From e05973af47c51fdcef362bf85ec1ab4e0251221c Mon Sep 17 00:00:00 2001 From: Greg Sherwood Date: Fri, 15 Jul 2016 09:16:13 +1000 Subject: [PATCH] Squiz.WhiteSpace.LanguageConstructSpacing no longer checks for spaces if parenthesis are being used (request #1062) --- CodeSniffer.php | 2 +- .../LanguageConstructSpacingSniff.php | 2 +- ...LanguageConstructSpacingUnitTest.inc.fixed | 32 +++++++++++++++++++ .../LanguageConstructSpacingUnitTest.php | 7 ---- package.xml | 7 ++-- 5 files changed, 39 insertions(+), 11 deletions(-) create mode 100644 CodeSniffer/Standards/Squiz/Tests/WhiteSpace/LanguageConstructSpacingUnitTest.inc.fixed diff --git a/CodeSniffer.php b/CodeSniffer.php index 4a86d9c554..d3ecb66e91 100644 --- a/CodeSniffer.php +++ b/CodeSniffer.php @@ -73,7 +73,7 @@ class PHP_CodeSniffer * * @var string */ - const VERSION = '2.6.3'; + const VERSION = '2.7.0'; /** * Package stability; either stable, beta or alpha. diff --git a/CodeSniffer/Standards/Squiz/Sniffs/WhiteSpace/LanguageConstructSpacingSniff.php b/CodeSniffer/Standards/Squiz/Sniffs/WhiteSpace/LanguageConstructSpacingSniff.php index 5d75015199..d2f852895e 100644 --- a/CodeSniffer/Standards/Squiz/Sniffs/WhiteSpace/LanguageConstructSpacingSniff.php +++ b/CodeSniffer/Standards/Squiz/Sniffs/WhiteSpace/LanguageConstructSpacingSniff.php @@ -82,7 +82,7 @@ public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) $phpcsFile->fixer->replaceToken(($stackPtr + 1), ' '); } } - } else { + } else if ($tokens[($stackPtr + 1)]['code'] !== T_OPEN_PARENTHESIS) { $error = 'Language constructs must be followed by a single space; expected "%s" but found "%s"'; $data = array( $tokens[$stackPtr]['content'].' '.$tokens[($stackPtr + 1)]['content'], diff --git a/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/LanguageConstructSpacingUnitTest.inc.fixed b/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/LanguageConstructSpacingUnitTest.inc.fixed new file mode 100644 index 0000000000..5a0d0852a4 --- /dev/null +++ b/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/LanguageConstructSpacingUnitTest.inc.fixed @@ -0,0 +1,32 @@ + 1, - 4 => 1, 7 => 1, - 8 => 1, 11 => 1, - 12 => 1, 15 => 1, - 16 => 1, 19 => 1, - 20 => 1, 23 => 1, - 24 => 1, 27 => 1, 31 => 1, - 32 => 1, ); }//end getErrorList() diff --git a/package.xml b/package.xml index b5065930e1..e87d54f00c 100644 --- a/package.xml +++ b/package.xml @@ -17,8 +17,8 @@ http://pear.php.net/dtd/package-2.0.xsd"> 2016-07-14 - 2.6.3 - 2.6.3 + 2.7.0 + 2.7.0 stable @@ -26,6 +26,8 @@ http://pear.php.net/dtd/package-2.0.xsd"> BSD 3-Clause License + - Squiz.WhiteSpace.LanguageConstructSpacing no longer checks for spaces if parenthesis are being used (request #1062) + -- Makes this sniff more compatibile with those that check parenthesis spacing of function calls - Fixed bug #1066 : Undefined index: quiet in CLI.php during unit test run with -v command line arg @@ -2137,6 +2139,7 @@ http://pear.php.net/dtd/package-2.0.xsd"> +