Skip to content

Commit 3a3e30b

Browse files
committed
Merge branch 'master' into 3.0
2 parents b21f9f4 + 86dd55a commit 3a3e30b

7 files changed

+154
-9
lines changed

package.xml

+77
Original file line numberDiff line numberDiff line change
@@ -1389,7 +1389,9 @@ http://pear.php.net/dtd/package-2.0.xsd">
13891389
<file baseinstalldir="PHP/CodeSniffer" name="ScopeKeywordSpacingUnitTest.inc" role="test" />
13901390
<file baseinstalldir="PHP/CodeSniffer" name="ScopeKeywordSpacingUnitTest.php" role="test" />
13911391
<file baseinstalldir="PHP/CodeSniffer" name="SemicolonSpacingUnitTest.inc" role="test" />
1392+
<file baseinstalldir="PHP/CodeSniffer" name="SemicolonSpacingUnitTest.inc.fixed" role="test" />
13921393
<file baseinstalldir="PHP/CodeSniffer" name="SemicolonSpacingUnitTest.js" role="test" />
1394+
<file baseinstalldir="PHP/CodeSniffer" name="SemicolonSpacingUnitTest.js.fixed" role="test" />
13931395
<file baseinstalldir="PHP/CodeSniffer" name="SemicolonSpacingUnitTest.php" role="test" />
13941396
<file baseinstalldir="PHP/CodeSniffer" name="SuperfluousWhitespaceUnitTest.1.css" role="test" />
13951397
<file baseinstalldir="PHP/CodeSniffer" name="SuperfluousWhitespaceUnitTest.1.css.fixed" role="test" />
@@ -1507,8 +1509,11 @@ http://pear.php.net/dtd/package-2.0.xsd">
15071509
<install as="CodeSniffer/Core/IsCamelCapsTest.php" name="tests/Core/IsCamelCapsTest.php" />
15081510
<install as="CodeSniffer/Core/ErrorSuppressionTest.php" name="tests/Core/ErrorSuppressionTest.php" />
15091511
<install as="CodeSniffer/Core/File/FindExtendedClassNameTest.php" name="tests/Core/File/FindExtendedClassNameTest.php" />
1512+
<install as="CodeSniffer/Core/File/FindExtendedClassNameTest.inc" name="tests/Core/File/FindExtendedClassNameTest.inc" />
15101513
<install as="CodeSniffer/Core/File/FindImplementedInterfaceNamesTest.php" name="tests/Core/File/FindImplementedInterfaceNamesTest.php" />
1514+
<install as="CodeSniffer/Core/File/FindImplementedInterfaceNamesTest.inc" name="tests/Core/File/FindImplementedInterfaceNamesTest.inc" />
15111515
<install as="CodeSniffer/Core/File/GetMethodParametersTest.php" name="tests/Core/File/GetMethodParametersTest.php" />
1516+
<install as="CodeSniffer/Core/File/GetMethodParametersTest.inc" name="tests/Core/File/GetMethodParametersTest.inc" />
15121517
<install as="CodeSniffer/Standards/AllSniffs.php" name="tests/Standards/AllSniffs.php" />
15131518
<install as="CodeSniffer/Standards/AbstractSniffUnitTest.php" name="tests/Standards/AbstractSniffUnitTest.php" />
15141519
</filelist>
@@ -1526,8 +1531,11 @@ http://pear.php.net/dtd/package-2.0.xsd">
15261531
<install as="CodeSniffer/Core/IsCamelCapsTest.php" name="tests/Core/IsCamelCapsTest.php" />
15271532
<install as="CodeSniffer/Core/ErrorSuppressionTest.php" name="tests/Core/ErrorSuppressionTest.php" />
15281533
<install as="CodeSniffer/Core/File/FindExtendedClassNameTest.php" name="tests/Core/File/FindExtendedClassNameTest.php" />
1534+
<install as="CodeSniffer/Core/File/FindExtendedClassNameTest.inc" name="tests/Core/File/FindExtendedClassNameTest.inc" />
15291535
<install as="CodeSniffer/Core/File/FindImplementedInterfaceNamesTest.php" name="tests/Core/File/FindImplementedInterfaceNamesTest.php" />
1536+
<install as="CodeSniffer/Core/File/FindImplementedInterfaceNamesTest.inc" name="tests/Core/File/FindImplementedInterfaceNamesTest.inc" />
15301537
<install as="CodeSniffer/Core/File/GetMethodParametersTest.php" name="tests/Core/File/GetMethodParametersTest.php" />
1538+
<install as="CodeSniffer/Core/File/GetMethodParametersTest.inc" name="tests/Core/File/GetMethodParametersTest.inc" />
15311539
<install as="CodeSniffer/Standards/AllSniffs.php" name="tests/Standards/AllSniffs.php" />
15321540
<install as="CodeSniffer/Standards/AbstractSniffUnitTest.php" name="tests/Standards/AbstractSniffUnitTest.php" />
15331541
<ignore name="bin/phpcs.bat" />
@@ -1670,6 +1678,75 @@ http://pear.php.net/dtd/package-2.0.xsd">
16701678
-- Hooks for version control systems will no longer be maintained within the PHPCS project
16711679
</notes>
16721680
</release>
1681+
<release>
1682+
<version>
1683+
<release>2.8.0</release>
1684+
<api>2.8.0</api>
1685+
</version>
1686+
<stability>
1687+
<release>stable</release>
1688+
<api>stable</api>
1689+
</stability>
1690+
<date>2017-02-02</date>
1691+
<license uri="https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt">BSD License</license>
1692+
<notes>
1693+
- The Internal.NoCodeFound error is no longer generated for content sourced from STDIN
1694+
-- This should stop some Git hooks generating errors because PHPCS is trying to process the refs passed on STDIN
1695+
- Squiz.Commenting.DocCommentAlignment now checks comments on class properties defined using the VAR keyword
1696+
-- Thanks to Klaus Purer for the patch
1697+
- The getMethodParameters() method now recognises "self" as a valid type hint
1698+
-- The return array now contains a new "content" index containing the raw content of the param definition
1699+
-- Thanks to Juliette Reinders Folmer for the patch
1700+
- The getMethodParameters() method now supports nullable types
1701+
-- The return array now contains a new "nullable_type" index set to true or false for each method param
1702+
-- Thanks to Juliette Reinders Folmer for the patch
1703+
- The getMethodParameters() method now supports closures
1704+
-- Thanks to Juliette Reinders Folmer for the patch
1705+
- Added more guard code for JS files with syntax errors (request #1271 and request #1272)
1706+
- Added more guard code for CSS files with syntax errors (request #1304)
1707+
- PEAR.Commenting.FunctionComment fixers now correctly handle multi-line param comments
1708+
- AbstractVariableSniff now supports anonymous classes
1709+
-- Thanks to Juliette Reinders Folmer for the patch
1710+
- Generic.NamingConventions.ConstructorName and PEAR.NamingConventions.ValidVariable now support anonymous classes
1711+
- Generic.NamingConventions.CamelCapsFunctionName and PEAR.NamingConventions.ValidFunctionName now support anonymous classes
1712+
-- Thanks to Juliette Reinders Folmer for the patch
1713+
- Generic.CodeAnalysis.UnusedFunctionParameter and PEAR.Functions.ValidDefaultValue now support closures
1714+
-- Thanks to Juliette Reinders Folmer for the patch
1715+
- PEAR.NamingConventions.ValidClassName and Squiz.Classes.ValidClassName now support traits
1716+
-- Thanks to Juliette Reinders Folmer for the patch
1717+
- Generic.Functions.FunctionCallArgumentSpacing now supports closures other PHP-provided functions
1718+
-- Thanks to Algirdas Gurevicius for the patch
1719+
- Fixed an error where a nullable type character was detected as an inline then token
1720+
-- A new T_NULLABLE token has been added to represent the ? nullable type character
1721+
-- Thanks to Jaroslav Hanslík for the patch
1722+
- Squiz.WhiteSpace.SemicolonSpacing no longer removes comments while fixing the placement of semicolons
1723+
-- Thanks to Algirdas Gurevicius for the patch
1724+
- Fixed bug #1230 : JS tokeniser incorrectly tokenises bitwise shifts as comparison
1725+
-- Thanks to Ryan McCue for the patch
1726+
- Fixed bug #1237 : Uninitialized string offset in PHP Tokenizer on PHP 5.2
1727+
- Fixed bug #1239 : Warning when static method name is 'default'
1728+
- Fixed bug #1240 : False positive for function names starting with triple underscore
1729+
-- Thanks to Juliette Reinders Folmer for the patch
1730+
- Fixed bug #1245 : SELF is not recognised as T_SELF token in: return new self
1731+
- Fixed bug #1246 : A mix of USE statements with and without braces can cause the tokenizer to mismatch brace tokens
1732+
-- Thanks to Michał Bundyra for the patch
1733+
- Fixed bug #1249 : GitBlame report requires a .git directory
1734+
- Fixed bug #1252 : Squiz.Strings.ConcatenationSpacing fix creates syntax error when joining a number to a string
1735+
- Fixed bug #1253 : Generic.ControlStructures.InlineControlStructure fix creates syntax error fixing if-try/catch
1736+
- Fixed bug #1255 : Inconsistent indentation check results when ELSE on new line
1737+
- Fixed bug #1257 : Double dash in CSS class name can lead to "Named colours are forbidden" false positives
1738+
- Fixed bug #1260 : Syntax errors not being shown when error_prepend_string is set
1739+
-- Thanks to Juliette Reinders Folmer for the patch
1740+
- Fixed bug #1264 : Array return type hint is sometimes detected as T_ARRAY_HINT instead of T_RETURN_TYPE
1741+
-- Thanks to Jaroslav Hanslík for the patch
1742+
- Fixed bug #1265 : ES6 arrow function raises unexpected operator spacing errors
1743+
- Fixed bug #1267 : Fixer incorrectly handles filepaths with repeated dir names
1744+
-- Thanks to Sergey Ovchinnikov for the patch
1745+
- Fixed bug #1276 : Commenting.FunctionComment.InvalidReturnVoid conditional issue with anonymous classes
1746+
- Fixed bug #1277 : Squiz.PHP.DisallowMultipleAssignments.Found error when var assignment is on the same line as an open tag
1747+
- Fixed bug #1284 : Squiz.Arrays.ArrayBracketSpacing.SpaceBeforeBracket false positive match for short list syntax
1748+
</notes>
1749+
</release>
16731750
<release>
16741751
<version>
16751752
<release>2.7.1</release>

src/Standards/Squiz/Sniffs/WhiteSpace/SemicolonSpacingSniff.php

+6-1
Original file line numberDiff line numberDiff line change
@@ -74,10 +74,15 @@ public function process(File $phpcsFile, $stackPtr)
7474
$fix = $phpcsFile->addFixableError($error, $stackPtr, 'Incorrect', $data);
7575
if ($fix === true) {
7676
$phpcsFile->fixer->beginChangeset();
77-
for ($i = ($stackPtr - 1); $i > $nonSpace; $i--) {
77+
$i = ($stackPtr - 1);
78+
while (($tokens[$i]['code'] === T_WHITESPACE) && ($i > $nonSpace)) {
7879
$phpcsFile->fixer->replaceToken($i, '');
80+
$i--;
7981
}
8082

83+
$phpcsFile->fixer->addContent($nonSpace, ';');
84+
$phpcsFile->fixer->replaceToken($stackPtr, '');
85+
8186
$phpcsFile->fixer->endChangeset();
8287
}
8388

src/Standards/Squiz/Tests/WhiteSpace/SemicolonSpacingUnitTest.inc

+7-1
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,10 @@ $test = $this->testThis() /* comment here */;
99
$test = $this->testThis() /* comment here */ ;
1010

1111
$hello ='foo';
12-
;
12+
;
13+
14+
$sum = $a /* + $b */;
15+
$sum = $a // + $b
16+
;
17+
$sum = $a /* + $b
18+
+ $c */ ;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?php
2+
$test = $this->testThis();
3+
$test = $this->testThis();
4+
$test = $this->testThis();
5+
for ($var = 1; $var < 10; $var++) {
6+
echo $var;
7+
}
8+
$test = $this->testThis(); /* comment here */
9+
$test = $this->testThis(); /* comment here */
10+
11+
$hello ='foo';
12+
;
13+
14+
$sum = $a; /* + $b */
15+
$sum = $a; // + $b
16+
17+
$sum = $a; /* + $b
18+
+ $c */

src/Standards/Squiz/Tests/WhiteSpace/SemicolonSpacingUnitTest.js

+9-1
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,12 @@ for (i=0 ; i<3 ; i++) {
1414
}
1515
}
1616
alert('hi');
17-
;
17+
;
18+
19+
var sum = a /* + b */;
20+
21+
var sum = a // +b
22+
;
23+
24+
var sum = a /* +b
25+
+ c */ ;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
var x = {
2+
a: function () {
3+
alert('thats right');
4+
x = (x?a:x);
5+
},
6+
};
7+
8+
id = id.replace(/row\/:;/gi, '');
9+
10+
for (i=0; i<3; i++) {
11+
for (j=0; j<5; j++) {
12+
if (j==x)
13+
break;
14+
}
15+
}
16+
alert('hi');
17+
;
18+
19+
var sum = a; /* + b */
20+
21+
var sum = a; // +b
22+
23+
24+
var sum = a; /* +b
25+
+ c */

src/Standards/Squiz/Tests/WhiteSpace/SemicolonSpacingUnitTest.php

+12-6
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,15 @@ public function getErrorList($testFile='SemicolonSpacingUnitTest.inc')
3030
switch ($testFile) {
3131
case 'SemicolonSpacingUnitTest.inc':
3232
return array(
33-
3 => 1,
34-
4 => 1,
35-
5 => 2,
36-
6 => 1,
37-
8 => 1,
38-
9 => 1,
33+
3 => 1,
34+
4 => 1,
35+
5 => 2,
36+
6 => 1,
37+
8 => 1,
38+
9 => 1,
39+
14 => 1,
40+
16 => 1,
41+
18 => 1,
3942
);
4043
break;
4144
case 'SemicolonSpacingUnitTest.js':
@@ -46,6 +49,9 @@ public function getErrorList($testFile='SemicolonSpacingUnitTest.inc')
4649
10 => 2,
4750
11 => 1,
4851
13 => 1,
52+
19 => 1,
53+
22 => 1,
54+
25 => 1,
4955
);
5056
break;
5157
default:

0 commit comments

Comments
 (0)