From eed69d3325671818bfad1d4966aa1fa8e601bf38 Mon Sep 17 00:00:00 2001 From: webimpress Date: Sun, 5 May 2019 12:50:46 +0100 Subject: [PATCH] DisallowFqn - resolve conflict with UnusedImport sniff when imported class was removed --- .../Sniffs/PHP/DisallowFqnSniff.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/WebimpressCodingStandard/Sniffs/PHP/DisallowFqnSniff.php b/src/WebimpressCodingStandard/Sniffs/PHP/DisallowFqnSniff.php index 55415cd7..87f4feba 100644 --- a/src/WebimpressCodingStandard/Sniffs/PHP/DisallowFqnSniff.php +++ b/src/WebimpressCodingStandard/Sniffs/PHP/DisallowFqnSniff.php @@ -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); @@ -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(); @@ -481,6 +481,8 @@ private function error( } $phpcsFile->fixer->endChangeset(); } + + return $fix; } private function import(string $type, string $fqn, string $alias) : array