@@ -152,14 +152,22 @@ private function getIgnoredSymbolPattern() {
152152
153153 private function isSymbolDefined (File $ phpcsFile , Symbol $ symbol ): bool {
154154 $ namespace = $ symbol ->getTopLevelNamespace ();
155- // If the symbol's namespace is imported or defined , ignore it
155+ // If the symbol's namespace is imported, ignore it
156156 if ($ namespace ) {
157- return $ this ->isNamespaceImportedOrDefined ($ phpcsFile , $ namespace );
157+ return $ this ->isNamespaceImported ($ phpcsFile , $ namespace );
158158 }
159159 // If the symbol has no namespace and is itself is imported or defined, ignore it
160160 return $ this ->isNamespaceImportedOrDefined ($ phpcsFile , $ symbol ->getName ());
161161 }
162162
163+ private function isNamespaceImported (File $ phpcsFile , string $ namespace ): bool {
164+ return (
165+ $ this ->isClassImported ($ phpcsFile , $ namespace )
166+ || $ this ->isFunctionImported ($ phpcsFile , $ namespace )
167+ || $ this ->isConstImported ($ phpcsFile , $ namespace )
168+ );
169+ }
170+
163171 private function isNamespaceImportedOrDefined (File $ phpcsFile , string $ namespace ): bool {
164172 return (
165173 $ this ->isClassImported ($ phpcsFile , $ namespace )
@@ -281,8 +289,9 @@ private function markSymbolUsed(File $phpcsFile, Symbol $symbol) {
281289
282290 private function getRecordedImportedSymbolMatchingSymbol (File $ phpcsFile , Symbol $ symbol ) {
283291 foreach ($ this ->symbolRecordsByFile [$ phpcsFile ->path ]->importedSymbolRecords as $ record ) {
284- $ this ->debug ("comparing symbol {$ symbol ->getTopLevelNamespace ()} to alias {$ record ->getAlias ()}" );
285- if ($ record ->getAlias () === $ symbol ->getTopLevelNamespace ()) {
292+ $ namespaceOrAlias = $ symbol ->getTopLevelNamespace () ?? $ symbol ->getAlias ();
293+ $ this ->debug ("comparing symbol {$ namespaceOrAlias } to alias {$ record ->getAlias ()}" );
294+ if ($ record ->getAlias () === $ namespaceOrAlias ) {
286295 return $ record ;
287296 }
288297 }
0 commit comments