Browse Source

PHP7.4 - properties types

SpacePossum 3 years ago
parent
commit
6474f90e5c

+ 1 - 4
src/AbstractDoctrineAnnotationFixer.php

@@ -29,10 +29,7 @@ use PhpCsFixer\Tokenizer\TokensAnalyzer;
  */
 abstract class AbstractDoctrineAnnotationFixer extends AbstractFixer implements ConfigurableFixerInterface
 {
-    /**
-     * @var array
-     */
-    private $classyElements;
+    private array $classyElements;
 
     /**
      * {@inheritdoc}

+ 5 - 8
src/AbstractPhpdocToTypeDeclarationFixer.php

@@ -31,15 +31,12 @@ use PhpCsFixer\Tokenizer\Tokens;
  */
 abstract class AbstractPhpdocToTypeDeclarationFixer extends AbstractFixer implements ConfigurableFixerInterface
 {
-    /**
-     * @var string
-     */
-    private $classRegex = '/^\\\\?[a-zA-Z_\\x7f-\\xff](?:\\\\?[a-zA-Z0-9_\\x7f-\\xff]+)*$/';
+    private const CLASS_REGEX = '/^\\\\?[a-zA-Z_\\x7f-\\xff](?:\\\\?[a-zA-Z0-9_\\x7f-\\xff]+)*$/';
 
     /**
      * @var array<string, int>
      */
-    private $versionSpecificTypes = [
+    private array $versionSpecificTypes = [
         'void' => 70100,
         'iterable' => 70100,
         'object' => 70200,
@@ -49,7 +46,7 @@ abstract class AbstractPhpdocToTypeDeclarationFixer extends AbstractFixer implem
     /**
      * @var array<string, bool>
      */
-    private $scalarTypes = [
+    private array $scalarTypes = [
         'bool' => true,
         'float' => true,
         'int' => true,
@@ -59,7 +56,7 @@ abstract class AbstractPhpdocToTypeDeclarationFixer extends AbstractFixer implem
     /**
      * @var array<string, bool>
      */
-    private static $syntaxValidationCache = [];
+    private static array $syntaxValidationCache = [];
 
     /**
      * {@inheritdoc}
@@ -202,7 +199,7 @@ abstract class AbstractPhpdocToTypeDeclarationFixer extends AbstractFixer implem
             if (false === $this->configuration['scalar_types']) {
                 return null;
             }
-        } elseif (1 !== Preg::match($this->classRegex, $commonType)) {
+        } elseif (1 !== Preg::match(self::CLASS_REGEX, $commonType)) {
             return null;
         }
 

+ 2 - 5
src/Cache/Cache.php

@@ -21,15 +21,12 @@ namespace PhpCsFixer\Cache;
  */
 final class Cache implements CacheInterface
 {
-    /**
-     * @var SignatureInterface
-     */
-    private $signature;
+    private SignatureInterface $signature;
 
     /**
      * @var array<string, int>
      */
-    private $hashes = [];
+    private array $hashes = [];
 
     public function __construct(SignatureInterface $signature)
     {

+ 1 - 4
src/Cache/Directory.php

@@ -21,10 +21,7 @@ namespace PhpCsFixer\Cache;
  */
 final class Directory implements DirectoryInterface
 {
-    /**
-     * @var string
-     */
-    private $directoryName;
+    private string $directoryName;
 
     public function __construct(string $directoryName)
     {

+ 6 - 18
src/Cache/FileCacheManager.php

@@ -32,30 +32,18 @@ namespace PhpCsFixer\Cache;
  */
 final class FileCacheManager implements CacheManagerInterface
 {
-    /**
-     * @var FileHandlerInterface
-     */
-    private $handler;
+    private FileHandlerInterface $handler;
 
-    /**
-     * @var SignatureInterface
-     */
-    private $signature;
+    private SignatureInterface $signature;
 
-    /**
-     * @var CacheInterface
-     */
-    private $cache;
+    private bool $isDryRun;
 
-    /**
-     * @var bool
-     */
-    private $isDryRun;
+    private DirectoryInterface $cacheDirectory;
 
     /**
-     * @var DirectoryInterface
+     * @var CacheInterface
      */
-    private $cacheDirectory;
+    private $cache;
 
     public function __construct(
         FileHandlerInterface $handler,

+ 1 - 4
src/Cache/FileHandler.php

@@ -23,10 +23,7 @@ use Symfony\Component\Filesystem\Exception\IOException;
  */
 final class FileHandler implements FileHandlerInterface
 {
-    /**
-     * @var string
-     */
-    private $file;
+    private string $file;
 
     public function __construct(string $file)
     {

+ 9 - 24
src/Cache/Signature.php

@@ -21,30 +21,15 @@ namespace PhpCsFixer\Cache;
  */
 final class Signature implements SignatureInterface
 {
-    /**
-     * @var string
-     */
-    private $phpVersion;
-
-    /**
-     * @var string
-     */
-    private $fixerVersion;
-
-    /**
-     * @var string
-     */
-    private $indent;
-
-    /**
-     * @var string
-     */
-    private $lineEnding;
-
-    /**
-     * @var array
-     */
-    private $rules;
+    private string $phpVersion;
+
+    private string $fixerVersion;
+
+    private string $indent;
+
+    private string $lineEnding;
+
+    private array $rules;
 
     public function __construct(string $phpVersion, string $fixerVersion, string $indent, string $lineEnding, array $rules)
     {

+ 10 - 37
src/Config.php

@@ -23,65 +23,38 @@ use PhpCsFixer\Fixer\FixerInterface;
  */
 class Config implements ConfigInterface
 {
-    /**
-     * @var string
-     */
-    private $cacheFile = '.php-cs-fixer.cache';
+    private string $cacheFile = '.php-cs-fixer.cache';
 
     /**
      * @var FixerInterface[]
      */
-    private $customFixers = [];
+    private array $customFixers = [];
 
     /**
      * @var null|iterable
      */
     private $finder;
 
-    /**
-     * @var string
-     */
-    private $format = 'txt';
+    private string $format = 'txt';
 
-    /**
-     * @var bool
-     */
-    private $hideProgress = false;
+    private bool $hideProgress = false;
 
-    /**
-     * @var string
-     */
-    private $indent = '    ';
+    private string $indent = '    ';
 
-    /**
-     * @var bool
-     */
-    private $isRiskyAllowed = false;
+    private bool $isRiskyAllowed = false;
 
-    /**
-     * @var string
-     */
-    private $lineEnding = "\n";
+    private string $lineEnding = "\n";
 
-    /**
-     * @var string
-     */
-    private $name;
+    private string $name;
 
     /**
      * @var null|string
      */
     private $phpExecutable;
 
-    /**
-     * @var array
-     */
-    private $rules = ['@PSR12' => true];
+    private array $rules = ['@PSR12' => true];
 
-    /**
-     * @var bool
-     */
-    private $usingCache = true;
+    private bool $usingCache = true;
 
     public function __construct(string $name = 'default')
     {

+ 2 - 4
src/ConfigurationException/InvalidFixerConfigurationException.php

@@ -24,10 +24,7 @@ use PhpCsFixer\Console\Command\FixCommandExitStatusCalculator;
  */
 class InvalidFixerConfigurationException extends InvalidConfigurationException
 {
-    /**
-     * @var string
-     */
-    private $fixerName;
+    private string $fixerName;
 
     public function __construct(string $fixerName, string $message, ?\Throwable $previous = null)
     {
@@ -36,6 +33,7 @@ class InvalidFixerConfigurationException extends InvalidConfigurationException
             FixCommandExitStatusCalculator::EXIT_STATUS_FLAG_HAS_INVALID_FIXER_CONFIG,
             $previous
         );
+
         $this->fixerName = $fixerName;
     }
 

+ 1 - 4
src/Console/Application.php

@@ -42,10 +42,7 @@ final class Application extends BaseApplication
     public const VERSION = '3.6.1-DEV';
     public const VERSION_CODENAME = 'Roe Deer';
 
-    /**
-     * @var ToolInfo
-     */
-    private $toolInfo;
+    private ToolInfo $toolInfo;
 
     public function __construct()
     {

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