Skip to content

Commit 179b213

Browse files
committed
Fix PHPStan Pro reanalyse results
1 parent 8fe9e60 commit 179b213

5 files changed

Lines changed: 18 additions & 11 deletions

File tree

conf/config.neon

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -316,6 +316,7 @@ parametersSchema:
316316

317317
# internal - static reflection
318318
singleReflectionFile: schema(string(), nullable())
319+
singleReflectionInsteadOfFile: schema(string(), nullable())
319320

320321
rules:
321322
- PHPStan\Rules\Debug\DumpTypeRule
@@ -1474,6 +1475,7 @@ services:
14741475
arguments:
14751476
reflectionProvider: @innerRuntimeReflectionProvider
14761477
patterns: %staticReflectionClassNamePatterns%
1478+
singleReflectionInsteadOfFile: %singleReflectionInsteadOfFile%
14771479
autowired: false
14781480

14791481
innerRuntimeReflectionProvider:

src/Command/CommandHelper.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,8 @@ public static function begin(
4747
bool $allowXdebug,
4848
bool $manageMemoryLimitFile = true,
4949
bool $debugEnabled = false,
50-
?string $singleReflectionFile = null
50+
?string $singleReflectionFile = null,
51+
?string $singleReflectionInsteadOfFile = null
5152
): InceptionResult
5253
{
5354
if (!$allowXdebug) {
@@ -249,7 +250,7 @@ public static function begin(
249250
}
250251

251252
try {
252-
$container = $containerFactory->create($tmpDir, $additionalConfigFiles, $paths, $composerAutoloaderProjectPaths, $analysedPathsFromConfig, $level ?? self::DEFAULT_LEVEL, $generateBaselineFile, $autoloadFile, $singleReflectionFile);
253+
$container = $containerFactory->create($tmpDir, $additionalConfigFiles, $paths, $composerAutoloaderProjectPaths, $analysedPathsFromConfig, $level ?? self::DEFAULT_LEVEL, $generateBaselineFile, $autoloadFile, $singleReflectionFile, $singleReflectionInsteadOfFile);
253254
} catch (\Nette\DI\InvalidConfigurationException | \Nette\Utils\AssertionException $e) {
254255
$errorOutput->writeLineFormatted('<error>Invalid configuration:</error>');
255256
$errorOutput->writeLineFormatted($e->getMessage());

src/Command/FixerWorkerCommand.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,8 @@ protected function execute(InputInterface $input, OutputInterface $output): int
117117
$allowXdebug,
118118
false,
119119
false,
120-
$singleReflectionFile
120+
$singleReflectionFile,
121+
$insteadOfFile
121122
);
122123
} catch (\PHPStan\Command\InceptionNotSuccessfulException $e) {
123124
return 1;

src/DependencyInjection/ContainerFactory.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ public function __construct(string $currentWorkingDirectory)
5151
* @param string|null $generateBaselineFile
5252
* @param string|null $cliAutoloadFile
5353
* @param string|null $singleReflectionFile
54+
* @param string|null $singleReflectionInsteadOfFile
5455
* @return \PHPStan\DependencyInjection\Container
5556
*/
5657
public function create(
@@ -62,7 +63,8 @@ public function create(
6263
string $usedLevel = CommandHelper::DEFAULT_LEVEL,
6364
?string $generateBaselineFile = null,
6465
?string $cliAutoloadFile = null,
65-
?string $singleReflectionFile = null
66+
?string $singleReflectionFile = null,
67+
?string $singleReflectionInsteadOfFile = null
6668
): Container
6769
{
6870
$configurator = new Configurator(new LoaderFactory(
@@ -93,6 +95,7 @@ public function create(
9395
]);
9496
$configurator->addDynamicParameters([
9597
'singleReflectionFile' => $singleReflectionFile,
98+
'singleReflectionInsteadOfFile' => $singleReflectionInsteadOfFile,
9699
]);
97100
$configurator->addConfig($this->configDirectory . '/config.neon');
98101
foreach ($additionalConfigFiles as $additionalConfigFile) {

src/Reflection/ReflectionProvider/ClassBlacklistReflectionProvider.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class ClassBlacklistReflectionProvider implements ReflectionProvider
2121
/** @var string[] */
2222
private array $patterns;
2323

24-
private ?string $singleReflectionFile;
24+
private ?string $singleReflectionInsteadOfFile;
2525

2626
/**
2727
* @param \PHPStan\Reflection\ReflectionProvider $reflectionProvider
@@ -31,13 +31,13 @@ public function __construct(
3131
ReflectionProvider $reflectionProvider,
3232
PhpStormStubsSourceStubber $phpStormStubsSourceStubber,
3333
array $patterns,
34-
?string $singleReflectionFile
34+
?string $singleReflectionInsteadOfFile
3535
)
3636
{
3737
$this->reflectionProvider = $reflectionProvider;
3838
$this->phpStormStubsSourceStubber = $phpStormStubsSourceStubber;
3939
$this->patterns = $patterns;
40-
$this->singleReflectionFile = $singleReflectionFile;
40+
$this->singleReflectionInsteadOfFile = $singleReflectionInsteadOfFile;
4141
}
4242

4343
public function hasClass(string $className): bool
@@ -52,8 +52,8 @@ public function hasClass(string $className): bool
5252
}
5353

5454
$classReflection = $this->reflectionProvider->getClass($className);
55-
if ($this->singleReflectionFile !== null) {
56-
if ($classReflection->getFileName() === $this->singleReflectionFile) {
55+
if ($this->singleReflectionInsteadOfFile !== null) {
56+
if ($classReflection->getFileName() === $this->singleReflectionInsteadOfFile) {
5757
return false;
5858
}
5959
}
@@ -133,7 +133,7 @@ public function hasFunction(\PhpParser\Node\Name $nameNode, ?Scope $scope): bool
133133
return false;
134134
}
135135

136-
if ($this->singleReflectionFile === null) {
136+
if ($this->singleReflectionInsteadOfFile === null) {
137137
return true;
138138
}
139139

@@ -142,7 +142,7 @@ public function hasFunction(\PhpParser\Node\Name $nameNode, ?Scope $scope): bool
142142
return true;
143143
}
144144

145-
return $functionReflection->getFileName() !== $this->singleReflectionFile;
145+
return $functionReflection->getFileName() !== $this->singleReflectionInsteadOfFile;
146146
}
147147

148148
public function getFunction(\PhpParser\Node\Name $nameNode, ?Scope $scope): FunctionReflection

0 commit comments

Comments
 (0)