Skip to content

Commit 2a145ba

Browse files
committed
PHPStan Pro - fix for potential issues
1 parent 9044bfc commit 2a145ba

File tree

3 files changed

+8
-2
lines changed

3 files changed

+8
-2
lines changed

conf/config.neon

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1820,6 +1820,7 @@ services:
18201820
currentPhpVersionRichParser: @currentPhpVersionRichParser
18211821
currentPhpVersionSimpleParser: @currentPhpVersionSimpleParser
18221822
php8Parser: @php8Parser
1823+
singleReflectionFile: %singleReflectionFile%
18231824
autowired: false
18241825

18251826
# Error formatters

src/Parser/PathRoutingParser.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
class PathRoutingParser implements Parser
1010
{
1111

12+
private ?string $singleReflectionFile;
13+
1214
/** @var bool[] filePath(string) => bool(true) */
1315
private array $analysedFiles = [];
1416

@@ -17,8 +19,10 @@ public function __construct(
1719
private Parser $currentPhpVersionRichParser,
1820
private Parser $currentPhpVersionSimpleParser,
1921
private Parser $php8Parser,
22+
?string $singleReflectionFile,
2023
)
2124
{
25+
$this->singleReflectionFile = $singleReflectionFile !== null ? $fileHelper->normalizePath($singleReflectionFile) : null;
2226
}
2327

2428
/**
@@ -36,7 +40,7 @@ public function parseFile(string $file): array
3640
}
3741

3842
$file = $this->fileHelper->normalizePath($file);
39-
if (!isset($this->analysedFiles[$file])) {
43+
if (!isset($this->analysedFiles[$file]) && $file !== $this->singleReflectionFile) {
4044
return $this->currentPhpVersionSimpleParser->parseFile($file);
4145
}
4246

tests/PHPStan/Parser/CachedParserTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,8 @@ public function testParseTheSameFileWithDifferentMethod(): void
8989
$fileHelper,
9090
self::getContainer()->getService('currentPhpVersionRichParser'),
9191
self::getContainer()->getService('currentPhpVersionSimpleDirectParser'),
92-
self::getContainer()->getService('php8Parser')
92+
self::getContainer()->getService('php8Parser'),
93+
null
9394
);
9495
$parser = new CachedParser($pathRoutingParser, 500);
9596
$path = $fileHelper->normalizePath(__DIR__ . '/data/test.php');

0 commit comments

Comments
 (0)