Skip to content

Commit 3dffc9a

Browse files
committed
fix
1 parent b05ecf5 commit 3dffc9a

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

src/Testing/TypeInferenceTestCase.php

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace PHPStan\Testing;
44

5+
use LogicException;
56
use PhpParser\Node;
67
use PhpParser\Node\Expr\StaticCall;
78
use 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

tests/PHPStan/Analyser/nsrt/bug-12866.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
<?php declare(strict_types = 1); // lint >= 8.0
1+
<?php // lint >= 8.0
2+
3+
declare(strict_types = 1);
24

35
namespace Bug12866;
46

0 commit comments

Comments
 (0)