6
6
7
7
class HelloWorld
8
8
{
9
+ private const NUMERIC_STRING_1 = "1 " ;
10
+ private const NUMERIC_STRING_NEGATIVE_1 = "-1 " ;
9
11
public function doFoo ()
10
12
{
11
- assertType ('*ERROR* ' , preg_split ('/[0-9a] ' , '1-2-3 ' ));
12
13
assertType ("array{''} " , preg_split ('/-/ ' , '' ));
13
14
assertType ("array{} " , preg_split ('/-/ ' , '' , -1 , PREG_SPLIT_NO_EMPTY ));
14
15
assertType ("array{'1', '-', '2', '-', '3'} " , preg_split ('/ *(-) */ ' , '1- 2-3 ' , -1 , PREG_SPLIT_DELIM_CAPTURE ));
@@ -21,6 +22,19 @@ public function doFoo()
21
22
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 ));
22
23
assertType ("array{array{'1', 0}, array{'', 2}, array{'3', 3}} " , preg_split ('/-/ ' , '1--3 ' , -1 , PREG_SPLIT_OFFSET_CAPTURE ));
23
24
assertType ("array{array{'1', 0}, array{'3', 3}} " , preg_split ('/-/ ' , '1--3 ' , -1 , PREG_SPLIT_NO_EMPTY | PREG_SPLIT_OFFSET_CAPTURE ));
25
+
26
+ assertType ("array{'1', '2', '3'} " , preg_split ('/-/ ' , '1-2-3 ' , self ::NUMERIC_STRING_NEGATIVE_1 ));
27
+ assertType ("array{'1', '2', '3'} " , preg_split ('/-/ ' , '1-2-3 ' , -1 , self ::NUMERIC_STRING_1 ));
28
+ }
29
+
30
+ public function doWithError () {
31
+ assertType ('*ERROR* ' , preg_split ('/[0-9a] ' , '1-2-3 ' ));
32
+ assertType ('*ERROR* ' , preg_split ('/-/ ' , '1-2-3 ' , 'hogehoge ' ));
33
+ assertType ('*ERROR* ' , preg_split ('/-/ ' , '1-2-3 ' , -1 , 'hogehoge ' ));
34
+ assertType ('*ERROR* ' , preg_split ('/-/ ' , '1-2-3 ' , [], self ::NUMERIC_STRING_NEGATIVE_1 ));
35
+ assertType ('*ERROR* ' , preg_split ('/-/ ' , '1-2-3 ' , null , self ::NUMERIC_STRING_NEGATIVE_1 ));
36
+ assertType ('*ERROR* ' , preg_split ('/-/ ' , '1-2-3 ' , -1 , []));
37
+ assertType ('*ERROR* ' , preg_split ('/-/ ' , '1-2-3 ' , -1 , null ));
24
38
}
25
39
26
40
public function doWithVariables (string $ pattern , string $ subject , int $ offset , int $ flags ): void
0 commit comments