Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DisallowFqn - resolve conflict with UnusedImport sniff when imported class was removed #9

Merged
merged 1 commit into from
May 11, 2019
Merged
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
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