Skip to content

Commit f371731

Browse files
authored
Merge branch refs/heads/1.11.x into 1.12.x
2 parents 3b50917 + 5c54586 commit f371731

File tree

3 files changed

+21
-13
lines changed

3 files changed

+21
-13
lines changed

Diff for: src/Type/Php/RegexExpressionHelper.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public function resolve(Expr $expr): Type
4444
&& $expr->name instanceof Name
4545
&& $expr->name->toLowerString() === 'preg_quote'
4646
) {
47-
return new ConstantStringType('');
47+
return new ConstantStringType('.*');
4848
}
4949

5050
if ($expr instanceof Concat) {

Diff for: tests/PHPStan/Rules/Regexp/RegularExpressionPatternRuleTest.php

+12-12
Original file line numberDiff line numberDiff line change
@@ -119,27 +119,27 @@ public function testValidRegexPatternBefore73(): void
119119
43,
120120
],
121121
[
122-
'Regex pattern is invalid: Delimiter must not be alphanumeric or backslash in pattern: nok',
122+
'Regex pattern is invalid: Delimiter must not be alphanumeric or backslash in pattern: nok.*',
123123
57,
124124
],
125125
[
126-
'Regex pattern is invalid: Delimiter must not be alphanumeric or backslash in pattern: nok',
126+
'Regex pattern is invalid: Delimiter must not be alphanumeric or backslash in pattern: nok.*',
127127
58,
128128
],
129129
[
130-
'Regex pattern is invalid: Compilation failed: missing ) at offset 1 in pattern: ~(~',
130+
'Regex pattern is invalid: Compilation failed: missing ) at offset 3 in pattern: ~(.*~',
131131
59,
132132
],
133133
[
134-
'Regex pattern is invalid: Delimiter must not be alphanumeric or backslash in pattern: noknono',
134+
'Regex pattern is invalid: Delimiter must not be alphanumeric or backslash in pattern: nok.*nono',
135135
61,
136136
],
137137
[
138-
'Regex pattern is invalid: Delimiter must not be alphanumeric or backslash in pattern: noknope',
138+
'Regex pattern is invalid: Delimiter must not be alphanumeric or backslash in pattern: nok.*nope',
139139
62,
140140
],
141141
[
142-
'Regex pattern is invalid: Compilation failed: missing ) at offset 1 in pattern: ~(~',
142+
'Regex pattern is invalid: Compilation failed: missing ) at offset 3 in pattern: ~(.*~',
143143
63,
144144
],
145145
],
@@ -249,27 +249,27 @@ public function testValidRegexPatternAfter73(): void
249249
43,
250250
],
251251
[
252-
sprintf('Regex pattern is invalid: Delimiter must not be %s in pattern: nok', $messagePart),
252+
sprintf('Regex pattern is invalid: Delimiter must not be %s in pattern: nok.*', $messagePart),
253253
57,
254254
],
255255
[
256-
sprintf('Regex pattern is invalid: Delimiter must not be %s in pattern: nok', $messagePart),
256+
sprintf('Regex pattern is invalid: Delimiter must not be %s in pattern: nok.*', $messagePart),
257257
58,
258258
],
259259
[
260-
'Regex pattern is invalid: Compilation failed: missing closing parenthesis at offset 1 in pattern: ~(~',
260+
'Regex pattern is invalid: Compilation failed: missing closing parenthesis at offset 3 in pattern: ~(.*~',
261261
59,
262262
],
263263
[
264-
sprintf('Regex pattern is invalid: Delimiter must not be %s in pattern: noknono', $messagePart),
264+
sprintf('Regex pattern is invalid: Delimiter must not be %s in pattern: nok.*nono', $messagePart),
265265
61,
266266
],
267267
[
268-
sprintf('Regex pattern is invalid: Delimiter must not be %s in pattern: noknope', $messagePart),
268+
sprintf('Regex pattern is invalid: Delimiter must not be %s in pattern: nok.*nope', $messagePart),
269269
62,
270270
],
271271
[
272-
'Regex pattern is invalid: Compilation failed: missing closing parenthesis at offset 1 in pattern: ~(~',
272+
'Regex pattern is invalid: Compilation failed: missing closing parenthesis at offset 3 in pattern: ~(.*~',
273273
63,
274274
],
275275
],

Diff for: tests/PHPStan/Rules/Regexp/data/valid-regex-pattern.php

+8
Original file line numberDiff line numberDiff line change
@@ -62,3 +62,11 @@ function doFoo(string $s) {
6262
preg_replace('nok'. preg_quote($s).'nope', '');
6363
preg_replace('~('. preg_quote($s, '~') .'~', '');
6464
}
65+
66+
class Bug11403
67+
{
68+
public function sayHello(string $s): void
69+
{
70+
preg_replace('![' . preg_quote($s) . ']+!u', $s, $s);
71+
}
72+
}

0 commit comments

Comments
 (0)