Skip to content

Commit

Permalink
DisallowFqn - resolve conflict with UnusedImport sniff when imported …
Browse files Browse the repository at this point in the history
…class was removed
  • Loading branch information
michalbundyra committed May 5, 2019
1 parent d0d09ff commit eed69d3
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/WebimpressCodingStandard/Sniffs/PHP/DisallowFqnSniff.php
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,7 @@ private function processString(File $phpcsFile, int $stackPtr, string $namespace

$error = '%s must be imported as %s';
$data = [$name, $alias];
$fix = $phpcsFile->addFixableError($error, $stackPtr, 'Import', $data);
$fix = $this->error($phpcsFile, $error, $stackPtr, 'Import', $data, $alias);

if ($fix) {
return $this->import($type, $name, $alias);
Expand Down Expand Up @@ -460,7 +460,7 @@ private function error(
string $code,
array $data,
string $expected
) : void {
) : bool {
$fix = $phpcsFile->addFixableError($error, $stackPtr, $code, $data);
if ($fix) {
$tokens = $phpcsFile->getTokens();
Expand All @@ -481,6 +481,8 @@ private function error(
}
$phpcsFile->fixer->endChangeset();
}

return $fix;
}

private function import(string $type, string $fqn, string $alias) : array
Expand Down

0 comments on commit eed69d3

Please sign in to comment.