Skip to content

Commit 518f9e7

Browse files
committed
RegularExpressionPatternRuleTest: utilize preg_match() array shape tests
1 parent 28022f2 commit 518f9e7

File tree

1 file changed

+55
-0
lines changed

1 file changed

+55
-0
lines changed

tests/PHPStan/Rules/Regexp/RegularExpressionPatternRuleTest.php

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -276,4 +276,59 @@ public function testValidRegexPatternAfter73(): void
276276
);
277277
}
278278

279+
/**
280+
* @dataProvider dataArrayShapePatterns
281+
*/
282+
public function testArrayShapePatterns(string $file, array $errors): void
283+
{
284+
$this->analyse(
285+
[$file],
286+
$errors
287+
);
288+
}
289+
290+
public function dataArrayShapePatterns(): iterable
291+
{
292+
yield [
293+
__DIR__ . '/../../Analyser/nsrt/preg_match_all_shapes.php',
294+
[]
295+
];
296+
yield [
297+
__DIR__ . '/../../Analyser/nsrt/preg_match_php7.php',
298+
[]
299+
];
300+
yield [
301+
__DIR__ . '/../../Analyser/nsrt/preg_match_php8.php',
302+
[]
303+
];
304+
305+
yield [
306+
__DIR__ . '/../../Analyser/nsrt/preg_match_shapes.php',
307+
[
308+
[
309+
"Regex pattern is invalid: Unknown modifier 'y' in pattern: /(foo)(bar)(baz)/xyz",
310+
124
311+
]
312+
]
313+
];
314+
315+
yield [
316+
__DIR__ . '/../../Analyser/nsrt/preg_match_shapes_php80.php',
317+
[]
318+
];
319+
yield [
320+
__DIR__ . '/../../Analyser/nsrt/preg_match_shapes_php82.php',
321+
[]
322+
];
323+
324+
yield [
325+
__DIR__ . '/../../Analyser/nsrt/preg_replace_callback_shapes.php',
326+
[]
327+
];
328+
yield [
329+
__DIR__ . '/../../Analyser/nsrt/preg_replace_callback_shapes-php72.php',
330+
[]
331+
];
332+
}
333+
279334
}

0 commit comments

Comments
 (0)