Skip to content

Commit eb79c5c

Browse files
committed
fix
1 parent f038703 commit eb79c5c

File tree

5 files changed

+18
-18
lines changed

5 files changed

+18
-18
lines changed

tests/PHPStan/Analyser/nsrt/bug-11293.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,21 +9,21 @@ class HelloWorld
99
public function sayHello(string $s): void
1010
{
1111
if (preg_match('/data-(\d{6})\.json$/', $s, $matches) > 0) {
12-
assertType('array{string, non-falsy-string&numeric-string}', $matches);
12+
assertType('array{non-falsy-string, non-falsy-string&numeric-string}', $matches);
1313
}
1414
}
1515

1616
public function sayHello2(string $s): void
1717
{
1818
if (preg_match('/data-(\d{6})\.json$/', $s, $matches) === 1) {
19-
assertType('array{string, non-falsy-string&numeric-string}', $matches);
19+
assertType('array{non-falsy-string, non-falsy-string&numeric-string}', $matches);
2020
}
2121
}
2222

2323
public function sayHello3(string $s): void
2424
{
2525
if (preg_match('/data-(\d{6})\.json$/', $s, $matches) >= 1) {
26-
assertType('array{string, non-falsy-string&numeric-string}', $matches);
26+
assertType('array{non-falsy-string, non-falsy-string&numeric-string}', $matches);
2727
}
2828
}
2929

@@ -35,7 +35,7 @@ public function sayHello4(string $s): void
3535
return;
3636
}
3737

38-
assertType('array{string, non-falsy-string&numeric-string}', $matches);
38+
assertType('array{non-falsy-string, non-falsy-string&numeric-string}', $matches);
3939
}
4040

4141
public function sayHello5(string $s): void
@@ -46,7 +46,7 @@ public function sayHello5(string $s): void
4646
return;
4747
}
4848

49-
assertType('array{string, non-falsy-string&numeric-string}', $matches);
49+
assertType('array{non-falsy-string, non-falsy-string&numeric-string}', $matches);
5050
}
5151

5252
public function sayHello6(string $s): void
@@ -57,6 +57,6 @@ public function sayHello6(string $s): void
5757
return;
5858
}
5959

60-
assertType('array{string, non-falsy-string&numeric-string}', $matches);
60+
assertType('array{non-falsy-string, non-falsy-string&numeric-string}', $matches);
6161
}
6262
}

tests/PHPStan/Analyser/nsrt/bug-11580.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ public function bad(string $in): void
1010
{
1111
$matches = [];
1212
if (preg_match('~^/xxx/([\w\-]+)/?([\w\-]+)?/?$~', $in, $matches)) {
13-
assertType('array{0: string, 1: non-empty-string, 2?: non-empty-string}', $matches);
13+
assertType('array{0: non-falsy-string, 1: non-empty-string, 2?: non-empty-string}', $matches);
1414
}
1515
}
1616

@@ -19,7 +19,7 @@ public function bad2(string $in): void
1919
$matches = [];
2020
$result = preg_match('~^/xxx/([\w\-]+)/?([\w\-]+)?/?$~', $in, $matches);
2121
if ($result) {
22-
assertType('array{0: string, 1: non-empty-string, 2?: non-empty-string}', $matches);
22+
assertType('array{0: non-falsy-string, 1: non-empty-string, 2?: non-empty-string}', $matches);
2323
}
2424
}
2525

@@ -28,7 +28,7 @@ public function bad3(string $in): void
2828
$result = preg_match('~^/xxx/([\w\-]+)/?([\w\-]+)?/?$~', $in, $matches);
2929
assertType('array{0?: string, 1?: non-empty-string, 2?: non-empty-string}', $matches);
3030
if ($result) {
31-
assertType('array{0: string, 1: non-empty-string, 2?: non-empty-string}', $matches);
31+
assertType('array{0: non-falsy-string, 1: non-empty-string, 2?: non-empty-string}', $matches);
3232
}
3333
}
3434

tests/PHPStan/Analyser/nsrt/bug-12210.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,20 @@
88

99
function bug12210a(string $text): void {
1010
assert(preg_match('(((sum|min|max)))', $text, $match) === 1);
11-
assertType("array{string, 'max'|'min'|'sum', 'max'|'min'|'sum'}", $match);
11+
assertType("array{non-empty-string, 'max'|'min'|'sum', 'max'|'min'|'sum'}", $match);
1212
}
1313

1414
function bug12210b(string $text): void {
1515
assert(preg_match('(((sum|min|ma.)))', $text, $match) === 1);
16-
assertType("array{string, non-empty-string, non-falsy-string}", $match);
16+
assertType("array{non-empty-string, non-empty-string, non-falsy-string}", $match);
1717
}
1818

1919
function bug12210c(string $text): void {
2020
assert(preg_match('(((su.|min|max)))', $text, $match) === 1);
21-
assertType("array{string, non-empty-string, non-falsy-string}", $match);
21+
assertType("array{non-empty-string, non-empty-string, non-falsy-string}", $match);
2222
}
2323

2424
function bug12210d(string $text): void {
2525
assert(preg_match('(((sum|mi.|max)))', $text, $match) === 1);
26-
assertType("array{string, non-empty-string, non-falsy-string}", $match);
26+
assertType("array{non-empty-string, non-empty-string, non-falsy-string}", $match);
2727
}

tests/PHPStan/Analyser/nsrt/bug-12242.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ function bar(string $str): void
2727
(\w*) # extra description (UNSIGNED, CHARACTER SET, ...) [3]
2828
$/x';
2929
if (preg_match($regexp, $str, $matches)) {
30-
assertType('array{string, non-empty-string, string, string}', $matches);
30+
assertType('array{non-falsy-string, non-empty-string, string, string}', $matches);
3131
}
3232
}
3333

tests/PHPStan/Analyser/nsrt/preg_match_shapes_php80.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,15 @@
77
function doOffsetCaptureWithUnmatchedNull(string $s): void {
88
// see https://3v4l.org/07rBO#v8.2.9
99
if (preg_match('/(foo)(bar)(baz)/', $s, $matches, PREG_OFFSET_CAPTURE|PREG_UNMATCHED_AS_NULL)) {
10-
assertType("array{array{string|null, int<-1, max>}, array{'foo'|null, int<-1, max>}, array{'bar'|null, int<-1, max>}, array{'baz'|null, int<-1, max>}}", $matches);
10+
assertType("array{array{non-falsy-string|null, int<-1, max>}, array{'foo'|null, int<-1, max>}, array{'bar'|null, int<-1, max>}, array{'baz'|null, int<-1, max>}}", $matches);
1111
}
12-
assertType("array{}|array{array{string|null, int<-1, max>}, array{'foo'|null, int<-1, max>}, array{'bar'|null, int<-1, max>}, array{'baz'|null, int<-1, max>}}", $matches);
12+
assertType("array{}|array{array{non-falsy-string|null, int<-1, max>}, array{'foo'|null, int<-1, max>}, array{'bar'|null, int<-1, max>}, array{'baz'|null, int<-1, max>}}", $matches);
1313
}
1414

1515
function doNonAutoCapturingModifier(string $s): void {
1616
if (preg_match('/(?n)(\d+)/', $s, $matches)) {
1717
// should be assertType('array{string}', $matches);
18-
assertType('array{string, numeric-string}', $matches);
18+
assertType('array{non-falsy-string, numeric-string}', $matches);
1919
}
20-
assertType('array{}|array{string, numeric-string}', $matches);
20+
assertType('array{}|array{non-falsy-string, numeric-string}', $matches);
2121
}

0 commit comments

Comments
 (0)