From 10699119dc252e9ceff5f9a76a7b613adba821d9 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Tim=20D=C3=BCsterhus?= Date: Wed, 13 Apr 2016 20:42:25 +0200 Subject: [PATCH] Fix detection of namespaces function calls --- CodeSniff/WCF/Sniffs/Namespaces/ClassMustBeImportedSniff.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/CodeSniff/WCF/Sniffs/Namespaces/ClassMustBeImportedSniff.php b/CodeSniff/WCF/Sniffs/Namespaces/ClassMustBeImportedSniff.php index 18d2733ff8..1413ad4a18 100644 --- a/CodeSniff/WCF/Sniffs/Namespaces/ClassMustBeImportedSniff.php +++ b/CodeSniff/WCF/Sniffs/Namespaces/ClassMustBeImportedSniff.php @@ -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) { -- 2.20.1