Browse Source

chore: add more typehints (#8325)

Dariusz Rumiński 2 months ago
parent
commit
7045be8815

+ 1 - 4
src/AbstractFixer.php

@@ -27,10 +27,7 @@ use PhpCsFixer\Tokenizer\Tokens;
  */
 abstract class AbstractFixer implements FixerInterface
 {
-    /**
-     * @var WhitespacesFixerConfig
-     */
-    protected $whitespacesConfig;
+    protected WhitespacesFixerConfig $whitespacesConfig;
 
     public function __construct()
     {

+ 1 - 4
src/AbstractFunctionReferenceFixer.php

@@ -24,10 +24,7 @@ use PhpCsFixer\Tokenizer\Tokens;
  */
 abstract class AbstractFunctionReferenceFixer extends AbstractFixer
 {
-    /**
-     * @var null|FunctionsAnalyzer
-     */
-    private $functionsAnalyzer;
+    private ?FunctionsAnalyzer $functionsAnalyzer = null;
 
     public function isCandidate(Tokens $tokens): bool
     {

+ 1 - 4
src/Cache/FileCacheManager.php

@@ -48,10 +48,7 @@ final class FileCacheManager implements CacheManagerInterface
 
     private bool $signatureWasUpdated = false;
 
-    /**
-     * @var CacheInterface
-     */
-    private $cache;
+    private CacheInterface $cache;
 
     public function __construct(
         FileHandlerInterface $handler,

+ 1 - 4
src/Config.php

@@ -60,10 +60,7 @@ class Config implements ConfigInterface, ParallelAwareConfigInterface
 
     private ParallelConfig $parallelConfig;
 
-    /**
-     * @var null|string
-     */
-    private $phpExecutable;
+    private ?string $phpExecutable = null;
 
     /**
      * @TODO: 4.0 - update to @PER

+ 2 - 2
src/Console/Command/DescribeCommand.php

@@ -61,14 +61,14 @@ final class DescribeCommand extends Command
     /**
      * @var ?list<string>
      */
-    private $setNames;
+    private ?array $setNames = null;
 
     private FixerFactory $fixerFactory;
 
     /**
      * @var null|array<string, FixerInterface>
      */
-    private $fixers;
+    private ?array $fixers = null;
 
     public function __construct(?FixerFactory $fixerFactory = null)
     {

+ 16 - 61
src/Console/ConfigurationResolver.php

@@ -62,49 +62,28 @@ final class ConfigurationResolver
     public const PATH_MODE_OVERRIDE = 'override';
     public const PATH_MODE_INTERSECTION = 'intersection';
 
-    /**
-     * @var null|bool
-     */
-    private $allowRisky;
+    private ?bool $allowRisky = null;
 
-    /**
-     * @var null|ConfigInterface
-     */
-    private $config;
+    private ?ConfigInterface $config = null;
 
-    /**
-     * @var null|string
-     */
-    private $configFile;
+    private ?string $configFile = null;
 
     private string $cwd;
 
     private ConfigInterface $defaultConfig;
 
-    /**
-     * @var null|ReporterInterface
-     */
-    private $reporter;
+    private ?ReporterInterface $reporter = null;
 
-    /**
-     * @var null|bool
-     */
-    private $isStdIn;
+    private ?bool $isStdIn = null;
 
-    /**
-     * @var null|bool
-     */
-    private $isDryRun;
+    private ?bool $isDryRun = null;
 
     /**
      * @var null|list<FixerInterface>
      */
-    private $fixers;
+    private ?array $fixers = null;
 
-    /**
-     * @var null|bool
-     */
-    private $configFinderIsOverridden;
+    private ?bool $configFinderIsOverridden = null;
 
     private ToolInfoInterface $toolInfo;
 
@@ -128,25 +107,13 @@ final class ConfigurationResolver
         'verbosity' => null,
     ];
 
-    /**
-     * @var null|string
-     */
-    private $cacheFile;
+    private ?string $cacheFile = null;
 
-    /**
-     * @var null|CacheManagerInterface
-     */
-    private $cacheManager;
+    private ?CacheManagerInterface $cacheManager = null;
 
-    /**
-     * @var null|DifferInterface
-     */
-    private $differ;
+    private ?DifferInterface $differ = null;
 
-    /**
-     * @var null|Directory
-     */
-    private $directory;
+    private ?Directory $directory = null;
 
     /**
      * @var null|iterable<\SplFileInfo>
@@ -155,10 +122,7 @@ final class ConfigurationResolver
 
     private ?string $format = null;
 
-    /**
-     * @var null|Linter
-     */
-    private $linter;
+    private ?Linter $linter = null;
 
     /**
      * @var null|list<string>
@@ -170,20 +134,11 @@ final class ConfigurationResolver
      */
     private $progress;
 
-    /**
-     * @var null|RuleSet
-     */
-    private $ruleSet;
+    private ?RuleSet $ruleSet = null;
 
-    /**
-     * @var null|bool
-     */
-    private $usingCache;
+    private ?bool $usingCache = null;
 
-    /**
-     * @var null|FixerFactory
-     */
-    private $fixerFactory;
+    private ?FixerFactory $fixerFactory = null;
 
     /**
      * @param array<string, mixed> $options

+ 1 - 4
src/Console/Output/ErrorOutput.php

@@ -28,10 +28,7 @@ final class ErrorOutput
 {
     private OutputInterface $output;
 
-    /**
-     * @var bool
-     */
-    private $isDecorated;
+    private bool $isDecorated;
 
     public function __construct(OutputInterface $output)
     {

+ 1 - 4
src/Console/Output/Progress/DotsOutput.php

@@ -44,10 +44,7 @@ final class DotsOutput implements ProgressOutputInterface
 
     private int $processedFiles = 0;
 
-    /**
-     * @var int
-     */
-    private $symbolsPerLine;
+    private int $symbolsPerLine;
 
     public function __construct(OutputContext $context)
     {

+ 1 - 1
src/Console/SelfUpdate/NewVersionChecker.php

@@ -30,7 +30,7 @@ final class NewVersionChecker implements NewVersionCheckerInterface
     /**
      * @var null|list<string>
      */
-    private $availableVersions;
+    private ?array $availableVersions = null;
 
     public function __construct(GithubClientInterface $githubClient)
     {

+ 6 - 17
src/DocBlock/Annotation.php

@@ -52,43 +52,32 @@ final class Annotation
 
     /**
      * The position of the first line of the annotation in the docblock.
-     *
-     * @var int
      */
-    private $start;
+    private int $start;
 
     /**
      * The position of the last line of the annotation in the docblock.
-     *
-     * @var int
      */
-    private $end;
+    private int $end;
 
     /**
      * The associated tag.
-     *
-     * @var null|Tag
      */
-    private $tag;
+    private ?Tag $tag = null;
 
     /**
      * Lazy loaded, cached types content.
-     *
-     * @var null|string
      */
-    private $typesContent;
+    private ?string $typesContent = null;
 
     /**
      * The cached types.
      *
      * @var null|list<string>
      */
-    private $types;
+    private ?array $types = null;
 
-    /**
-     * @var null|NamespaceAnalysis
-     */
-    private $namespace;
+    private ?NamespaceAnalysis $namespace = null;
 
     /**
      * @var list<NamespaceUseAnalysis>

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