Fix detection of namespaces function calls
authorTim Düsterhus <duesterhus@woltlab.com>
Wed, 13 Apr 2016 18:42:25 +0000 (20:42 +0200)
committerTim Düsterhus <duesterhus@woltlab.com>
Wed, 13 Apr 2016 18:43:36 +0000 (20:43 +0200)
CodeSniff/WCF/Sniffs/Namespaces/ClassMustBeImportedSniff.php

index 18d2733ff829d22096cccabb7cbbe25d76f612bd..1413ad4a187c018819910029dce976fb30deb269 100644 (file)
@@ -60,7 +60,9 @@ class WCF_Sniffs_Namespaces_ClassMustBeImportedSniff implements PHP_CodeSniffer_
                                                $newClass = $phpcsFile->findNext(T_STRING, $tClass);
                                                if ($tokens[$newClass]['content'] == $tokens[$end - 1]['content']) return;
                                        }
-                                       $tNew = $phpcsFile->findPrevious(array(T_NEW), $stackPtr - 1, null, false, null, true);
+                                       $pos = $prevNonClassPart - 1;
+                                       while ($tokens[$pos]['code'] === T_WHITESPACE) $pos--;
+                                       $tNew = $tokens[$pos]['code'] === T_NEW;
                                        
                                        // are we trying to create a new object?
                                        if ($tNew === false) {