From: Tim Düsterhus Date: Wed, 6 Jan 2016 16:40:34 +0000 (+0100) Subject: Allow namespaced functions in PHPCS X-Git-Tag: 3.0.0_Beta_1~2065 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=75ddf53b752ae932e148b095b98af9c749b43057;p=GitHub%2FWoltLab%2FWCF.git Allow namespaced functions in PHPCS --- diff --git a/CodeSniff/WCF/Sniffs/Namespaces/ClassMustBeImportedSniff.php b/CodeSniff/WCF/Sniffs/Namespaces/ClassMustBeImportedSniff.php index 0e1ba74ca7..bf432696a5 100644 --- a/CodeSniff/WCF/Sniffs/Namespaces/ClassMustBeImportedSniff.php +++ b/CodeSniff/WCF/Sniffs/Namespaces/ClassMustBeImportedSniff.php @@ -60,6 +60,20 @@ 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); + + // 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 + return; + } + } $error = 'Namespaced classes (%s) must be imported with use.'; $data = array( @@ -70,4 +84,4 @@ class WCF_Sniffs_Namespaces_ClassMustBeImportedSniff implements PHP_CodeSniffer_ } } } -} \ No newline at end of file +} diff --git a/wcfsetup/install/files/lib/system/WCF.class.php b/wcfsetup/install/files/lib/system/WCF.class.php index 1c79755274..93f521cd2c 100644 --- a/wcfsetup/install/files/lib/system/WCF.class.php +++ b/wcfsetup/install/files/lib/system/WCF.class.php @@ -242,9 +242,7 @@ class WCF { @header('HTTP/1.1 503 Service Unavailable'); try { - // @codingStandardsIgnoreStart \wcf\functions\exception\printThrowable($e); - // @codingStandardsIgnoreEnd } catch (\Throwable $e2) { echo "
An Exception was thrown while handling an Exception:\n\n";