Skip to content

Commit c98c498

Browse files
committed
Update tests for latest phpstan
1 parent 0c1da10 commit c98c498

File tree

1 file changed

+17
-17
lines changed

1 file changed

+17
-17
lines changed

tests/PHPStanTests/nsrt/preg-match.php

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -16,33 +16,33 @@ function doMatch(string $s): void
1616
assertType('array{}|array{string}', $matches);
1717

1818
if (Preg::match('/Price: (£|€)\d+/', $s, $matches)) {
19-
assertType('array{string, non-empty-string}', $matches);
19+
assertType('array{string, \'£\'|\'\'}', $matches);
2020
} else {
2121
assertType('array{}', $matches);
2222
}
23-
assertType('array{}|array{string, non-empty-string}', $matches);
23+
assertType('array{}|array{string, \'£\'|\'\'}', $matches);
2424

2525
if (Preg::match('/Price: (£|€)?\d+/', $s, $matches)) {
26-
assertType('array{string, non-empty-string|null}', $matches);
26+
assertType('array{string, \'£\'|\'\'|null}', $matches);
2727
} else {
2828
assertType('array{}', $matches);
2929
}
30-
assertType('array{}|array{string, non-empty-string|null}', $matches);
30+
assertType('array{}|array{string, \'£\'|\'\'|null}', $matches);
3131

3232
// passing the PREG_UNMATCHED_AS_NULL should change nothing compared to above as it is always set
3333
if (Preg::match('/Price: (£|€)?\d+/', $s, $matches, PREG_UNMATCHED_AS_NULL)) {
34-
assertType('array{string, non-empty-string|null}', $matches);
34+
assertType('array{string, \'£\'|\'\'|null}', $matches);
3535
} else {
3636
assertType('array{}', $matches);
3737
}
38-
assertType('array{}|array{string, non-empty-string|null}', $matches);
38+
assertType('array{}|array{string, \'£\'|\'\'|null}', $matches);
3939

4040
if (Preg::isMatch('/Price: (?<currency>£|€)\d+/', $s, $matches)) {
41-
assertType('array{0: string, currency: non-empty-string, 1: non-empty-string}', $matches);
41+
assertType('array{0: string, currency: \'£\'|\'\', 1: \'£\'|\'\'}', $matches);
4242
} else {
4343
assertType('array{}', $matches);
4444
}
45-
assertType('array{}|array{0: string, currency: non-empty-string, 1: non-empty-string}', $matches);
45+
assertType('array{}|array{0: string, currency: \'£\'|\'\', 1: \'£\'|\'\'}', $matches);
4646
}
4747

4848
function doMatchStrictGroups(string $s): void
@@ -55,18 +55,18 @@ function doMatchStrictGroups(string $s): void
5555
assertType('array{}|array{string}', $matches);
5656

5757
if (Preg::matchStrictGroups('/Price: (£|€)\d+/', $s, $matches)) {
58-
assertType('array{string, non-empty-string}', $matches);
58+
assertType('array{string, \'£\'|\'\'}', $matches);
5959
} else {
6060
assertType('array{}', $matches);
6161
}
62-
assertType('array{}|array{string, non-empty-string}', $matches);
62+
assertType('array{}|array{string, \'£\'|\'\'}', $matches);
6363

6464
if (Preg::isMatchStrictGroups('/Price: (?<test>£|€)\d+/', $s, $matches)) {
65-
assertType('array{0: string, test: non-empty-string, 1: non-empty-string}', $matches);
65+
assertType('array{0: string, test: \'£\'|\'\', 1: \'£\'|\'\'}', $matches);
6666
} else {
6767
assertType('array{}', $matches);
6868
}
69-
assertType('array{}|array{0: string, test: non-empty-string, 1: non-empty-string}', $matches);
69+
assertType('array{}|array{0: string, test: \'£\'|\'\', 1: \'£\'|\'\'}', $matches);
7070
}
7171

7272
function doMatchStrictGroupsUnsafe(string $s): void
@@ -98,21 +98,21 @@ function doMatchAllStrictGroups(string $s): void
9898
assertType('array{}|array{list<string>}', $matches);
9999

100100
if (Preg::matchAllStrictGroups('/Price: (£|€)\d+/', $s, $matches)) {
101-
assertType('array{list<string>, list<non-empty-string>}', $matches);
101+
assertType('array{list<string>, list<\'£\'|\'\'>}', $matches);
102102
} else {
103103
assertType('array{}', $matches);
104104
}
105-
assertType('array{}|array{list<string>, list<non-empty-string>}', $matches);
105+
assertType('array{}|array{list<string>, list<\'£\'|\'\'>}', $matches);
106106

107107
if (Preg::isMatchAllStrictGroups('/Price: (?<test>£|€)\d+/', $s, $matches)) {
108-
assertType('array{0: list<string>, test: list<non-empty-string>, 1: list<non-empty-string>}', $matches);
108+
assertType('array{0: list<string>, test: list<\'£\'|\'\'>, 1: list<\'£\'|\'\'>}', $matches);
109109
} else {
110110
assertType('array{}', $matches);
111111
}
112-
assertType('array{}|array{0: list<string>, test: list<non-empty-string>, 1: list<non-empty-string>}', $matches);
112+
assertType('array{}|array{0: list<string>, test: list<\'£\'|\'\'>, 1: list<\'£\'|\'\'>}', $matches);
113113

114114
if (Preg::isMatchAllStrictGroups('/Price: (?<test>£|€)?\d+/', $s, $matches)) {
115-
assertType('array{0: list<string>, test: list<non-empty-string>, 1: list<non-empty-string>}', $matches);
115+
assertType('array{0: list<string>, test: list<\'£\'|\'\'>, 1: list<\'£\'|\'\'>}', $matches);
116116
}
117117
}
118118

0 commit comments

Comments
 (0)