Kuba Werłos 3 лет назад
Родитель
Сommit
bc656ec721

+ 2 - 2
UPGRADE-v3.md

@@ -157,8 +157,8 @@ Code BC changes
 
 - class `Token` is now `final`
 - class `Tokens` is now `final`
-- method `create` of class `Config` has been removed, use the constructor
-- method `create` of class `RuleSet` has been removed, use the constructor
+- method `create` of class `Config` has been removed, [use the constructor](./doc/config.rst)
+- method `create` of class `RuleSet` has been removed, [use the constructor](./doc/custom_rules.rst)
 
 ### BC breaks; common internal classes
 

+ 2 - 1
composer.json

@@ -26,7 +26,8 @@
         "symfony/filesystem": "^4.4.20 || ^5.0",
         "symfony/finder": "^4.4.20 || ^5.0",
         "symfony/options-resolver": "^4.4.20 || ^5.0",
-        "symfony/polyfill-php72": "^1.22",
+        "symfony/polyfill-php72": "^1.23",
+        "symfony/polyfill-php81": "^1.23",
         "symfony/process": "^4.4.20 || ^5.0",
         "symfony/stopwatch": "^4.4.20 || ^5.0"
     },

+ 1 - 1
doc/usage.rst

@@ -133,7 +133,7 @@ The ``--config`` option can be used, like in the ``fix`` command, to tell from w
 
     $ php php-cs-fixer.phar list-files --config=.php-cs-fixer.dist.php
 
-The output is build in a form that its easy to use in combination with ``xargs`` command in a linux pipe.
+The output is built in a form that its easy to use in combination with ``xargs`` command in a linux pipe.
 This can be useful e.g. in situations where the caching mechanism might not be available (CI, Docker) and distribute
 fixing across several processes might speedup the process.
 

+ 1 - 16
src/Console/Command/HelpCommand.php

@@ -106,7 +106,7 @@ final class HelpCommand extends BaseHelpCommand
             return '[]';
         }
 
-        $isHash = static::isHash($value);
+        $isHash = !array_is_list($value);
         $str = '[';
 
         foreach ($value as $k => $v) {
@@ -122,19 +122,4 @@ final class HelpCommand extends BaseHelpCommand
 
         return substr($str, 0, -2).']';
     }
-
-    private static function isHash(array $array): bool
-    {
-        $i = 0;
-
-        foreach ($array as $k => $v) {
-            if ($k !== $i) {
-                return true;
-            }
-
-            ++$i;
-        }
-
-        return false;
-    }
 }

+ 11 - 9
src/Fixer/Phpdoc/PhpdocTagTypeFixer.php

@@ -90,21 +90,23 @@ final class PhpdocTagTypeFixer extends AbstractFixer implements ConfigurableFixe
             return;
         }
 
+        $regularExpression = sprintf(
+            '/({?@(?:%s).*?(?:(?=\s\*\/)|(?=\n)}?))/i',
+            implode('|', array_map(
+                function (string $tag) {
+                    return preg_quote($tag, '/');
+                },
+                array_keys($this->configuration['tags'])
+            ))
+        );
+
         foreach ($tokens as $index => $token) {
             if (!$token->isGivenKind(T_DOC_COMMENT)) {
                 continue;
             }
 
             $parts = Preg::split(
-                sprintf(
-                    '/({?@(?:%s)(?:}|\h.*?(?:}|(?=\R)|(?=\h+\*\/)))?)/i',
-                    implode('|', array_map(
-                        function (string $tag) {
-                            return preg_quote($tag, '/');
-                        },
-                        array_keys($this->configuration['tags'])
-                    ))
-                ),
+                $regularExpression,
                 $token->getContent(),
                 -1,
                 PREG_SPLIT_DELIM_CAPTURE

+ 1 - 5
tests/Fixer/Alias/PowToExponentiationFixerTest.php

@@ -36,7 +36,7 @@ final class PowToExponentiationFixerTest extends AbstractFixerTestCase
 
     public function provideFixCases()
     {
-        $tests = [
+        yield from [
             [
                 '<?php 1**2;',
                 '<?php pow(1,2);',
@@ -226,10 +226,6 @@ final class PowToExponentiationFixerTest extends AbstractFixerTestCase
             ],
         ];
 
-        foreach ($tests as $index => $test) {
-            yield $index => $test;
-        }
-
         if (\PHP_VERSION_ID < 80000) {
             yield [
                 '<?php echo $a{1}** $b{2+5};',

+ 1 - 5
tests/Fixer/CastNotation/ModernizeTypesCastingFixerTest.php

@@ -175,7 +175,7 @@ OVERRIDDEN;
 
     public function provideFix70Cases()
     {
-        $tests = [
+        yield from [
             [
                 '<?php $foo = ((string) $x)[0];',
                 '<?php $foo = strval($x)[0];',
@@ -186,10 +186,6 @@ OVERRIDDEN;
             ],
         ];
 
-        foreach ($tests as $index => $test) {
-            yield $index => $test;
-        }
-
         if (\PHP_VERSION_ID < 80000) {
             yield [
                 '<?php $foo = ((string) ($x + $y)){0};',

+ 1 - 5
tests/Fixer/ClassNotation/ClassDefinitionFixerTest.php

@@ -491,7 +491,7 @@ TestInterface3, /**/     TestInterface4   ,
 
     public function provideClassyImplementsInfoCases()
     {
-        $tests = [
+        yield from [
             '1' => [
                 '<?php
 class X11 implements    Z   , T,R
@@ -525,10 +525,6 @@ class X10 implements    Z   , T,R    //
             ],
         ];
 
-        foreach ($tests as $index => $test) {
-            yield $index => $test;
-        }
-
         if (\PHP_VERSION_ID < 80000) {
             $multiLine = true;
             $code = '<?php

+ 1 - 5
tests/Fixer/ControlStructure/NoUnneededCurlyBracesFixerTest.php

@@ -35,7 +35,7 @@ final class NoUnneededCurlyBracesFixerTest extends AbstractFixerTestCase
 
     public function provideFixCases()
     {
-        $tests = [
+        yield from [
             'simple sample, last token candidate' => [
                 '<?php  echo 1;',
                 '<?php { echo 1;}',
@@ -113,10 +113,6 @@ final class NoUnneededCurlyBracesFixerTest extends AbstractFixerTestCase
             ],
         ];
 
-        foreach ($tests as $index => $test) {
-            yield $index => $test;
-        }
-
         if (\PHP_VERSION_ID < 80000) {
             yield 'no fixes, offset access syntax with curly braces' => [
                 '<?php

+ 2 - 10
tests/Fixer/ControlStructure/NoUselessElseFixerTest.php

@@ -285,11 +285,7 @@ else?><?php echo 5;',
             }
         ';
 
-        $tests = $this->generateCases($expected, $input);
-
-        foreach ($tests as $index => $test) {
-            yield $index => $test;
-        }
+        yield from $this->generateCases($expected, $input);
 
         yield [
             '<?php
@@ -453,7 +449,7 @@ else?><?php echo 5;',
 
     public function provideNegativeCases()
     {
-        $tests = [
+        yield from [
             [
                 '<?php
                     if ($a0) {
@@ -612,10 +608,6 @@ else?><?php echo 5;',
             ],
         ];
 
-        foreach ($tests as $index => $test) {
-            yield $index => $test;
-        }
-
         if (\PHP_VERSION_ID >= 80000) {
             $cases = [
                 '$bar = $foo1 ?? throw new \Exception($e);',

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