File tree Expand file tree Collapse file tree 1 file changed +53
-0
lines changed
tests/PHPStan/Rules/Regexp Expand file tree Collapse file tree 1 file changed +53
-0
lines changed Original file line number Diff line number Diff line change @@ -276,4 +276,57 @@ public function testValidRegexPatternAfter73(): void
276276 );
277277 }
278278
279+ /**
280+ * @param list<array{0: string, 1: int, 2?: string|null}> $errors
281+ * @dataProvider dataArrayShapePatterns
282+ */
283+ public function testArrayShapePatterns (string $ file , array $ errors ): void
284+ {
285+ $ this ->analyse (
286+ [$ file ],
287+ $ errors ,
288+ );
289+ }
290+
291+ public function dataArrayShapePatterns (): iterable
292+ {
293+ yield [
294+ __DIR__ . '/../../Analyser/nsrt/preg_match_all_shapes.php ' ,
295+ [],
296+ ];
297+
298+ yield [
299+ __DIR__ . '/../../Analyser/nsrt/preg_match_shapes.php ' ,
300+ [
301+ [
302+ "Regex pattern is invalid: Unknown modifier 'y' in pattern: /(foo)(bar)(baz)/xyz " ,
303+ 124 ,
304+ ],
305+ ],
306+ ];
307+
308+ if (PHP_VERSION_ID >= 80000 ) {
309+ yield [
310+ __DIR__ . '/../../Analyser/nsrt/preg_match_shapes_php80.php ' ,
311+ [],
312+ ];
313+ }
314+
315+ if (PHP_VERSION_ID >= 80200 ) {
316+ yield [
317+ __DIR__ . '/../../Analyser/nsrt/preg_match_shapes_php82.php ' ,
318+ [],
319+ ];
320+ }
321+
322+ yield [
323+ __DIR__ . '/../../Analyser/nsrt/preg_replace_callback_shapes.php ' ,
324+ [],
325+ ];
326+ yield [
327+ __DIR__ . '/../../Analyser/nsrt/preg_replace_callback_shapes-php72.php ' ,
328+ [],
329+ ];
330+ }
331+
279332}
You can’t perform that action at this time.
0 commit comments