From 2c9ecb45a1e589f04d583636b1965b9843a323c8 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Tim=20D=C3=BCsterhus?= Date: Wed, 6 Jan 2016 18:32:30 +0100 Subject: [PATCH] Fix detection of namespaced function calls --- CodeSniff/WCF/Sniffs/Namespaces/ClassMustBeImportedSniff.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/CodeSniff/WCF/Sniffs/Namespaces/ClassMustBeImportedSniff.php b/CodeSniff/WCF/Sniffs/Namespaces/ClassMustBeImportedSniff.php index bf432696a5..18d2733ff8 100644 --- a/CodeSniff/WCF/Sniffs/Namespaces/ClassMustBeImportedSniff.php +++ b/CodeSniff/WCF/Sniffs/Namespaces/ClassMustBeImportedSniff.php @@ -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 -- 2.20.1