Просмотр исходного кода

DX: Test that Transformers are adding only CustomTokens that they define and nothing else

Dariusz Ruminski 4 лет назад
Родитель
Сommit
9f54f1bfcd

+ 1 - 0
.composer-require-checker.json

@@ -1,6 +1,7 @@
 {
     "symbol-whitelist" : [
         "LegacyPHPUnit\\TestCase",
+        "PhpCsFixer\\AccessibleObject\\AccessibleObject",
         "PhpCsFixer\\PhpunitConstraintIsIdenticalString\\Constraint\\IsIdenticalString",
         "PhpCsFixer\\Tests\\Test\\Constraint\\SameStringsConstraint",
         "PhpCsFixer\\Tests\\Test\\IsIdenticalConstraint",

+ 1 - 0
.github/workflows/sca.yml

@@ -114,5 +114,6 @@ jobs:
             grep -v tests/Test/IntegrationCaseFactoryInterface.php |
             grep -v tests/Test/InternalIntegrationCaseFactory.php |
             grep -v tests/Test/IsIdenticalConstraint.php |
+            grep -v tests/Test/TokensWithObservedTransformers.php |
             grep -v tests/TestCase.php \
           && (echo "UNKNOWN FILES DETECTED" && exit 1) || echo "NO UNKNOWN FILES"

+ 1 - 0
composer.json

@@ -71,6 +71,7 @@
             "tests/Test/IntegrationCaseFactoryInterface.php",
             "tests/Test/InternalIntegrationCaseFactory.php",
             "tests/Test/IsIdenticalConstraint.php",
+            "tests/Test/TokensWithObservedTransformers.php",
             "tests/TestCase.php"
         ]
     },

+ 2 - 1
src/Fixer/ControlStructure/NoUnneededControlParenthesesFixer.php

@@ -46,11 +46,12 @@ final class NoUnneededControlParenthesesFixer extends AbstractFixer implements C
     {
         parent::__construct();
 
-        // To be moved back to compile time property declaration when PHP support of PHP CS Fixer will be 7.0+
+        // @TODO: To be moved back to compile time property declaration when PHP support of PHP CS Fixer will be 7.0+
         if (\defined('T_COALESCE')) {
             self::$loops['clone']['forbiddenContents'][] = [T_COALESCE, '??'];
         }
 
+        // @TODO: To be moved back to compile time property declaration when PHP support of PHP CS Fixer will be 7.0+
         if (\defined('T_YIELD_FROM')) {
             self::$loops['yield_from'] = ['lookupTokens' => T_YIELD_FROM, 'neededSuccessors' => [';', ')']];
         }

+ 2 - 0
src/Fixer/ControlStructure/YodaStyleFixer.php

@@ -485,10 +485,12 @@ return $foo === count($bar);
                 T_XOR_EQUAL,    // ^=
             ];
 
+            // @TODO: drop condition when PHP 7.0+ is required
             if (\defined('T_COALESCE')) {
                 $tokens[] = T_COALESCE; // ??
             }
 
+            // @TODO: drop condition when PHP 7.4+ is required
             if (\defined('T_COALESCE_EQUAL')) {
                 $tokens[] = T_COALESCE_EQUAL; // ??=
             }

+ 2 - 0
src/Fixer/LanguageConstruct/SingleSpaceAfterConstructFixer.php

@@ -105,10 +105,12 @@ final class SingleSpaceAfterConstructFixer extends AbstractFixer implements Conf
     {
         parent::configure($configuration);
 
+        // @TODO: drop condition when PHP 7.0+ is required
         if (\defined('T_YIELD_FROM')) {
             self::$tokenMap['yield_from'] = T_YIELD_FROM;
         }
 
+        // @TODO: drop condition when PHP 8.0+ is required
         if (\defined('T_MATCH')) {
             self::$tokenMap['match'] = T_MATCH;
         }

+ 3 - 0
src/Fixer/Operator/BinaryOperatorSpacesFixer.php

@@ -457,14 +457,17 @@ $foo = \json_encode($bar, JSON_PRESERVE_ZERO_FRACTION | JSON_PRETTY_PRINT);
             }
         }
 
+        // @TODO: drop condition when PHP 7.0+ is required
         if (!\defined('T_SPACESHIP')) {
             unset($operators['<=>']);
         }
 
+        // @TODO: drop condition when PHP 7.0+ is required
         if (!\defined('T_COALESCE')) {
             unset($operators['??']);
         }
 
+        // @TODO: drop condition when PHP 7.4+ is required
         if (!\defined('T_COALESCE_EQUAL')) {
             unset($operators['??=']);
         }

+ 1 - 0
src/Fixer/Operator/NewWithBracesFixer.php

@@ -95,6 +95,7 @@ final class NewWithBracesFixer extends AbstractFixer
                 [CT::T_BRACE_CLASS_INSTANTIATION_CLOSE],
             ];
 
+            // @TODO: drop condition when PHP 7.0+ is required
             if (\defined('T_SPACESHIP')) {
                 $nextTokenKinds[] = [T_SPACESHIP];
             }

+ 1 - 1
src/Fixer/Whitespace/BlankLineBeforeStatementFixer.php

@@ -71,7 +71,7 @@ final class BlankLineBeforeStatementFixer extends AbstractFixer implements Confi
     {
         parent::__construct();
 
-        // To be moved back to compile time property declaration when PHP support of PHP CS Fixer will be 7.0+
+        // @TODO: To be moved back to compile time property declaration when PHP support of PHP CS Fixer will be 7.0+
         if (\defined('T_YIELD_FROM')) {
             self::$tokenMap['yield_from'] = T_YIELD_FROM;
         }

+ 6 - 1
src/Linter/TokenizerLinter.php

@@ -27,7 +27,12 @@ final class TokenizerLinter implements LinterInterface
 {
     public function __construct()
     {
-        if (false === \defined('TOKEN_PARSE') || false === class_exists(\CompileError::class)) {
+        if (
+            // @TODO: drop condition when PHP 7.0+ is required
+            false === \defined('TOKEN_PARSE')
+            // @TODO: drop condition when PHP 7.3+ is required
+            || false === class_exists(\CompileError::class)
+        ) {
             throw new UnavailableLinterException('Cannot use tokenizer as linter.');
         }
     }

Некоторые файлы не были показаны из-за большого количества измененных файлов