File tree Expand file tree Collapse file tree 2 files changed +12
-3
lines changed
tests/PHPStan/Analyser/nsrt Expand file tree Collapse file tree 2 files changed +12
-3
lines changed Original file line number Diff line number Diff line change 22
33namespace PHPStan \Testing ;
44
5+ use LogicException ;
56use PhpParser \Node ;
67use PhpParser \Node \Expr \StaticCall ;
78use PhpParser \Node \Name ;
@@ -432,8 +433,12 @@ public static function findTestDataFilesFromDirectory(string $directory): array
432433 $ files = [];
433434 foreach ($ finder ->files ()->name ('*.php ' )->in ($ directory ) as $ fileInfo ) {
434435 $ path = $ fileInfo ->getPathname ();
435- if (self ::isFileLintSkipped ($ path )) {
436- continue ;
436+ try {
437+ if (self ::isFileLintSkipped ($ path )) {
438+ continue ;
439+ }
440+ } catch (LogicException $ e ) {
441+ self ::fail ($ e ->getMessage ());
437442 }
438443 $ files [] = $ path ;
439444 }
@@ -467,6 +472,8 @@ private static function isFileLintSkipped(string $file): bool
467472
468473 if (preg_match ('~<?php \\s* \\/ \\/\s*lint\s*([^\d\s]+)\s*([^\s]+)\s*~i ' , $ firstLine , $ m ) === 1 ) {
469474 return version_compare (PHP_VERSION , $ m [2 ], $ m [1 ]) === false ;
475+ } elseif (str_contains ($ firstLine , 'lint ' )) {
476+ throw new LogicException (sprintf ('// lint comment must immediately follow the php starting tag in %s ' , $ file ));
470477 }
471478 }
472479
Original file line number Diff line number Diff line change 1- <?php declare (strict_types = 1 ); // lint >= 8.0
1+ <?php // lint >= 8.0
2+
3+ declare (strict_types = 1 );
24
35namespace Bug12866 ;
46
You can’t perform that action at this time.
0 commit comments