Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/Excluder/TestsUsageExcluder.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,14 +68,14 @@ public function shouldExclude(ClassMemberUsage $usage, Node $node, Scope $scope)
return false;
}

return $this->isWithinDevPaths($this->realpath($scope->getFile()))
&& !$this->isWithinDevPaths($this->getDeclarationFile($usage->getMemberRef()->getClassName()));
return $this->isWithinDevPaths($this->realpath($scope->getFile())) === true
&& $this->isWithinDevPaths($this->getDeclarationFile($usage->getMemberRef()->getClassName())) === false;
}

private function isWithinDevPaths(?string $filePath): bool
private function isWithinDevPaths(?string $filePath): ?bool
{
if ($filePath === null) {
return false;
return null;
}

foreach ($this->devPaths as $devPath) {
Expand Down
1 change: 1 addition & 0 deletions tests/Rule/data/excluders/tests/src/code.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

class DeclaredInSrcUsedInTests {
const CONST = 1; // error: Unused DeclaredInSrcUsedInTests::CONST (all usages excluded by tests excluder)
const MIXED = 2;
}

class DeclaredInSrcUsedInBoth {
Expand Down
3 changes: 2 additions & 1 deletion tests/Rule/data/excluders/tests/tests/code.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@ class DeclaredInTestsUsedInSrc {
const CONST = 1;
}

function test1() {
function test1($mixed) {
echo DeclaredInSrcUsedInBoth::CONST;
echo DeclaredInSrcUsedInTests::CONST;
echo DeclaredInTestsUsedInTests::CONST;
echo DeclaredInTestsUsedInBoth::CONST;
$mixed::MIXED;
}