Skip to content

Commit 924de19

Browse files
authored
Do not report Composer\InstalledVersions (#5)
1 parent 585a069 commit 924de19

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

src/ComposerDependencyAnalyser.php

+12
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,10 @@ public function scan(array $scanPaths): array
9393
continue;
9494
}
9595

96+
if ($this->isComposerInternalClass($usedSymbol)) {
97+
continue;
98+
}
99+
96100
if (!isset($this->optimizedClassmap[$usedSymbol])) {
97101
if (!$this->isConstOrFunction($usedSymbol)) {
98102
$errors[$usedSymbol] = new ClassmapEntryMissingError($usedSymbol, $filePath);
@@ -225,4 +229,12 @@ private function isConstOrFunction(string $usedClass): bool
225229
return defined($usedClass) || function_exists($usedClass);
226230
}
227231

232+
/**
233+
* Those are always available: https://getcomposer.org/doc/07-runtime.md#installed-versions
234+
*/
235+
private function isComposerInternalClass(string $usedSymbol): bool
236+
{
237+
return $usedSymbol === 'Composer\\InstalledVersions';
238+
}
239+
228240
}

tests/data/shadow-dependencies.php

+2
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,5 @@
1818

1919
echo \DIRECTORY_SEPARATOR;
2020
echo \strlen('');
21+
22+
\Composer\InstalledVersions::getInstalledPackages();

0 commit comments

Comments
 (0)