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
5 changes: 3 additions & 2 deletions src/RuleTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
use function sort;
use function sprintf;
use function str_replace;
use function strpos;
use function trim;
use function uniqid;
use const DIRECTORY_SEPARATOR;
Expand All @@ -48,7 +49,7 @@ protected function analyzeFiles(

if ($autofix) {
foreach ($files as $file) {
$fileErrors = array_filter($analyserErrors, static fn (Error $error): bool => $error->getFilePath() === $file);
$fileErrors = array_filter($analyserErrors, static fn (Error $error): bool => strpos($error->getFile(), $file) === 0);
$this->autofix($file, array_values($fileErrors));
}

Expand All @@ -59,7 +60,7 @@ protected function analyzeFiles(
}

foreach ($files as $file) {
$fileErrors = array_filter($analyserErrors, static fn (Error $error): bool => $error->getFilePath() === $file);
$fileErrors = array_filter($analyserErrors, static fn (Error $error): bool => strpos($error->getFile(), $file) === 0);
$actualErrors = $this->processActualErrors(array_values($fileErrors));
$expectedErrors = $this->parseExpectedErrors($file);

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?php declare(strict_types = 1);

namespace DisallowDivisionByLiteralZeroRule;

class TraitUser {
use MyTrait;
}
3 changes: 0 additions & 3 deletions tests/Rule/Data/DisallowDivisionByLiteralZeroRule/trait.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,3 @@ public function emitError(): float
}
}

class TraitUser {
use MyTrait;
}
5 changes: 4 additions & 1 deletion tests/RuleTestCaseTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,10 @@ public function testRule(): void

public function testTrait(): void
{
$this->analyzeFiles([__DIR__ . '/Rule/Data/DisallowDivisionByLiteralZeroRule/trait.php']);
$this->analyzeFiles([
__DIR__ . '/Rule/Data/DisallowDivisionByLiteralZeroRule/trait.php',
__DIR__ . '/Rule/Data/DisallowDivisionByLiteralZeroRule/trait-user.php',
]);
}

public function testMultipleErrorsOnSameLine(): void
Expand Down