Skip to content

Commit

Permalink
Merge branch 'master' into 3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
gsherwood committed Feb 2, 2017
2 parents b21f9f4 + 86dd55a commit 3a3e30b
Show file tree
Hide file tree
Showing 7 changed files with 154 additions and 9 deletions.
77 changes: 77 additions & 0 deletions package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1389,7 +1389,9 @@ http://pear.php.net/dtd/package-2.0.xsd">
<file baseinstalldir="PHP/CodeSniffer" name="ScopeKeywordSpacingUnitTest.inc" role="test" />
<file baseinstalldir="PHP/CodeSniffer" name="ScopeKeywordSpacingUnitTest.php" role="test" />
<file baseinstalldir="PHP/CodeSniffer" name="SemicolonSpacingUnitTest.inc" role="test" />
<file baseinstalldir="PHP/CodeSniffer" name="SemicolonSpacingUnitTest.inc.fixed" role="test" />
<file baseinstalldir="PHP/CodeSniffer" name="SemicolonSpacingUnitTest.js" role="test" />
<file baseinstalldir="PHP/CodeSniffer" name="SemicolonSpacingUnitTest.js.fixed" role="test" />
<file baseinstalldir="PHP/CodeSniffer" name="SemicolonSpacingUnitTest.php" role="test" />
<file baseinstalldir="PHP/CodeSniffer" name="SuperfluousWhitespaceUnitTest.1.css" role="test" />
<file baseinstalldir="PHP/CodeSniffer" name="SuperfluousWhitespaceUnitTest.1.css.fixed" role="test" />
Expand Down Expand Up @@ -1507,8 +1509,11 @@ http://pear.php.net/dtd/package-2.0.xsd">
<install as="CodeSniffer/Core/IsCamelCapsTest.php" name="tests/Core/IsCamelCapsTest.php" />
<install as="CodeSniffer/Core/ErrorSuppressionTest.php" name="tests/Core/ErrorSuppressionTest.php" />
<install as="CodeSniffer/Core/File/FindExtendedClassNameTest.php" name="tests/Core/File/FindExtendedClassNameTest.php" />
<install as="CodeSniffer/Core/File/FindExtendedClassNameTest.inc" name="tests/Core/File/FindExtendedClassNameTest.inc" />
<install as="CodeSniffer/Core/File/FindImplementedInterfaceNamesTest.php" name="tests/Core/File/FindImplementedInterfaceNamesTest.php" />
<install as="CodeSniffer/Core/File/FindImplementedInterfaceNamesTest.inc" name="tests/Core/File/FindImplementedInterfaceNamesTest.inc" />
<install as="CodeSniffer/Core/File/GetMethodParametersTest.php" name="tests/Core/File/GetMethodParametersTest.php" />
<install as="CodeSniffer/Core/File/GetMethodParametersTest.inc" name="tests/Core/File/GetMethodParametersTest.inc" />
<install as="CodeSniffer/Standards/AllSniffs.php" name="tests/Standards/AllSniffs.php" />
<install as="CodeSniffer/Standards/AbstractSniffUnitTest.php" name="tests/Standards/AbstractSniffUnitTest.php" />
</filelist>
Expand All @@ -1526,8 +1531,11 @@ http://pear.php.net/dtd/package-2.0.xsd">
<install as="CodeSniffer/Core/IsCamelCapsTest.php" name="tests/Core/IsCamelCapsTest.php" />
<install as="CodeSniffer/Core/ErrorSuppressionTest.php" name="tests/Core/ErrorSuppressionTest.php" />
<install as="CodeSniffer/Core/File/FindExtendedClassNameTest.php" name="tests/Core/File/FindExtendedClassNameTest.php" />
<install as="CodeSniffer/Core/File/FindExtendedClassNameTest.inc" name="tests/Core/File/FindExtendedClassNameTest.inc" />
<install as="CodeSniffer/Core/File/FindImplementedInterfaceNamesTest.php" name="tests/Core/File/FindImplementedInterfaceNamesTest.php" />
<install as="CodeSniffer/Core/File/FindImplementedInterfaceNamesTest.inc" name="tests/Core/File/FindImplementedInterfaceNamesTest.inc" />
<install as="CodeSniffer/Core/File/GetMethodParametersTest.php" name="tests/Core/File/GetMethodParametersTest.php" />
<install as="CodeSniffer/Core/File/GetMethodParametersTest.inc" name="tests/Core/File/GetMethodParametersTest.inc" />
<install as="CodeSniffer/Standards/AllSniffs.php" name="tests/Standards/AllSniffs.php" />
<install as="CodeSniffer/Standards/AbstractSniffUnitTest.php" name="tests/Standards/AbstractSniffUnitTest.php" />
<ignore name="bin/phpcs.bat" />
Expand Down Expand Up @@ -1670,6 +1678,75 @@ http://pear.php.net/dtd/package-2.0.xsd">
-- Hooks for version control systems will no longer be maintained within the PHPCS project
</notes>
</release>
<release>
<version>
<release>2.8.0</release>
<api>2.8.0</api>
</version>
<stability>
<release>stable</release>
<api>stable</api>
</stability>
<date>2017-02-02</date>
<license uri="https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt">BSD License</license>
<notes>
- The Internal.NoCodeFound error is no longer generated for content sourced from STDIN
-- This should stop some Git hooks generating errors because PHPCS is trying to process the refs passed on STDIN
- Squiz.Commenting.DocCommentAlignment now checks comments on class properties defined using the VAR keyword
-- Thanks to Klaus Purer for the patch
- The getMethodParameters() method now recognises "self" as a valid type hint
-- The return array now contains a new "content" index containing the raw content of the param definition
-- Thanks to Juliette Reinders Folmer for the patch
- The getMethodParameters() method now supports nullable types
-- The return array now contains a new "nullable_type" index set to true or false for each method param
-- Thanks to Juliette Reinders Folmer for the patch
- The getMethodParameters() method now supports closures
-- Thanks to Juliette Reinders Folmer for the patch
- Added more guard code for JS files with syntax errors (request #1271 and request #1272)
- Added more guard code for CSS files with syntax errors (request #1304)
- PEAR.Commenting.FunctionComment fixers now correctly handle multi-line param comments
- AbstractVariableSniff now supports anonymous classes
-- Thanks to Juliette Reinders Folmer for the patch
- Generic.NamingConventions.ConstructorName and PEAR.NamingConventions.ValidVariable now support anonymous classes
- Generic.NamingConventions.CamelCapsFunctionName and PEAR.NamingConventions.ValidFunctionName now support anonymous classes
-- Thanks to Juliette Reinders Folmer for the patch
- Generic.CodeAnalysis.UnusedFunctionParameter and PEAR.Functions.ValidDefaultValue now support closures
-- Thanks to Juliette Reinders Folmer for the patch
- PEAR.NamingConventions.ValidClassName and Squiz.Classes.ValidClassName now support traits
-- Thanks to Juliette Reinders Folmer for the patch
- Generic.Functions.FunctionCallArgumentSpacing now supports closures other PHP-provided functions
-- Thanks to Algirdas Gurevicius for the patch
- Fixed an error where a nullable type character was detected as an inline then token
-- A new T_NULLABLE token has been added to represent the ? nullable type character
-- Thanks to Jaroslav Hanslík for the patch
- Squiz.WhiteSpace.SemicolonSpacing no longer removes comments while fixing the placement of semicolons
-- Thanks to Algirdas Gurevicius for the patch
- Fixed bug #1230 : JS tokeniser incorrectly tokenises bitwise shifts as comparison
-- Thanks to Ryan McCue for the patch
- Fixed bug #1237 : Uninitialized string offset in PHP Tokenizer on PHP 5.2
- Fixed bug #1239 : Warning when static method name is 'default'
- Fixed bug #1240 : False positive for function names starting with triple underscore
-- Thanks to Juliette Reinders Folmer for the patch
- Fixed bug #1245 : SELF is not recognised as T_SELF token in: return new self
- Fixed bug #1246 : A mix of USE statements with and without braces can cause the tokenizer to mismatch brace tokens
-- Thanks to Michał Bundyra for the patch
- Fixed bug #1249 : GitBlame report requires a .git directory
- Fixed bug #1252 : Squiz.Strings.ConcatenationSpacing fix creates syntax error when joining a number to a string
- Fixed bug #1253 : Generic.ControlStructures.InlineControlStructure fix creates syntax error fixing if-try/catch
- Fixed bug #1255 : Inconsistent indentation check results when ELSE on new line
- Fixed bug #1257 : Double dash in CSS class name can lead to "Named colours are forbidden" false positives
- Fixed bug #1260 : Syntax errors not being shown when error_prepend_string is set
-- Thanks to Juliette Reinders Folmer for the patch
- Fixed bug #1264 : Array return type hint is sometimes detected as T_ARRAY_HINT instead of T_RETURN_TYPE
-- Thanks to Jaroslav Hanslík for the patch
- Fixed bug #1265 : ES6 arrow function raises unexpected operator spacing errors
- Fixed bug #1267 : Fixer incorrectly handles filepaths with repeated dir names
-- Thanks to Sergey Ovchinnikov for the patch
- Fixed bug #1276 : Commenting.FunctionComment.InvalidReturnVoid conditional issue with anonymous classes
- Fixed bug #1277 : Squiz.PHP.DisallowMultipleAssignments.Found error when var assignment is on the same line as an open tag
- Fixed bug #1284 : Squiz.Arrays.ArrayBracketSpacing.SpaceBeforeBracket false positive match for short list syntax
</notes>
</release>
<release>
<version>
<release>2.7.1</release>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,15 @@ public function process(File $phpcsFile, $stackPtr)
$fix = $phpcsFile->addFixableError($error, $stackPtr, 'Incorrect', $data);
if ($fix === true) {
$phpcsFile->fixer->beginChangeset();
for ($i = ($stackPtr - 1); $i > $nonSpace; $i--) {
$i = ($stackPtr - 1);
while (($tokens[$i]['code'] === T_WHITESPACE) && ($i > $nonSpace)) {
$phpcsFile->fixer->replaceToken($i, '');
$i--;
}

$phpcsFile->fixer->addContent($nonSpace, ';');
$phpcsFile->fixer->replaceToken($stackPtr, '');

$phpcsFile->fixer->endChangeset();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,10 @@ $test = $this->testThis() /* comment here */;
$test = $this->testThis() /* comment here */ ;

$hello ='foo';
;
;

$sum = $a /* + $b */;
$sum = $a // + $b
;
$sum = $a /* + $b
+ $c */ ;
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php
$test = $this->testThis();
$test = $this->testThis();
$test = $this->testThis();
for ($var = 1; $var < 10; $var++) {
echo $var;
}
$test = $this->testThis(); /* comment here */
$test = $this->testThis(); /* comment here */

$hello ='foo';
;

$sum = $a; /* + $b */
$sum = $a; // + $b

$sum = $a; /* + $b
+ $c */
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,12 @@ for (i=0 ; i<3 ; i++) {
}
}
alert('hi');
;
;

var sum = a /* + b */;

var sum = a // +b
;

var sum = a /* +b
+ c */ ;
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
var x = {
a: function () {
alert('thats right');
x = (x?a:x);
},
};

id = id.replace(/row\/:;/gi, '');

for (i=0; i<3; i++) {
for (j=0; j<5; j++) {
if (j==x)
break;
}
}
alert('hi');
;

var sum = a; /* + b */

var sum = a; // +b


var sum = a; /* +b
+ c */
18 changes: 12 additions & 6 deletions src/Standards/Squiz/Tests/WhiteSpace/SemicolonSpacingUnitTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,15 @@ public function getErrorList($testFile='SemicolonSpacingUnitTest.inc')
switch ($testFile) {
case 'SemicolonSpacingUnitTest.inc':
return array(
3 => 1,
4 => 1,
5 => 2,
6 => 1,
8 => 1,
9 => 1,
3 => 1,
4 => 1,
5 => 2,
6 => 1,
8 => 1,
9 => 1,
14 => 1,
16 => 1,
18 => 1,
);
break;
case 'SemicolonSpacingUnitTest.js':
Expand All @@ -46,6 +49,9 @@ public function getErrorList($testFile='SemicolonSpacingUnitTest.inc')
10 => 2,
11 => 1,
13 => 1,
19 => 1,
22 => 1,
25 => 1,
);
break;
default:
Expand Down

0 comments on commit 3a3e30b

Please sign in to comment.