Skip to content

Commit

Permalink
Merge pull request #9 from webimpress/hotfix/disallow-fqn-unused-impo…
Browse files Browse the repository at this point in the history
…rt-conflict

DisallowFqn - resolve conflict with UnusedImport sniff when imported class was removed
  • Loading branch information
michalbundyra committed May 10, 2019
2 parents 129b8a7 + eed69d3 commit d335b87
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 d335b87

Please sign in to comment.