Browse Source

DX: enable `UseArrowFunctionsFixer` for the codebase (#7194)

Kuba Werłos 1 year ago
parent
commit
287c45b0f4

+ 0 - 1
.php-cs-fixer.dist.php

@@ -43,7 +43,6 @@ $config
         'heredoc_indentation' => false, // TODO switch on when # of PR's is lower
         'modernize_strpos' => true, // needs PHP 8+ or polyfill
         'no_useless_concat_operator' => false, // TODO switch back on when the `src/Console/Application.php` no longer needs the concat
-        'use_arrow_functions' => false, // TODO switch on when # of PR's is lower
     ])
     ->setFinder($finder)
 ;

+ 1 - 3
src/Console/Command/DescribeCommand.php

@@ -421,9 +421,7 @@ final class DescribeCommand extends Command
             static function (array $matches) {
                 return Preg::replaceCallback(
                     '/`(.*)<(.*)>`_/',
-                    static function (array $matches): string {
-                        return $matches[1].'('.$matches[2].')';
-                    },
+                    static fn (array $matches): string => $matches[1].'('.$matches[2].')',
                     $matches[1]
                 );
             },

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

@@ -44,9 +44,7 @@ final class HelpCommand extends BaseHelpCommand
         $allowed = $option->getAllowedValues();
 
         if (null !== $allowed) {
-            $allowed = array_filter($allowed, static function ($value): bool {
-                return !$value instanceof \Closure;
-            });
+            $allowed = array_filter($allowed, static fn ($value): bool => !$value instanceof \Closure);
 
             usort($allowed, static function ($valueA, $valueB): int {
                 if ($valueA instanceof AllowedValueSubset) {

+ 3 - 9
src/Console/ConfigurationResolver.php

@@ -328,14 +328,10 @@ final class ConfigurationResolver
 
             if (false === $this->getRiskyAllowed()) {
                 $riskyFixers = array_map(
-                    static function (FixerInterface $fixer): string {
-                        return $fixer->getName();
-                    },
+                    static fn (FixerInterface $fixer): string => $fixer->getName(),
                     array_filter(
                         $this->fixers,
-                        static function (FixerInterface $fixer): bool {
-                            return $fixer->isRisky();
-                        }
+                        static fn (FixerInterface $fixer): bool => $fixer->isRisky()
                     )
                 );
 
@@ -838,9 +834,7 @@ final class ConfigurationResolver
         $isIntersectionPathMode = self::PATH_MODE_INTERSECTION === $this->options['path-mode'];
 
         $paths = array_filter(array_map(
-            static function (string $path) {
-                return realpath($path);
-            },
+            static fn (string $path) => realpath($path),
             $this->getPath()
         ));
 

+ 1 - 3
src/Console/Report/ListSetsReport/JsonReporter.php

@@ -32,9 +32,7 @@ final class JsonReporter implements ReporterInterface
     {
         $sets = $reportSummary->getSets();
 
-        usort($sets, static function (RuleSetDescriptionInterface $a, RuleSetDescriptionInterface $b): int {
-            return strcmp($a->getName(), $b->getName());
-        });
+        usort($sets, static fn (RuleSetDescriptionInterface $a, RuleSetDescriptionInterface $b): int => strcmp($a->getName(), $b->getName()));
 
         $json = ['sets' => []];
 

+ 1 - 3
src/Console/Report/ListSetsReport/TextReporter.php

@@ -32,9 +32,7 @@ final class TextReporter implements ReporterInterface
     {
         $sets = $reportSummary->getSets();
 
-        usort($sets, static function (RuleSetDescriptionInterface $a, RuleSetDescriptionInterface $b): int {
-            return strcmp($a->getName(), $b->getName());
-        });
+        usort($sets, static fn (RuleSetDescriptionInterface $a, RuleSetDescriptionInterface $b): int => strcmp($a->getName(), $b->getName()));
 
         $output = '';
 

+ 1 - 3
src/DocBlock/Annotation.php

@@ -227,9 +227,7 @@ final class Annotation
      */
     public function getNormalizedTypes(): array
     {
-        $normalized = array_map(static function (string $type): string {
-            return strtolower($type);
-        }, $this->getTypes());
+        $normalized = array_map(static fn (string $type): string => strtolower($type), $this->getTypes());
 
         sort($normalized);
 

+ 1 - 3
src/DocBlock/DocBlock.php

@@ -152,9 +152,7 @@ final class DocBlock
 
         $usefulLines = array_filter(
             $this->lines,
-            static function (Line $line): bool {
-                return $line->containsUsefulContent();
-            }
+            static fn (Line $line): bool => $line->containsUsefulContent()
         );
 
         if (1 < \count($usefulLines)) {

+ 1 - 3
src/Documentation/DocumentationLocator.php

@@ -44,9 +44,7 @@ final class DocumentationLocator
     {
         return $this->getFixersDocumentationDirectoryPath().'/'.Preg::replaceCallback(
             '/^.*\\\\(.+)\\\\(.+)Fixer$/',
-            static function (array $matches): string {
-                return Utils::camelCaseToUnderscore($matches[1]).'/'.Utils::camelCaseToUnderscore($matches[2]);
-            },
+            static fn (array $matches): string => Utils::camelCaseToUnderscore($matches[1]).'/'.Utils::camelCaseToUnderscore($matches[2]),
             \get_class($fixer)
         ).'.rst';
     }

+ 1 - 3
src/Documentation/FixerDocumentGenerator.php

@@ -254,9 +254,7 @@ RST;
             'Phpdoc' => 'PHPDoc',
         ];
 
-        usort($fixers, static function (FixerInterface $a, FixerInterface $b): int {
-            return strcmp(\get_class($a), \get_class($b));
-        });
+        usort($fixers, static fn (FixerInterface $a, FixerInterface $b): int => strcmp(\get_class($a), \get_class($b)));
 
         $documentation = <<<'RST'
 =======================

Some files were not shown because too many files changed in this diff