Skip to content

Commit e6592be

Browse files
committed
Merge remote-tracking branch 'upstream/master'
2 parents 8be584e + 2ecd8dc commit e6592be

File tree

5 files changed

+112
-28
lines changed

5 files changed

+112
-28
lines changed

package.xml

Lines changed: 68 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ http://pear.php.net/dtd/package-2.0.xsd">
1414
<email>gsherwood@squiz.net</email>
1515
<active>yes</active>
1616
</lead>
17-
<date>2019-10-28</date>
18-
<time>15:31:00</time>
17+
<date>2019-12-04</date>
18+
<time>15:42:00</time>
1919
<version>
2020
<release>3.5.3</release>
2121
<api>3.5.3</api>
@@ -2025,6 +2025,72 @@ http://pear.php.net/dtd/package-2.0.xsd">
20252025
</filelist>
20262026
</phprelease>
20272027
<changelog>
2028+
<release>
2029+
<version>
2030+
<release>3.5.3</release>
2031+
<api>3.5.3</api>
2032+
</version>
2033+
<stability>
2034+
<release>stable</release>
2035+
<api>stable</api>
2036+
</stability>
2037+
<date>2019-12-04</date>
2038+
<license uri="https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt">BSD License</license>
2039+
<notes>
2040+
- The PHP 7.4 T_FN token has been made available for older versions
2041+
-- T_FN represents the fn string used for arrow functions
2042+
-- The double arrow becomes the scope opener, and uses a new T_FN_ARROW token type
2043+
-- The token after the statement (normally a semicolon) becomes the scope closer
2044+
-- The token is also associated with the opening and closing parenthesis of the statement
2045+
-- Any functions named "fn" will cause have a T_FN token for the function name, but have no scope information
2046+
-- Thanks to Michał Bundyra for the help with this change
2047+
- PHP 7.4 numeric separators are now tokenized in the same way when using older PHP versions
2048+
-- Previously, a number like 1_000 would tokenize as T_LNUMBER (1), T_STRING (_000)
2049+
-- Now, the number tokenizes as T_LNUMBER (1_000)
2050+
-- Sniff developers should consider how numbers with underscores impact their custom sniffs
2051+
- The PHPCS file cache now takes file permissions into account
2052+
-- The cache is now invalidated for a file when its permissions are changed
2053+
- File::getMethodParameters() now supports arrow functions
2054+
- File::getMethodProperties() now supports arrow functions
2055+
- Added Fixer::changeCodeBlockIndent() to change the indent of a code block while auto-fixing
2056+
-- Can be used to either increase or decrease the indent
2057+
-- Useful when moving the start position of something like a closure, where you want the content to also move
2058+
- Added Generic.Files.ExecutableFile sniff
2059+
-- Ensures that files are not executable
2060+
-- Thanks to Matthew Peveler for the contribution
2061+
- Generic.CodeAnalysis.EmptyPhpStatement now reports unnecessary semicolons after control structure closing braces
2062+
-- Thanks to Vincent Langlet for the patch
2063+
- Generic.PHP.LowerCaseKeyword now enforces that the "fn" keyword is lowercase
2064+
-- Thanks to Michał Bundyra for the patch
2065+
- Generic.WhiteSpace.ScopeIndent now supports static arrow functions
2066+
- PEAR.Functions.FunctionCallSignature now adjusts the indent of function argument contents during auto-fixing
2067+
-- Previously, only the first line of an argument was changed, leading to inconsistent indents
2068+
-- This change also applies to PSR2.Methods.FunctionCallSignature
2069+
- PSR2.ControlStructures.ControlStructureSpacing now checks whitespace before the closing parenthesis of multi-line control structures
2070+
-- Previously, it incorrectly applied the whitespace check for single-line definitions only
2071+
- PSR12.Functions.ReturnTypeDeclaration now checks the return type of arrow functions
2072+
-- Thanks to Michał Bundyra for the patch
2073+
- PSR12.Traits.UseDeclaration now ensures all trait import statements are grouped together
2074+
-- Previously, the trait import section of the class ended when the first non-import statement was found
2075+
-- Checking now continues throughout the class to ensure all statements are grouped together
2076+
-- This also ensures that empty lines are not requested after an import statement that isn't the last one
2077+
- Squiz.Functions.LowercaseFunctionKeywords now enforces that the "fn" keyword is lowercase
2078+
-- Thanks to Michał Bundyra for the patch
2079+
- Fixed bug #2586 : Generic.WhiteSpace.ScopeIndent false positives when indenting open tags at a non tab-stop
2080+
- Fixed bug #2638 : Squiz.CSS.DuplicateClassDefinitionSniff sees comments as part of the class name
2081+
-- Thanks to Raphael Horber for the patch
2082+
- Fixed bug #2640 : Squiz.WhiteSpace.OperatorSpacing false positives for some negation operators
2083+
-- Thanks to Jakub Chábek and Juliette Reinders Folmer for the patch
2084+
- Fixed bug #2674 : Squiz.Functions.FunctionDeclarationArgumentSpacing prints wrong argument name in error message
2085+
- Fixed bug #2676 : PSR12.Files.FileHeader locks up when file ends with multiple inline comments
2086+
- Fixed bug #2678 : PSR12.Classes.AnonClassDeclaration incorrectly enforcing that closing brace be on a line by itself
2087+
- Fixed bug #2685 : File::getMethodParameters() setting typeHintEndToken for vars with no type hint
2088+
-- Thanks to Juliette Reinders Folmer for the patch
2089+
- Fixed bug #2694 : AbstractArraySniff produces invalid indices when using ternary operator
2090+
-- Thanks to Michał Bundyra for the patch
2091+
- Fixed bug #2702 : Generic.WhiteSpace.ScopeIndent false positive when using ternary operator with short arrays
2092+
</notes>
2093+
</release>
20282094
<release>
20292095
<version>
20302096
<release>3.5.2</release>

src/Filters/Filter.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,8 @@ public function accept()
132132
*/
133133
public function getChildren()
134134
{
135-
$children = new static(
135+
$filterClass = get_called_class();
136+
$children = new $filterClass(
136137
new \RecursiveDirectoryIterator($this->current(), (\RecursiveDirectoryIterator::SKIP_DOTS | \FilesystemIterator::FOLLOW_SYMLINKS)),
137138
$this->basedir,
138139
$this->config,

src/Standards/Generic/Tests/Files/ExecutableFileUnitTest.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,20 @@ class ExecutableFileUnitTest extends AbstractSniffUnitTest
1515
{
1616

1717

18+
/**
19+
* Should this test be skipped for some reason.
20+
*
21+
* @return void
22+
*/
23+
protected function shouldSkipTest()
24+
{
25+
// PEAR doesn't preserve the executable flag, so skip
26+
// tests when running in a PEAR install.
27+
return $GLOBALS['PHP_CODESNIFFER_PEAR'];
28+
29+
}//end shouldSkipTest()
30+
31+
1832
/**
1933
* Returns the lines where errors should occur.
2034
*

src/Util/Tokens.php

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ final class Tokens
145145
/**
146146
* The token weightings.
147147
*
148-
* @var array<int, int>
148+
* @var array<int|string, int>
149149
*/
150150
public static $weightings = [
151151
T_CLASS => 1000,
@@ -226,7 +226,7 @@ final class Tokens
226226
/**
227227
* Tokens that represent assignments.
228228
*
229-
* @var array<int, int>
229+
* @var array<int|string, int|string>
230230
*/
231231
public static $assignmentTokens = [
232232
T_EQUAL => T_EQUAL,
@@ -250,7 +250,7 @@ final class Tokens
250250
/**
251251
* Tokens that represent equality comparisons.
252252
*
253-
* @var array<int, int>
253+
* @var array<int|string, int|string>
254254
*/
255255
public static $equalityTokens = [
256256
T_IS_EQUAL => T_IS_EQUAL,
@@ -264,7 +264,7 @@ final class Tokens
264264
/**
265265
* Tokens that represent comparison operator.
266266
*
267-
* @var array<int, int>
267+
* @var array<int|string, int|string>
268268
*/
269269
public static $comparisonTokens = [
270270
T_IS_EQUAL => T_IS_EQUAL,
@@ -282,7 +282,7 @@ final class Tokens
282282
/**
283283
* Tokens that represent arithmetic operators.
284284
*
285-
* @var array<int, int>
285+
* @var array<int|string, int|string>
286286
*/
287287
public static $arithmeticTokens = [
288288
T_PLUS => T_PLUS,
@@ -296,7 +296,7 @@ final class Tokens
296296
/**
297297
* Tokens that perform operations.
298298
*
299-
* @var array<int, int>
299+
* @var array<int|string, int|string>
300300
*/
301301
public static $operators = [
302302
T_MINUS => T_MINUS,
@@ -317,7 +317,7 @@ final class Tokens
317317
/**
318318
* Tokens that perform boolean operations.
319319
*
320-
* @var array<int, int>
320+
* @var array<int|string, int|string>
321321
*/
322322
public static $booleanOperators = [
323323
T_BOOLEAN_AND => T_BOOLEAN_AND,
@@ -330,7 +330,7 @@ final class Tokens
330330
/**
331331
* Tokens that represent casting.
332332
*
333-
* @var array<int, int>
333+
* @var array<int|string, int|string>
334334
*/
335335
public static $castTokens = [
336336
T_INT_CAST => T_INT_CAST,
@@ -346,7 +346,7 @@ final class Tokens
346346
/**
347347
* Token types that open parenthesis.
348348
*
349-
* @var array<int, int>
349+
* @var array<int|string, int|string>
350350
*/
351351
public static $parenthesisOpeners = [
352352
T_ARRAY => T_ARRAY,
@@ -367,7 +367,7 @@ final class Tokens
367367
/**
368368
* Tokens that are allowed to open scopes.
369369
*
370-
* @var array<int, int>
370+
* @var array<int|string, int|string>
371371
*/
372372
public static $scopeOpeners = [
373373
T_CLASS => T_CLASS,
@@ -399,7 +399,7 @@ final class Tokens
399399
/**
400400
* Tokens that represent scope modifiers.
401401
*
402-
* @var array<int, int>
402+
* @var array<int|string, int|string>
403403
*/
404404
public static $scopeModifiers = [
405405
T_PRIVATE => T_PRIVATE,
@@ -410,7 +410,7 @@ final class Tokens
410410
/**
411411
* Tokens that can prefix a method name
412412
*
413-
* @var array<int, int>
413+
* @var array<int|string, int|string>
414414
*/
415415
public static $methodPrefixes = [
416416
T_PRIVATE => T_PRIVATE,
@@ -424,7 +424,7 @@ final class Tokens
424424
/**
425425
* Tokens that open code blocks.
426426
*
427-
* @var array<int, int>
427+
* @var array<int|string, int|string>
428428
*/
429429
public static $blockOpeners = [
430430
T_OPEN_CURLY_BRACKET => T_OPEN_CURLY_BRACKET,
@@ -436,7 +436,7 @@ final class Tokens
436436
/**
437437
* Tokens that don't represent code.
438438
*
439-
* @var array<int, int>
439+
* @var array<int|string, int|string>
440440
*/
441441
public static $emptyTokens = [
442442
T_WHITESPACE => T_WHITESPACE,
@@ -458,7 +458,7 @@ final class Tokens
458458
/**
459459
* Tokens that are comments.
460460
*
461-
* @var array<int, int>
461+
* @var array<int|string, int|string>
462462
*/
463463
public static $commentTokens = [
464464
T_COMMENT => T_COMMENT,
@@ -479,7 +479,7 @@ final class Tokens
479479
/**
480480
* Tokens that are comments containing PHPCS instructions.
481481
*
482-
* @var array<int, int>
482+
* @var array<int|string, int|string>
483483
*/
484484
public static $phpcsCommentTokens = [
485485
T_PHPCS_ENABLE => T_PHPCS_ENABLE,
@@ -494,7 +494,7 @@ final class Tokens
494494
*
495495
* Note that T_STRINGS are NOT represented in this list.
496496
*
497-
* @var array<int, int>
497+
* @var array<int|string, int|string>
498498
*/
499499
public static $stringTokens = [
500500
T_CONSTANT_ENCAPSED_STRING => T_CONSTANT_ENCAPSED_STRING,
@@ -504,7 +504,7 @@ final class Tokens
504504
/**
505505
* Tokens that represent text strings.
506506
*
507-
* @var array<int, int>
507+
* @var array<int|string, int|string>
508508
*/
509509
public static $textStringTokens = [
510510
T_CONSTANT_ENCAPSED_STRING => T_CONSTANT_ENCAPSED_STRING,
@@ -517,7 +517,7 @@ final class Tokens
517517
/**
518518
* Tokens that represent brackets and parenthesis.
519519
*
520-
* @var array<int, int>
520+
* @var array<int|string, int|string>
521521
*/
522522
public static $bracketTokens = [
523523
T_OPEN_CURLY_BRACKET => T_OPEN_CURLY_BRACKET,
@@ -531,7 +531,7 @@ final class Tokens
531531
/**
532532
* Tokens that include files.
533533
*
534-
* @var array<int, int>
534+
* @var array<int|string, int|string>
535535
*/
536536
public static $includeTokens = [
537537
T_REQUIRE_ONCE => T_REQUIRE_ONCE,
@@ -543,7 +543,7 @@ final class Tokens
543543
/**
544544
* Tokens that make up a heredoc string.
545545
*
546-
* @var array<int, int>
546+
* @var array<int|string, int|string>
547547
*/
548548
public static $heredocTokens = [
549549
T_START_HEREDOC => T_START_HEREDOC,
@@ -560,7 +560,7 @@ final class Tokens
560560
* Mostly, these are just strings. But PHP tokenizes some language
561561
* constructs and functions using their own tokens.
562562
*
563-
* @var array<int, int>
563+
* @var array<int|string, int|string>
564564
*/
565565
public static $functionNameTokens = [
566566
T_STRING => T_STRING,
@@ -580,7 +580,7 @@ final class Tokens
580580
/**
581581
* Tokens that open class and object scopes.
582582
*
583-
* @var array<int, int>
583+
* @var array<int|string, int|string>
584584
*/
585585
public static $ooScopeTokens = [
586586
T_CLASS => T_CLASS,
@@ -623,8 +623,8 @@ public static function tokenName($token)
623623
*
624624
* Returns false if there are no weightings for any of the specified tokens.
625625
*
626-
* @param array<int, int> $tokens The token types to get the highest weighted
627-
* type for.
626+
* @param array<int|string> $tokens The token types to get the highest weighted
627+
* type for.
628628
*
629629
* @return int The highest weighted token.
630630
*/

tests/AllTests.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,16 @@
99

1010
namespace PHP_CodeSniffer\Tests;
1111

12+
$GLOBALS['PHP_CODESNIFFER_PEAR'] = false;
13+
1214
if (is_file(__DIR__.'/../autoload.php') === true) {
1315
include_once 'Core/AllTests.php';
1416
include_once 'Standards/AllSniffs.php';
1517
} else {
1618
include_once 'CodeSniffer/Core/AllTests.php';
1719
include_once 'CodeSniffer/Standards/AllSniffs.php';
1820
include_once 'FileList.php';
21+
$GLOBALS['PHP_CODESNIFFER_PEAR'] = true;
1922
}
2023

2124
// PHPUnit 7 made the TestSuite run() method incompatible with

0 commit comments

Comments
 (0)