|
6 | 6 |
|
7 | 7 | class HelloWorld |
8 | 8 | { |
| 9 | + public function doFoo() |
| 10 | + { |
| 11 | + assertType('*ERROR*', preg_split('/[0-9a]', '1-2-3')); |
| 12 | + assertType("array{''}", preg_split('/-/', '')); |
| 13 | + assertType("array{}", preg_split('/-/', '', -1, PREG_SPLIT_NO_EMPTY)); |
| 14 | + assertType("array{array{'', 0}}", preg_split('/-/', '', -1, PREG_SPLIT_OFFSET_CAPTURE)); |
| 15 | + assertType("array{}", preg_split('/-/', '', -1, PREG_SPLIT_NO_EMPTY | PREG_SPLIT_OFFSET_CAPTURE)); |
| 16 | + assertType("array{'1', '2', '3'}", preg_split('/-/', '1-2-3')); |
| 17 | + assertType("array{'1', '2', '3'}", preg_split('/-/', '1-2-3', -1, PREG_SPLIT_NO_EMPTY)); |
| 18 | + assertType("array{'1', '3'}", preg_split('/-/', '1--3', -1, PREG_SPLIT_NO_EMPTY)); |
| 19 | + assertType("array{array{'1', 0}, array{'2', 2}, array{'3', 4}}", preg_split('/-/', '1-2-3', -1, PREG_SPLIT_OFFSET_CAPTURE)); |
| 20 | + assertType("array{array{'1', 0}, array{'2', 2}, array{'3', 4}}", preg_split('/-/', '1-2-3', -1, PREG_SPLIT_NO_EMPTY | PREG_SPLIT_OFFSET_CAPTURE)); |
| 21 | + assertType("array{array{'1', 0}, array{'', 2}, array{'3', 3}}", preg_split('/-/', '1--3', -1, PREG_SPLIT_OFFSET_CAPTURE)); |
| 22 | + assertType("array{array{'1', 0}, array{'3', 3}}", preg_split('/-/', '1--3', -1, PREG_SPLIT_NO_EMPTY | PREG_SPLIT_OFFSET_CAPTURE)); |
| 23 | + } |
| 24 | + |
| 25 | + /** |
| 26 | + * @param non-empty-string $nonEmptySubject |
| 27 | + */ |
| 28 | + public function doWithVariables(string $pattern, string $subject, string $nonEmptySubject, int $offset, int $flags): void |
| 29 | + { |
| 30 | + assertType('(list<array{string, int<0, max>}|string>|false)', preg_split($pattern, $subject, $offset, $flags)); |
| 31 | + assertType('(list<array{string, int<0, max>}|string>|false)', preg_split("//", $subject, $offset, $flags)); |
| 32 | + |
| 33 | + assertType('(non-empty-list<array{string, int<0, max>}|string>|false)', preg_split($pattern, $nonEmptySubject, $offset, $flags)); |
| 34 | + assertType('(non-empty-list<array{string, int<0, max>}|string>|false)', preg_split("//", $nonEmptySubject, $offset, $flags)); |
| 35 | + |
| 36 | + assertType('(non-empty-list<string>|false)', preg_split("//", $nonEmptySubject)); |
| 37 | + |
| 38 | + assertType('(non-empty-list<array{string, int<0, max>}|string>|false)', preg_split($pattern, "1-2-3", $offset, $flags)); |
| 39 | + assertType('(list<array{string, int<0, max>}|string>|false)', preg_split($pattern, $subject, -1, $flags)); |
| 40 | + assertType('(list<non-empty-string>|false)', preg_split($pattern, $subject, $offset, PREG_SPLIT_NO_EMPTY)); |
| 41 | + assertType('(list<array{string, int<0, max>}>|false)', preg_split($pattern, $subject, $offset, PREG_SPLIT_OFFSET_CAPTURE)); |
| 42 | + } |
| 43 | + |
9 | 44 | /** |
10 | 45 | * @param string $pattern |
11 | 46 | * @param string $subject |
@@ -36,34 +71,4 @@ public static function dynamicFlags($pattern, $subject, $limit = -1) |
36 | 71 |
|
37 | 72 | assertType('(list<array{string, int<0, max>}>|false)', preg_split($pattern, $subject, $limit, $flags)); |
38 | 73 | } |
39 | | - |
40 | | - public function doFoo() |
41 | | - { |
42 | | - assertType('*ERROR*', preg_split('/[0-9a]', '1-2-3')); |
43 | | - assertType("array{''}", preg_split('/-/', '')); |
44 | | - assertType("array{'1', '2', '3'}", preg_split('/-/', '1-2-3')); |
45 | | - assertType("array{'1', '2', '3'}", preg_split('/-/', '1-2-3', -1, PREG_SPLIT_NO_EMPTY)); |
46 | | - assertType("array{'1', '3'}", preg_split('/-/', '1--3', -1, PREG_SPLIT_NO_EMPTY)); |
47 | | - assertType("array{array{'1', 0}, array{'2', 2}, array{'3', 4}}", preg_split('/-/', '1-2-3', -1, PREG_SPLIT_OFFSET_CAPTURE)); |
48 | | - assertType("array{array{'1', 0}, array{'2', 2}, array{'3', 4}}", preg_split('/-/', '1-2-3', -1, PREG_SPLIT_NO_EMPTY | PREG_SPLIT_OFFSET_CAPTURE)); |
49 | | - assertType("array{array{'1', 0}, array{'', 2}, array{'3', 3}}", preg_split('/-/', '1--3', -1, PREG_SPLIT_OFFSET_CAPTURE)); |
50 | | - assertType("array{array{'1', 0}, array{'3', 3}}", preg_split('/-/', '1--3', -1, PREG_SPLIT_NO_EMPTY | PREG_SPLIT_OFFSET_CAPTURE)); |
51 | | - } |
52 | | - |
53 | | - /** |
54 | | - * @param non-empty-string $nonEmptySubject |
55 | | - */ |
56 | | - public function doWithVariables(string $pattern, string $subject, string $nonEmptySubject, int $offset, int $flags): void |
57 | | - { |
58 | | - assertType('(list<array{string, int<0, max>}|string>|false)', preg_split($pattern, $subject, $offset, $flags)); |
59 | | - assertType('(list<array{string, int<0, max>}|string>|false)', preg_split("//", $subject, $offset, $flags)); |
60 | | - |
61 | | - assertType('(list<array{string, int<0, max>}|string>|false)', preg_split($pattern, $nonEmptySubject, $offset, $flags)); |
62 | | - assertType('(list<array{string, int<0, max>}|string>|false)', preg_split("//", $nonEmptySubject, $offset, $flags)); |
63 | | - |
64 | | - assertType('(list<array{string, int<0, max>}|string>|false)', preg_split($pattern, "1-2-3", $offset, $flags)); |
65 | | - assertType('(list<array{string, int<0, max>}|string>|false)', preg_split($pattern, $subject, -1, $flags)); |
66 | | - assertType('(list<non-empty-string>|false)', preg_split($pattern, $subject, $offset, PREG_SPLIT_NO_EMPTY)); |
67 | | - assertType('(list<array{string, int<0, max>}>|false)', preg_split($pattern, $subject, $offset, PREG_SPLIT_OFFSET_CAPTURE)); |
68 | | - } |
69 | 74 | } |
0 commit comments