Skip to content

Commit 50d11a3

Browse files
staabmSeldaek
authored andcommitted
added more tests
1 parent 4017da4 commit 50d11a3

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

tests/PHPStanTests/nsrt/preg-match.php

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ function doMatch(string $s): void
99
{
1010
if (Preg::match('/Price: /i', $s, $matches)) {
1111
assertType('array{string}', $matches);
12+
} else {
13+
assertType('array{}', $matches);
1214
}
1315
assertType('array{}|array{string}', $matches);
1416

@@ -19,3 +21,23 @@ function doMatch(string $s): void
1921
}
2022
assertType('array{}|array{string, string}', $matches);
2123
}
24+
25+
function identicalMatch(string $s): void
26+
{
27+
if (Preg::match('/Price: /i', $s, $matches) === 1) {
28+
assertType('array{string}', $matches);
29+
} else {
30+
assertType('array{}', $matches);
31+
}
32+
assertType('array{}|array{string}', $matches);
33+
}
34+
35+
function equalMatch(string $s): void
36+
{
37+
if (Preg::match('/Price: /i', $s, $matches) == 1) {
38+
assertType('array{string}', $matches);
39+
} else {
40+
assertType('array{}', $matches);
41+
}
42+
assertType('array{}|array{string}', $matches);
43+
}

0 commit comments

Comments
 (0)