Skip to content

Commit 580e888

Browse files
committed
Merge branch 'master' into report-memory-improvements
Conflicts: package.xml
2 parents 1d416db + 6938964 commit 580e888

File tree

16 files changed

+58
-13
lines changed

16 files changed

+58
-13
lines changed

CodeSniffer/CommentParser/AbstractParser.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ private function _parse($comment)
239239
// spaces as well as separate tokens.
240240
$flags = (PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY);
241241
$words = preg_split(
242-
'|(\s+)|',
242+
'|(\s+)|u',
243243
$line.$this->phpcsFile->eolChar,
244244
-1,
245245
$flags

CodeSniffer/Standards/Generic/Sniffs/Debug/JSHintSniff.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* @category PHP
88
* @package PHP_CodeSniffer
99
* @author Greg Sherwood <[email protected]>
10-
* @author Alexander Wei§ <[email protected]>
10+
* @author Alexander Wei§ <[email protected]>
1111
* @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600)
1212
* @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence
1313
* @link http://pear.php.net/package/PHP_CodeSniffer
@@ -21,7 +21,7 @@
2121
* @category PHP
2222
* @package PHP_CodeSniffer
2323
* @author Greg Sherwood <[email protected]>
24-
* @author Alexander Wei§ <[email protected]>
24+
* @author Alexander Wei§ <[email protected]>
2525
* @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600)
2626
* @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence
2727
* @version Release: @package_version@

CodeSniffer/Standards/PEAR/Tests/Commenting/FileCommentUnitTest.inc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ declare(encoding='utf-8');
2222
* @package PHP_CodeSniffer
2323
* @package ADDITIONAL PACKAGE TAG
2424
* @subpackage SUBPACKAGE TAG
25-
* @author Antônio Carlos Venâncio Júnior <[email protected]>
25+
* @author Antônio Carlos Venâncio Júnior <[email protected]>
2626
* @author Greg Sherwood [email protected]
2727
* @author Mr T <[email protected]>
2828
* @author

CodeSniffer/Standards/PEAR/Tests/WhiteSpace/ScopeClosingBraceUnitTest.inc

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,4 +88,12 @@ switch ($httpResponseCode) {
8888
switch($i) {
8989
case 1: {}
9090
}
91-
?>
91+
92+
switch ($httpResponseCode) {
93+
case 100:
94+
case 101:
95+
case 102:
96+
exit;
97+
default:
98+
exit;
99+
}

CodeSniffer/Standards/PEAR/Tests/WhiteSpace/ScopeClosingBraceUnitTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ public function getErrorList()
5050
65 => 1,
5151
85 => 1,
5252
89 => 1,
53+
98 => 1,
5354
);
5455

5556
}//end getErrorList()

CodeSniffer/Standards/Squiz/Sniffs/ControlStructures/ForLoopDeclarationSniff.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,9 @@ public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
9494
$phpcsFile->addError($error, $stackPtr, 'SpacingBeforeFirst');
9595
}
9696

97-
if ($tokens[($firstSemicolon + 1)]['code'] !== T_WHITESPACE) {
97+
if ($tokens[($firstSemicolon + 1)]['code'] !== T_WHITESPACE
98+
&& $tokens[($firstSemicolon + 1)]['code'] !== T_SEMICOLON
99+
) {
98100
$error = 'Expected 1 space after first semicolon of FOR loop; 0 found';
99101
$phpcsFile->addError($error, $stackPtr, 'NoSpaceAfterFirst');
100102
} else {
@@ -109,7 +111,9 @@ public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
109111
$secondSemicolon = $phpcsFile->findNext(T_SEMICOLON, ($firstSemicolon + 1));
110112

111113
if ($secondSemicolon !== false) {
112-
if ($tokens[($secondSemicolon - 1)]['code'] === T_WHITESPACE) {
114+
if ($tokens[($secondSemicolon - 1)]['code'] === T_WHITESPACE
115+
&& $tokens[($firstSemicolon + 1)]['code'] !== T_SEMICOLON
116+
) {
113117
$error = 'Space found before second semicolon of FOR loop';
114118
$phpcsFile->addError($error, $stackPtr, 'SpacingBeforeSecond');
115119
}

CodeSniffer/Standards/Squiz/Sniffs/WhiteSpace/OperatorSpacingSniff.php

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,8 @@ public function register()
6767
* Processes this sniff, when one of its tokens is encountered.
6868
*
6969
* @param PHP_CodeSniffer_File $phpcsFile The current file being checked.
70-
* @param int $stackPtr The position of the current token in the
71-
* stack passed in $tokens.
70+
* @param int $stackPtr The position of the current token in
71+
* the stack passed in $tokens.
7272
*
7373
* @return void
7474
*/
@@ -96,11 +96,22 @@ public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
9696

9797
if ($tokens[$stackPtr]['code'] === T_EQUAL) {
9898
// Skip for '=&' case.
99-
if (isset($tokens[($stackPtr + 1)]) === true && $tokens[($stackPtr + 1)]['code'] === T_BITWISE_AND) {
99+
if (isset($tokens[($stackPtr + 1)]) === true
100+
&& $tokens[($stackPtr + 1)]['code'] === T_BITWISE_AND
101+
) {
100102
return;
101103
}
102104
}
103105

106+
// Skip short ternary such as: $foo = $bar ?: true;
107+
if (($tokens[$stackPtr]['code'] == T_INLINE_THEN
108+
&& $tokens[$stackPtr + 1]['code'] == T_INLINE_ELSE)
109+
|| ($tokens[$stackPtr - 1]['code'] == T_INLINE_THEN
110+
&& $tokens[$stackPtr]['code'] == T_INLINE_ELSE)
111+
) {
112+
return;
113+
}
114+
104115
if ($tokens[$stackPtr]['code'] === T_BITWISE_AND) {
105116
// If it's not a reference, then we expect one space either side of the
106117
// bitwise operator.

CodeSniffer/Standards/Squiz/Tests/Commenting/FileCommentUnitTest.inc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
* @package SquizCMS
2222
* @package ADDITIONAL PACKAGE TAG
2323
* @subpackage not_camelcased
24-
* @author Antônio Carlos Venâncio Júnior <[email protected]>
24+
* @author Antônio Carlos Venâncio Júnior <[email protected]>
2525
* @author
2626
* @copyright 1997~1994 The PHP Group
2727
* @license http://www.php.net/license/3_0.txt

CodeSniffer/Standards/Squiz/Tests/Commenting/FileCommentUnitTest.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
* @package SquizCMS
2222
* @package ADDITIONAL PACKAGE TAG
2323
* @subpackage not_camelcased
24-
* @author Antônio Carlos Venâncio Júnior <[email protected]>
24+
* @author Antônio Carlos Venâncio Júnior <[email protected]>
2525
* @author
2626
* @copyright 1997~1994 The PHP Group
2727
* @license http://www.php.net/license/3_0.txt

CodeSniffer/Standards/Squiz/Tests/ControlStructures/ForLoopDeclarationUnitTest.inc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,9 @@ for ($i = 0; $i < 10;) {
2727
for ($i = 0; $i < 10; ) {
2828
}
2929

30+
for ($i = 0; ; $i++) {
31+
}
32+
for ($i = 0;; $i++) {
33+
}
34+
3035
?>

CodeSniffer/Standards/Squiz/Tests/ControlStructures/ForLoopDeclarationUnitTest.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,3 +32,8 @@ for (var i = 0; i < 10;) {
3232
}
3333
for (var i = 0; i < 10; ) {
3434
}
35+
36+
for (var i = 0; ; i++) {
37+
}
38+
for (var i = 0;; i++) {
39+
}

CodeSniffer/Standards/Squiz/Tests/ControlStructures/ForLoopDeclarationUnitTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ public function getErrorList($testFile='ForLoopDeclarationUnitTest.inc')
5353
17 => 2,
5454
21 => 6,
5555
27 => 1,
56+
30 => 1,
5657
);
5758
break;
5859
case 'ForLoopDeclarationUnitTest.js':
@@ -63,6 +64,7 @@ public function getErrorList($testFile='ForLoopDeclarationUnitTest.inc')
6364
15 => 2,
6465
19 => 6,
6566
33 => 1,
67+
36 => 1,
6668
);
6769
break;
6870
default:

CodeSniffer/Standards/Squiz/Tests/WhiteSpace/OperatorSpacingUnitTest.inc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ function foo($boo = -1) {}
106106
$foo = array('boo' => -1);
107107
$x = $test ? -1 : 1;
108108
$y = $test ? 1 : -1;
109+
$z = $test ?: false;
109110

110111
$closureWithDefaultParamter = function (array $testArray=array()) {};
111112

CodeSniffer/Standards/Squiz/Tests/WhiteSpace/OperatorSpacingUnitTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ public function getErrorList($testFile='OperatorSpacingUnitTest.inc')
9292
88 => 5,
9393
90 => 4,
9494
91 => 5,
95-
127 => 4,
95+
128 => 4,
9696
);
9797
break;
9898
case 'OperatorSpacingUnitTest.js':

CodeSniffer/Tokenizers/PHP.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,7 @@ class PHP_CodeSniffer_Tokenizers_PHP
183183
T_RETURN,
184184
T_CONTINUE,
185185
T_THROW,
186+
T_EXIT,
186187
),
187188
'strict' => true,
188189
'shared' => true,
@@ -199,6 +200,7 @@ class PHP_CodeSniffer_Tokenizers_PHP
199200
T_RETURN,
200201
T_CONTINUE,
201202
T_THROW,
203+
T_EXIT,
202204
),
203205
'strict' => true,
204206
'shared' => true,

package.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,15 @@ http://pear.php.net/dtd/package-2.0.xsd">
3434
-- It still reports errors where constants are defined
3535
- Individual messages can now be excluded in ruleset.xml files using the exclude tag (request #20091)
3636
-- Setting message severity to 0 continues to be supported
37+
- Squiz OperatorSpacingSniff no longer throws errors for the ?: short ternary operator
38+
-- Thanks to Antoine Musso for the patch
39+
- Comment parser now supports non-English characters when splitting comment lines into words
40+
-- Thanks to Nik Sun for the patch
41+
- Exit statements are now recognised as valid closers for CASE and DEFAULT blocks
3742
- Fixed bug #20093 : Bug with ternary operator token
3843
- Fixed bug #20097 : CLI.php throws error in php 5.2
3944
- Fixed bug #20100 : incorrect Function mysql() has been deprecated report
45+
- Fixed bug #20123 : PSR2 complains about an empty second statement in for-loop
4046
</notes>
4147
<contents>
4248
<dir name="/">

0 commit comments

Comments
 (0)