Skip to content

Commit 549376e

Browse files
NodeScopeResolver setting analysedFiles to limit analysis of traits outside analysedPaths is optional
1 parent 5c71ab2 commit 549376e

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/Analyser/NodeScopeResolver.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -180,8 +180,8 @@ class NodeScopeResolver
180180
private const LOOP_SCOPE_ITERATIONS = 3;
181181
private const GENERALIZE_AFTER_ITERATION = 1;
182182

183-
/** @var bool[] filePath(string) => bool(true) */
184-
private array $analysedFiles = [];
183+
/** @var ?array<string, bool> filePath(string) => bool(true) */
184+
private ?array $analysedFiles = [];
185185

186186
/** @var array<string, true> */
187187
private array $earlyTerminatingMethodNames = [];
@@ -222,11 +222,11 @@ public function __construct(
222222

223223
/**
224224
* @api
225-
* @param string[] $files
225+
* @param ?string[] $files
226226
*/
227-
public function setAnalysedFiles(array $files): void
227+
public function setAnalysedFiles(?array $files): void
228228
{
229-
$this->analysedFiles = array_fill_keys($files, true);
229+
$this->analysedFiles = $files !== null ? array_fill_keys($files, true) : null;
230230
}
231231

232232
/**
@@ -4075,7 +4075,7 @@ private function processTraitUse(Node\Stmt\TraitUse $node, MutatingScope $classS
40754075
continue; // trait from eval or from PHP itself
40764076
}
40774077
$fileName = $this->fileHelper->normalizePath($traitFileName);
4078-
if (!isset($this->analysedFiles[$fileName])) {
4078+
if ($this->analysedFiles !== null && !isset($this->analysedFiles[$fileName])) {
40794079
continue;
40804080
}
40814081
$parserNodes = $this->parser->parseFile($fileName);

0 commit comments

Comments
 (0)