Browse Source

Prepare for PHP8.1, clean ups, type hints, SCA

SpacePossum 3 years ago
parent
commit
87f08d8b5c

+ 1 - 1
src/AbstractDoctrineAnnotationFixer.php

@@ -79,7 +79,7 @@ abstract class AbstractDoctrineAnnotationFixer extends AbstractFixer implements
         return new FixerConfigurationResolver([
         return new FixerConfigurationResolver([
             (new FixerOptionBuilder('ignored_tags', 'List of tags that must not be treated as Doctrine Annotations.'))
             (new FixerOptionBuilder('ignored_tags', 'List of tags that must not be treated as Doctrine Annotations.'))
                 ->setAllowedTypes(['array'])
                 ->setAllowedTypes(['array'])
-                ->setAllowedValues([static function (array $values) {
+                ->setAllowedValues([static function (array $values): bool {
                     foreach ($values as $value) {
                     foreach ($values as $value) {
                         if (!\is_string($value)) {
                         if (!\is_string($value)) {
                             return false;
                             return false;

+ 0 - 2
src/AbstractFopenFlagFixer.php

@@ -19,8 +19,6 @@ use PhpCsFixer\Tokenizer\Tokens;
 
 
 /**
 /**
  * @internal
  * @internal
- *
- * @author SpacePossum
  */
  */
 abstract class AbstractFopenFlagFixer extends AbstractFunctionReferenceFixer
 abstract class AbstractFopenFlagFixer extends AbstractFunctionReferenceFixer
 {
 {

+ 1 - 1
src/AbstractLinesBeforeNamespaceFixer.php

@@ -22,7 +22,7 @@ use PhpCsFixer\Tokenizer\Tokens;
  * This abstract fixer is responsible for ensuring that a certain number of
  * This abstract fixer is responsible for ensuring that a certain number of
  * lines prefix a namespace declaration.
  * lines prefix a namespace declaration.
  *
  *
- * @author Graham Campbell <graham@alt-three.com>
+ * @author Graham Campbell <hello@gjcampbell.co.uk>
  *
  *
  * @internal
  * @internal
  */
  */

+ 0 - 3
src/AbstractNoUselessElseFixer.php

@@ -16,9 +16,6 @@ namespace PhpCsFixer;
 
 
 use PhpCsFixer\Tokenizer\Tokens;
 use PhpCsFixer\Tokenizer\Tokens;
 
 
-/**
- * @author SpacePossum
- */
 abstract class AbstractNoUselessElseFixer extends AbstractFixer
 abstract class AbstractNoUselessElseFixer extends AbstractFixer
 {
 {
     /**
     /**

+ 1 - 1
src/AbstractPhpdocTypesFixer.php

@@ -22,7 +22,7 @@ use PhpCsFixer\Tokenizer\Tokens;
 /**
 /**
  * This abstract fixer provides a base for fixers to fix types in PHPDoc.
  * This abstract fixer provides a base for fixers to fix types in PHPDoc.
  *
  *
- * @author Graham Campbell <graham@alt-three.com>
+ * @author Graham Campbell <hello@gjcampbell.co.uk>
  *
  *
  * @internal
  * @internal
  */
  */

+ 0 - 2
src/ConfigurationException/InvalidConfigurationException.php

@@ -19,8 +19,6 @@ use PhpCsFixer\Console\Command\FixCommandExitStatusCalculator;
 /**
 /**
  * Exceptions of this type are thrown on misconfiguration of the Fixer.
  * Exceptions of this type are thrown on misconfiguration of the Fixer.
  *
  *
- * @author SpacePossum
- *
  * @internal
  * @internal
  * @final Only internal extending this class is supported
  * @final Only internal extending this class is supported
  */
  */

+ 0 - 2
src/ConfigurationException/InvalidFixerConfigurationException.php

@@ -19,8 +19,6 @@ use PhpCsFixer\Console\Command\FixCommandExitStatusCalculator;
 /**
 /**
  * Exception thrown by Fixers on misconfiguration.
  * Exception thrown by Fixers on misconfiguration.
  *
  *
- * @author SpacePossum
- *
  * @internal
  * @internal
  * @final Only internal extending this class is supported
  * @final Only internal extending this class is supported
  */
  */

+ 11 - 14
src/Console/Command/DescribeCommand.php

@@ -41,7 +41,6 @@ use Symfony\Component\Console\Output\OutputInterface;
 
 
 /**
 /**
  * @author Dariusz Rumiński <dariusz.ruminski@gmail.com>
  * @author Dariusz Rumiński <dariusz.ruminski@gmail.com>
- * @author SpacePossum
  *
  *
  * @internal
  * @internal
  */
  */
@@ -193,7 +192,14 @@ final class DescribeCommand extends Command
                 $line = '* <info>'.OutputFormatter::escape($option->getName()).'</info>';
                 $line = '* <info>'.OutputFormatter::escape($option->getName()).'</info>';
                 $allowed = HelpCommand::getDisplayableAllowedValues($option);
                 $allowed = HelpCommand::getDisplayableAllowedValues($option);
 
 
-                if (null !== $allowed) {
+                if (null === $allowed) {
+                    $allowed = array_map(
+                        static function (string $type): string {
+                            return '<comment>'.$type.'</comment>';
+                        },
+                        $option->getAllowedTypes()
+                    );
+                } else {
                     foreach ($allowed as &$value) {
                     foreach ($allowed as &$value) {
                         if ($value instanceof AllowedValueSubset) {
                         if ($value instanceof AllowedValueSubset) {
                             $value = 'a subset of <comment>'.HelpCommand::toString($value->getAllowedValues()).'</comment>';
                             $value = 'a subset of <comment>'.HelpCommand::toString($value->getAllowedValues()).'</comment>';
@@ -201,18 +207,9 @@ final class DescribeCommand extends Command
                             $value = '<comment>'.HelpCommand::toString($value).'</comment>';
                             $value = '<comment>'.HelpCommand::toString($value).'</comment>';
                         }
                         }
                     }
                     }
-                } else {
-                    $allowed = array_map(
-                        static function (string $type) {
-                            return '<comment>'.$type.'</comment>';
-                        },
-                        $option->getAllowedTypes()
-                    );
                 }
                 }
 
 
-                if (null !== $allowed) {
-                    $line .= ' ('.implode(', ', $allowed).')';
-                }
+                $line .= ' ('.implode(', ', $allowed).')';
 
 
                 $description = Preg::replace('/(`.+?`)/', '<info>$1</info>', OutputFormatter::escape($option->getDescription()));
                 $description = Preg::replace('/(`.+?`)/', '<info>$1</info>', OutputFormatter::escape($option->getDescription()));
                 $line .= ': '.lcfirst(Preg::replace('/\.$/', '', $description)).'; ';
                 $line .= ': '.lcfirst(Preg::replace('/\.$/', '', $description)).'; ';
@@ -245,7 +242,7 @@ final class DescribeCommand extends Command
         }
         }
 
 
         /** @var CodeSampleInterface[] $codeSamples */
         /** @var CodeSampleInterface[] $codeSamples */
-        $codeSamples = array_filter($definition->getCodeSamples(), static function (CodeSampleInterface $codeSample) {
+        $codeSamples = array_filter($definition->getCodeSamples(), static function (CodeSampleInterface $codeSample): bool {
             if ($codeSample instanceof VersionSpecificCodeSampleInterface) {
             if ($codeSample instanceof VersionSpecificCodeSampleInterface) {
                 return $codeSample->isSuitableFor(\PHP_VERSION_ID);
                 return $codeSample->isSuitableFor(\PHP_VERSION_ID);
             }
             }
@@ -421,7 +418,7 @@ final class DescribeCommand extends Command
             static function (array $matches) {
             static function (array $matches) {
                 return Preg::replaceCallback(
                 return Preg::replaceCallback(
                     '/`(.*)<(.*)>`_/',
                     '/`(.*)<(.*)>`_/',
-                    static function (array $matches) {
+                    static function (array $matches): string {
                         return $matches[1].'('.$matches[2].')';
                         return $matches[1].'('.$matches[2].')';
                     },
                     },
                     $matches[1]
                     $matches[1]

+ 0 - 2
src/Console/Command/DescribeNameNotFoundException.php

@@ -15,8 +15,6 @@ declare(strict_types=1);
 namespace PhpCsFixer\Console\Command;
 namespace PhpCsFixer\Console\Command;
 
 
 /**
 /**
- * @author SpacePossum
- *
  * @internal
  * @internal
  */
  */
 final class DescribeNameNotFoundException extends \InvalidArgumentException
 final class DescribeNameNotFoundException extends \InvalidArgumentException

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

@@ -25,7 +25,6 @@ use Symfony\Component\Console\Output\OutputInterface;
 /**
 /**
  * @author Fabien Potencier <fabien@symfony.com>
  * @author Fabien Potencier <fabien@symfony.com>
  * @author Dariusz Rumiński <dariusz.ruminski@gmail.com>
  * @author Dariusz Rumiński <dariusz.ruminski@gmail.com>
- * @author SpacePossum
  *
  *
  * @internal
  * @internal
  */
  */
@@ -55,11 +54,11 @@ final class HelpCommand extends BaseHelpCommand
         $allowed = $option->getAllowedValues();
         $allowed = $option->getAllowedValues();
 
 
         if (null !== $allowed) {
         if (null !== $allowed) {
-            $allowed = array_filter($allowed, static function ($value) {
+            $allowed = array_filter($allowed, static function ($value): bool {
                 return !($value instanceof \Closure);
                 return !($value instanceof \Closure);
             });
             });
 
 
-            usort($allowed, static function ($valueA, $valueB) {
+            usort($allowed, static function ($valueA, $valueB): int {
                 if ($valueA instanceof AllowedValueSubset) {
                 if ($valueA instanceof AllowedValueSubset) {
                     return -1;
                     return -1;
                 }
                 }

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