Fix detection of namespaced function calls
authorTim Düsterhus <duesterhus@woltlab.com>
Wed, 6 Jan 2016 17:32:30 +0000 (18:32 +0100)
committerTim Düsterhus <duesterhus@woltlab.com>
Wed, 6 Jan 2016 17:32:30 +0000 (18:32 +0100)
CodeSniff/WCF/Sniffs/Namespaces/ClassMustBeImportedSniff.php

index bf432696a5c28db1a2192a11c051245b50ac641c..18d2733ff829d22096cccabb7cbbe25d76f612bd 100644 (file)
@@ -60,14 +60,13 @@ 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);
+                                       $tNew = $phpcsFile->findPrevious(array(T_NEW), $stackPtr - 1, null, false, null, true);
                                        
                                        // are we trying to create a new object?
                                        if ($tNew === false) {
                                                // no
                                                $parenthesis = $phpcsFile->findNext(T_OPEN_PARENTHESIS, $end);
                                                $nonParenthesis = $phpcsFile->findNext(T_OPEN_PARENTHESIS, $end, null, true);
-                                               
                                                // are we accessing something that's static?
                                                if ($parenthesis !== false && $parenthesis < $nonParenthesis) {
                                                        // no -> this looks like a function call of a namespaced function