From: Tim Düsterhus Date: Fri, 4 Jan 2013 15:30:23 +0000 (+0100) Subject: UseDeclarationSniff checks for newlines between use-statements X-Git-Tag: 2.0.0_Beta_1~600 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=abfda06b423bc628e47b0a2e11159866782a5a03;p=GitHub%2FWoltLab%2FWCF.git UseDeclarationSniff checks for newlines between use-statements cf. #987 --- diff --git a/CodeSniff/WCF/Sniffs/Classes/ClassFileNameSniff.php b/CodeSniff/WCF/Sniffs/Classes/ClassFileNameSniff.php index da3ca9dc98..4997382919 100644 --- a/CodeSniff/WCF/Sniffs/Classes/ClassFileNameSniff.php +++ b/CodeSniff/WCF/Sniffs/Classes/ClassFileNameSniff.php @@ -6,7 +6,7 @@ * See: https://github.com/squizlabs/PHP_CodeSniffer/blob/master/CodeSniffer/Standards/Squiz/Sniffs/Classes/ClassFileNameSniff.php * * @author Tim Duesterhus - * @license BSD Licence + * @license GNU Lesser General Public License * @package com.woltlab.wcf * @category Community Framework */ diff --git a/CodeSniff/WCF/Sniffs/ControlStructures/ControlSignatureSniff.php b/CodeSniff/WCF/Sniffs/ControlStructures/ControlSignatureSniff.php index 283c33e22e..a10dbad2af 100644 --- a/CodeSniff/WCF/Sniffs/ControlStructures/ControlSignatureSniff.php +++ b/CodeSniff/WCF/Sniffs/ControlStructures/ControlSignatureSniff.php @@ -10,7 +10,7 @@ if (class_exists('PHP_CodeSniffer_Standards_AbstractPatternSniff', true) === fal * See: https://github.com/squizlabs/PHP_CodeSniffer/blob/master/CodeSniffer/Standards/Squiz/Sniffs/ControlStructures/ControlSignatureSniff.php * * @author Tim Duesterhus - * @license BSD Licence + * @license GNU Lesser General Public License * @package com.woltlab.wcf * @category Community Framework */ diff --git a/CodeSniff/WCF/Sniffs/Namespaces/UseDeclarationSniff.php b/CodeSniff/WCF/Sniffs/Namespaces/UseDeclarationSniff.php index 38c47fcc4c..b5adfc3045 100644 --- a/CodeSniff/WCF/Sniffs/Namespaces/UseDeclarationSniff.php +++ b/CodeSniff/WCF/Sniffs/Namespaces/UseDeclarationSniff.php @@ -62,10 +62,24 @@ class WCF_Sniffs_Namespaces_UseDeclarationSniff implements PHP_CodeSniffer_Sniff } } + $end = $phpcsFile->findNext(T_SEMICOLON, ($stackPtr + 1)); + $next = $phpcsFile->findNext(T_WHITESPACE, ($end + 1), null, true); + if ($tokens[$next]['code'] === T_USE) { + $diff = $tokens[$next]['line'] - $tokens[$stackPtr]['line'] - 1; + if ($diff !== 0) { + $error = 'There must not be any blank lines between use statements; %s found;'; + $data = array($diff); + $phpcsFile->addError($error, $stackPtr, 'SpaceBetweenUse', $data); + } + } + // Only interested in the last USE statement from here onwards. $nextUse = $phpcsFile->findNext(T_USE, ($stackPtr + 1)); if ($nextUse !== false) { - return; + $next = $phpcsFile->findNext(T_WHITESPACE, ($nextUse + 1), null, true); + if ($tokens[$next]['code'] !== T_OPEN_PARENTHESIS) { + return; + } } $end = $phpcsFile->findNext(T_SEMICOLON, ($stackPtr + 1)); @@ -77,7 +91,7 @@ class WCF_Sniffs_Namespaces_UseDeclarationSniff implements PHP_CodeSniffer_Sniff } $error = 'There must be one blank line after the last USE statement; %s found;'; - $data = array($diff); + $data = array($diff); $phpcsFile->addError($error, $stackPtr, 'SpaceAfterLastUse', $data); } diff --git a/CodeSniff/WCF/Sniffs/WhiteSpace/SuperfluousWhitespaceSniff.php b/CodeSniff/WCF/Sniffs/WhiteSpace/SuperfluousWhitespaceSniff.php index 40d5f21054..ec4cf0bd7e 100644 --- a/CodeSniff/WCF/Sniffs/WhiteSpace/SuperfluousWhitespaceSniff.php +++ b/CodeSniff/WCF/Sniffs/WhiteSpace/SuperfluousWhitespaceSniff.php @@ -6,7 +6,7 @@ * See: https://github.com/squizlabs/PHP_CodeSniffer/blob/master/CodeSniffer/Standards/Squiz/Sniffs/WhiteSpace/SuperfluousWhitespaceSniff.php * * @author Tim Duesterhus - * @license BSD Licence + * @license GNU Lesser General Public License * @package com.woltlab.wcf * @category Community Framework */ diff --git a/wcfsetup/install/files/lib/acp/form/StyleAddForm.class.php b/wcfsetup/install/files/lib/acp/form/StyleAddForm.class.php index 1c1f608f7a..3e76477890 100644 --- a/wcfsetup/install/files/lib/acp/form/StyleAddForm.class.php +++ b/wcfsetup/install/files/lib/acp/form/StyleAddForm.class.php @@ -1,7 +1,6 @@