File tree 2 files changed +9
-2
lines changed
tests/PHPStan/Rules/Regexp
2 files changed +9
-2
lines changed Original file line number Diff line number Diff line change 13
13
use PHPStan \Type \Regex \RegexExpressionHelper ;
14
14
use function in_array ;
15
15
use function sprintf ;
16
- use function str_contains ;
17
16
use function str_starts_with ;
17
+ use function stripos ;
18
18
use function strlen ;
19
19
use function strpos ;
20
20
use function strtolower ;
@@ -128,7 +128,10 @@ private function validatePattern(string $pattern): ?string
128
128
try {
129
129
Strings::match ('' , $ pattern );
130
130
} catch (RegexpException $ e ) {
131
- if (str_contains ($ e ->getMessage (), 'UTF-8 error ' )) {
131
+ if (
132
+ stripos ($ e ->getMessage (), 'Compilation failed ' ) !== false
133
+ && stripos ($ e ->getMessage (), 'UTF-8 ' ) !== false
134
+ ) {
132
135
$ patternPos = strpos ($ e ->getMessage (), 'pattern: ' );
133
136
if ($ patternPos === false ) {
134
137
throw new ShouldNotHappenException ();
Original file line number Diff line number Diff line change @@ -334,6 +334,10 @@ public function dataArrayShapePatterns(): iterable
334
334
335
335
public function testBug12629 (): void
336
336
{
337
+ if (PHP_VERSION_ID < 70300 ) {
338
+ $ this ->markTestSkipped ('This test requires PHP >= 7.3.0 ' );
339
+ }
340
+
337
341
$ this ->analyse (
338
342
[__DIR__ . '/data/bug-12629.php ' ],
339
343
[
You can’t perform that action at this time.
0 commit comments