Skip to content

Commit b770d64

Browse files
committed
Move Predef check after symbol check
1 parent e53300a commit b770d64

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

ImportDetection/Sniffs/Imports/RequireImportsSniff.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,13 @@ public function process(File $phpcsFile, $stackPtr) {
7878
$this->debug('found symbol inside an import: ' . $symbol->getName());
7979
return;
8080
}
81+
// If the symbol's namespace is imported or defined, ignore it
82+
// If the symbol has no namespace and is itself is imported or defined, ignore it
83+
if ($this->isSymbolDefined($phpcsFile, $symbol)) {
84+
$this->debug('found defined symbol: ' . $symbol->getName());
85+
$this->markSymbolUsed($phpcsFile, $symbol);
86+
return;
87+
}
8188
// If the symbol is predefined, ignore it
8289
if ($helper->isPredefinedConstant($phpcsFile, $stackPtr) || $helper->isBuiltInFunction($phpcsFile, $stackPtr)) {
8390
$this->debug('found predefined symbol: ' . $symbol->getName());
@@ -88,13 +95,6 @@ public function process(File $phpcsFile, $stackPtr) {
8895
$this->debug('found typehint symbol: ' . $symbol->getName());
8996
return;
9097
}
91-
// If the symbol's namespace is imported or defined, ignore it
92-
// If the symbol has no namespace and is itself is imported or defined, ignore it
93-
if ($this->isSymbolDefined($phpcsFile, $symbol)) {
94-
$this->debug('found defined symbol: ' . $symbol->getName());
95-
$this->markSymbolUsed($phpcsFile, $symbol);
96-
return;
97-
}
9898
// If the symbol is global, we are in the global namespace, and
9999
// configured to ignore global symbols in the global namespace,
100100
// ignore it

0 commit comments

Comments
 (0)