diff --git a/src/AbstractDoctrineAnnotationFixer.php b/src/AbstractDoctrineAnnotationFixer.php index 56d7f8fefd0..8299f5b7b89 100644 --- a/src/AbstractDoctrineAnnotationFixer.php +++ b/src/AbstractDoctrineAnnotationFixer.php @@ -29,10 +29,7 @@ */ abstract class AbstractDoctrineAnnotationFixer extends AbstractFixer implements ConfigurableFixerInterface { - /** - * @var array - */ - private $classyElements; + private array $classyElements; /** * {@inheritdoc} diff --git a/src/AbstractPhpdocToTypeDeclarationFixer.php b/src/AbstractPhpdocToTypeDeclarationFixer.php index 57bb41806d4..1a2792f70f6 100644 --- a/src/AbstractPhpdocToTypeDeclarationFixer.php +++ b/src/AbstractPhpdocToTypeDeclarationFixer.php @@ -31,15 +31,12 @@ */ 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 */ - private $versionSpecificTypes = [ + private array $versionSpecificTypes = [ 'void' => 70100, 'iterable' => 70100, 'object' => 70200, @@ -49,7 +46,7 @@ abstract class AbstractPhpdocToTypeDeclarationFixer extends AbstractFixer implem /** * @var array */ - private $scalarTypes = [ + private array $scalarTypes = [ 'bool' => true, 'float' => true, 'int' => true, @@ -59,7 +56,7 @@ abstract class AbstractPhpdocToTypeDeclarationFixer extends AbstractFixer implem /** * @var array */ - private static $syntaxValidationCache = []; + private static array $syntaxValidationCache = []; /** * {@inheritdoc} @@ -202,7 +199,7 @@ protected function getCommonTypeFromAnnotation(Annotation $annotation, bool $isR 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; } diff --git a/src/Cache/Cache.php b/src/Cache/Cache.php index 28f1ee24447..f39c1f8ceef 100644 --- a/src/Cache/Cache.php +++ b/src/Cache/Cache.php @@ -21,15 +21,12 @@ */ final class Cache implements CacheInterface { - /** - * @var SignatureInterface - */ - private $signature; + private SignatureInterface $signature; /** * @var array */ - private $hashes = []; + private array $hashes = []; public function __construct(SignatureInterface $signature) { diff --git a/src/Cache/Directory.php b/src/Cache/Directory.php index cc9423ebb61..90882af0a08 100644 --- a/src/Cache/Directory.php +++ b/src/Cache/Directory.php @@ -21,10 +21,7 @@ */ final class Directory implements DirectoryInterface { - /** - * @var string - */ - private $directoryName; + private string $directoryName; public function __construct(string $directoryName) { diff --git a/src/Cache/FileCacheManager.php b/src/Cache/FileCacheManager.php index b2ac9dec131..8d91dae7b1e 100644 --- a/src/Cache/FileCacheManager.php +++ b/src/Cache/FileCacheManager.php @@ -32,30 +32,18 @@ */ 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, diff --git a/src/Cache/FileHandler.php b/src/Cache/FileHandler.php index 1a4727e0fe3..059e6b42671 100644 --- a/src/Cache/FileHandler.php +++ b/src/Cache/FileHandler.php @@ -23,10 +23,7 @@ */ final class FileHandler implements FileHandlerInterface { - /** - * @var string - */ - private $file; + private string $file; public function __construct(string $file) { diff --git a/src/Cache/Signature.php b/src/Cache/Signature.php index e7d17672d81..4ff463095bb 100644 --- a/src/Cache/Signature.php +++ b/src/Cache/Signature.php @@ -21,30 +21,15 @@ */ 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) { diff --git a/src/Config.php b/src/Config.php index ee59b26ed23..88948bfbe69 100644 --- a/src/Config.php +++ b/src/Config.php @@ -23,65 +23,38 @@ */ 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') { diff --git a/src/ConfigurationException/InvalidFixerConfigurationException.php b/src/ConfigurationException/InvalidFixerConfigurationException.php index 0750eee86a9..1419a248e25 100644 --- a/src/ConfigurationException/InvalidFixerConfigurationException.php +++ b/src/ConfigurationException/InvalidFixerConfigurationException.php @@ -24,10 +24,7 @@ */ 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 @@ public function __construct(string $fixerName, string $message, ?\Throwable $pre FixCommandExitStatusCalculator::EXIT_STATUS_FLAG_HAS_INVALID_FIXER_CONFIG, $previous ); + $this->fixerName = $fixerName; } diff --git a/src/Console/Application.php b/src/Console/Application.php index 525e3be2505..5b1851beadf 100644 --- a/src/Console/Application.php +++ b/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() { diff --git a/src/Console/Command/DescribeCommand.php b/src/Console/Command/DescribeCommand.php index 22ac8dadce6..07de38644c1 100644 --- a/src/Console/Command/DescribeCommand.php +++ b/src/Console/Command/DescribeCommand.php @@ -56,10 +56,7 @@ final class DescribeCommand extends Command */ private $setNames; - /** - * @var FixerFactory - */ - private $fixerFactory; + private FixerFactory $fixerFactory; /** * @var array diff --git a/src/Console/Command/DescribeNameNotFoundException.php b/src/Console/Command/DescribeNameNotFoundException.php index 8ddab2a308f..27f5bcfcaac 100644 --- a/src/Console/Command/DescribeNameNotFoundException.php +++ b/src/Console/Command/DescribeNameNotFoundException.php @@ -19,15 +19,12 @@ */ final class DescribeNameNotFoundException extends \InvalidArgumentException { - /** - * @var string - */ - private $name; + private string $name; /** - * @var string 'rule'|'set' + * 'rule'|'set'. */ - private $type; + private string $type; public function __construct(string $name, string $type) { diff --git a/src/Console/Command/FixCommand.php b/src/Console/Command/FixCommand.php index 62c0778bbcb..c3619b4e8f3 100644 --- a/src/Console/Command/FixCommand.php +++ b/src/Console/Command/FixCommand.php @@ -49,39 +49,24 @@ final class FixCommand extends Command */ protected static $defaultName = 'fix'; - /** - * @var EventDispatcherInterface - */ - private $eventDispatcher; + private EventDispatcherInterface $eventDispatcher; - /** - * @var ErrorsManager - */ - private $errorsManager; + private ErrorsManager $errorsManager; - /** - * @var Stopwatch - */ - private $stopwatch; + private Stopwatch $stopwatch; - /** - * @var ConfigInterface - */ - private $defaultConfig; + private ConfigInterface $defaultConfig; - /** - * @var ToolInfoInterface - */ - private $toolInfo; + private ToolInfoInterface $toolInfo; public function __construct(ToolInfoInterface $toolInfo) { parent::__construct(); - $this->defaultConfig = new Config(); - $this->errorsManager = new ErrorsManager(); $this->eventDispatcher = new EventDispatcher(); + $this->errorsManager = new ErrorsManager(); $this->stopwatch = new Stopwatch(); + $this->defaultConfig = new Config(); $this->toolInfo = $toolInfo; } diff --git a/src/Console/Command/ListFilesCommand.php b/src/Console/Command/ListFilesCommand.php index f88707ceee3..fe21ecea1cb 100644 --- a/src/Console/Command/ListFilesCommand.php +++ b/src/Console/Command/ListFilesCommand.php @@ -36,15 +36,9 @@ final class ListFilesCommand extends Command */ protected static $defaultName = 'list-files'; - /** - * @var ConfigInterface - */ - private $defaultConfig; + private ConfigInterface $defaultConfig; - /** - * @var ToolInfoInterface - */ - private $toolInfo; + private ToolInfoInterface $toolInfo; public function __construct(ToolInfoInterface $toolInfo) { diff --git a/src/Console/Command/SelfUpdateCommand.php b/src/Console/Command/SelfUpdateCommand.php index 6e3eb84285a..9a3efd6ed47 100644 --- a/src/Console/Command/SelfUpdateCommand.php +++ b/src/Console/Command/SelfUpdateCommand.php @@ -39,20 +39,11 @@ final class SelfUpdateCommand extends Command */ protected static $defaultName = 'self-update'; - /** - * @var NewVersionCheckerInterface - */ - private $versionChecker; + private NewVersionCheckerInterface $versionChecker; - /** - * @var ToolInfoInterface - */ - private $toolInfo; + private ToolInfoInterface $toolInfo; - /** - * @var PharCheckerInterface - */ - private $pharChecker; + private PharCheckerInterface $pharChecker; public function __construct( NewVersionCheckerInterface $versionChecker, diff --git a/src/Console/ConfigurationResolver.php b/src/Console/ConfigurationResolver.php index 3fe44f9520f..d2ad67e8be1 100644 --- a/src/Console/ConfigurationResolver.php +++ b/src/Console/ConfigurationResolver.php @@ -80,10 +80,7 @@ final class ConfigurationResolver */ private $cwd; - /** - * @var ConfigInterface - */ - private $defaultConfig; + private ConfigInterface $defaultConfig; /** * @var null|ReporterInterface @@ -110,15 +107,9 @@ final class ConfigurationResolver */ private $configFinderIsOverridden; - /** - * @var ToolInfoInterface - */ - private $toolInfo; + private ToolInfoInterface $toolInfo; - /** - * @var array - */ - private $options = [ + private array $options = [ 'allow-risky' => null, 'cache-file' => null, 'config' => null, @@ -194,8 +185,8 @@ public function __construct( string $cwd, ToolInfoInterface $toolInfo ) { - $this->cwd = $cwd; $this->defaultConfig = $config; + $this->cwd = $cwd; $this->toolInfo = $toolInfo; foreach ($options as $name => $value) { diff --git a/src/Console/Output/ErrorOutput.php b/src/Console/Output/ErrorOutput.php index 3d716364342..3e0efdaf74f 100644 --- a/src/Console/Output/ErrorOutput.php +++ b/src/Console/Output/ErrorOutput.php @@ -25,10 +25,7 @@ */ final class ErrorOutput { - /** - * @var OutputInterface - */ - private $output; + private OutputInterface $output; /** * @var bool diff --git a/src/Console/Output/ProcessOutput.php b/src/Console/Output/ProcessOutput.php index be662e30f82..6ca9d2760f5 100644 --- a/src/Console/Output/ProcessOutput.php +++ b/src/Console/Output/ProcessOutput.php @@ -27,10 +27,8 @@ final class ProcessOutput implements ProcessOutputInterface { /** * File statuses map. - * - * @var array */ - private static $eventStatusMap = [ + private static array $eventStatusMap = [ FixerFileProcessedEvent::STATUS_UNKNOWN => ['symbol' => '?', 'format' => '%s', 'description' => 'unknown'], FixerFileProcessedEvent::STATUS_INVALID => ['symbol' => 'I', 'format' => '%s', 'description' => 'invalid file syntax (file ignored)'], FixerFileProcessedEvent::STATUS_SKIPPED => ['symbol' => 'S', 'format' => '%s', 'description' => 'skipped (cached or empty file)'], @@ -40,25 +38,13 @@ final class ProcessOutput implements ProcessOutputInterface FixerFileProcessedEvent::STATUS_LINT => ['symbol' => 'E', 'format' => '%s', 'description' => 'error'], ]; - /** - * @var EventDispatcherInterface - */ - private $eventDispatcher; + private OutputInterface $output; - /** - * @var OutputInterface - */ - private $output; + private EventDispatcherInterface $eventDispatcher; - /** - * @var int - */ - private $files; + private int $files; - /** - * @var int - */ - private $processedFiles = 0; + private int $processedFiles = 0; /** * @var int diff --git a/src/Console/Report/FixReport/ReportSummary.php b/src/Console/Report/FixReport/ReportSummary.php index d9b1aefcc26..3c48a0628e2 100644 --- a/src/Console/Report/FixReport/ReportSummary.php +++ b/src/Console/Report/FixReport/ReportSummary.php @@ -21,35 +21,17 @@ */ final class ReportSummary { - /** - * @var bool - */ - private $addAppliedFixers; + private array $changed; - /** - * @var array - */ - private $changed; + private int $time; - /** - * @var bool - */ - private $isDecoratedOutput; + private int $memory; - /** - * @var bool - */ - private $isDryRun; + private bool $addAppliedFixers; - /** - * @var int - */ - private $memory; + private bool $isDryRun; - /** - * @var int - */ - private $time; + private bool $isDecoratedOutput; /** * @param int $time duration in milliseconds diff --git a/src/Console/Report/FixReport/ReporterFactory.php b/src/Console/Report/FixReport/ReporterFactory.php index b7ab998c33a..5ffcb5ad04b 100644 --- a/src/Console/Report/FixReport/ReporterFactory.php +++ b/src/Console/Report/FixReport/ReporterFactory.php @@ -24,8 +24,10 @@ */ final class ReporterFactory { - /** @var ReporterInterface[] */ - private $reporters = []; + /** + * @var ReporterInterface[] + */ + private array $reporters = []; public function registerBuiltInReporters(): self { diff --git a/src/Console/Report/ListSetsReport/ReportSummary.php b/src/Console/Report/ListSetsReport/ReportSummary.php index 351bdd47d97..6ca98d9a41e 100644 --- a/src/Console/Report/ListSetsReport/ReportSummary.php +++ b/src/Console/Report/ListSetsReport/ReportSummary.php @@ -26,14 +26,13 @@ final class ReportSummary /** * @var RuleSetDescriptionInterface[] */ - private $sets; + private array $sets; /** * @param RuleSetDescriptionInterface[] $sets */ - public function __construct( - array $sets - ) { + public function __construct(array $sets) + { $this->sets = $sets; } diff --git a/src/Console/Report/ListSetsReport/ReporterFactory.php b/src/Console/Report/ListSetsReport/ReporterFactory.php index 5e2f277515a..abf211e9544 100644 --- a/src/Console/Report/ListSetsReport/ReporterFactory.php +++ b/src/Console/Report/ListSetsReport/ReporterFactory.php @@ -24,8 +24,10 @@ */ final class ReporterFactory { - /** @var ReporterInterface[] */ - private $reporters = []; + /** + * @var ReporterInterface[] + */ + private array $reporters = []; public function registerBuiltInReporters(): self { diff --git a/src/Console/SelfUpdate/NewVersionChecker.php b/src/Console/SelfUpdate/NewVersionChecker.php index 510ecb85675..54ec34ddbe3 100644 --- a/src/Console/SelfUpdate/NewVersionChecker.php +++ b/src/Console/SelfUpdate/NewVersionChecker.php @@ -23,15 +23,9 @@ */ final class NewVersionChecker implements NewVersionCheckerInterface { - /** - * @var GithubClientInterface - */ - private $githubClient; + private GithubClientInterface $githubClient; - /** - * @var VersionParser - */ - private $versionParser; + private VersionParser $versionParser; /** * @var null|string[] diff --git a/src/Console/WarningsDetector.php b/src/Console/WarningsDetector.php index 7ef568c77bf..85ac917934e 100644 --- a/src/Console/WarningsDetector.php +++ b/src/Console/WarningsDetector.php @@ -24,15 +24,12 @@ */ final class WarningsDetector { - /** - * @var ToolInfoInterface - */ - private $toolInfo; + private ToolInfoInterface $toolInfo; /** * @var string[] */ - private $warnings = []; + private array $warnings = []; public function __construct(ToolInfoInterface $toolInfo) { diff --git a/src/Differ/DiffConsoleFormatter.php b/src/Differ/DiffConsoleFormatter.php index e9b97f22435..f52ed44a74a 100644 --- a/src/Differ/DiffConsoleFormatter.php +++ b/src/Differ/DiffConsoleFormatter.php @@ -24,15 +24,9 @@ */ final class DiffConsoleFormatter { - /** - * @var bool - */ - private $isDecoratedOutput; + private bool $isDecoratedOutput; - /** - * @var string - */ - private $template; + private string $template; public function __construct(bool $isDecoratedOutput, string $template = '%s') { diff --git a/src/Differ/FullDiffer.php b/src/Differ/FullDiffer.php index 94f71c720f4..ee5d738fe47 100644 --- a/src/Differ/FullDiffer.php +++ b/src/Differ/FullDiffer.php @@ -24,10 +24,7 @@ */ final class FullDiffer implements DifferInterface { - /** - * @var Differ - */ - private $differ; + private Differ $differ; public function __construct() { diff --git a/src/DocBlock/Annotation.php b/src/DocBlock/Annotation.php index bfdc14c479c..f0d322bd4cd 100644 --- a/src/DocBlock/Annotation.php +++ b/src/DocBlock/Annotation.php @@ -31,7 +31,7 @@ final class Annotation * * @var string[] */ - private static $tags = [ + private static array $tags = [ 'method', 'param', 'property', @@ -93,7 +93,7 @@ final class Annotation /** * @var NamespaceUseAnalysis[] */ - private $namespaceUses; + private array $namespaceUses; /** * Create a new line instance. diff --git a/src/DocBlock/DocBlock.php b/src/DocBlock/DocBlock.php index b62c9caeeda..efdcff32da7 100644 --- a/src/DocBlock/DocBlock.php +++ b/src/DocBlock/DocBlock.php @@ -32,7 +32,7 @@ final class DocBlock * * @var Line[] */ - private $lines = []; + private array $lines = []; /** * The array of annotations. @@ -49,7 +49,7 @@ final class DocBlock /** * @var NamespaceUseAnalysis[] */ - private $namespaceUses; + private array $namespaceUses; public function __construct(string $content, ?NamespaceAnalysis $namespace = null, array $namespaceUses = []) { diff --git a/src/DocBlock/Line.php b/src/DocBlock/Line.php index 3c6a349341b..0db50e82848 100644 --- a/src/DocBlock/Line.php +++ b/src/DocBlock/Line.php @@ -25,10 +25,8 @@ final class Line { /** * The content of this line. - * - * @var string */ - private $content; + private string $content; /** * Create a new line instance. diff --git a/src/DocBlock/ShortDescription.php b/src/DocBlock/ShortDescription.php index eeb71f3280a..dbd9e5dada2 100644 --- a/src/DocBlock/ShortDescription.php +++ b/src/DocBlock/ShortDescription.php @@ -23,10 +23,8 @@ final class ShortDescription { /** * The docblock containing the short description. - * - * @var DocBlock */ - private $doc; + private DocBlock $doc; public function __construct(DocBlock $doc) { diff --git a/src/DocBlock/Tag.php b/src/DocBlock/Tag.php index f06522b9d97..988c19b7138 100644 --- a/src/DocBlock/Tag.php +++ b/src/DocBlock/Tag.php @@ -28,7 +28,7 @@ final class Tag * * @var string[] */ - private static $tags = [ + private static array $tags = [ 'api', 'author', 'category', 'copyright', 'deprecated', 'example', 'global', 'internal', 'license', 'link', 'method', 'package', 'param', 'property', 'property-read', 'property-write', 'return', 'see', @@ -37,10 +37,8 @@ final class Tag /** * The line containing the tag. - * - * @var Line */ - private $line; + private Line $line; /** * The cached tag name. diff --git a/src/DocBlock/TagComparator.php b/src/DocBlock/TagComparator.php index d0e7c874430..2f414519815 100644 --- a/src/DocBlock/TagComparator.php +++ b/src/DocBlock/TagComparator.php @@ -24,10 +24,8 @@ final class TagComparator { /** * Groups of tags that should be allowed to immediately follow each other. - * - * @var array */ - private static $groups = [ + private static array $groups = [ ['deprecated', 'link', 'see', 'since'], ['author', 'copyright', 'license'], ['category', 'package', 'subpackage'], diff --git a/src/DocBlock/TypeExpression.php b/src/DocBlock/TypeExpression.php index d3b21d1074b..be4e7b37195 100644 --- a/src/DocBlock/TypeExpression.php +++ b/src/DocBlock/TypeExpression.php @@ -110,15 +110,12 @@ final class TypeExpression */ private $value; - /** - * @var bool - */ - private $isUnionType = false; + private bool $isUnionType = false; /** * @var list */ - private $innerTypeExpressions = []; + private array $innerTypeExpressions = []; private string $typesGlue = '|'; diff --git a/src/Doctrine/Annotation/Token.php b/src/Doctrine/Annotation/Token.php index 91340678423..4e5a4a5db8d 100644 --- a/src/Doctrine/Annotation/Token.php +++ b/src/Doctrine/Annotation/Token.php @@ -23,15 +23,9 @@ */ final class Token { - /** - * @var int - */ - private $type; + private int $type; - /** - * @var string - */ - private $content; + private string $content; /** * @param int $type The type diff --git a/src/Documentation/FixerDocumentGenerator.php b/src/Documentation/FixerDocumentGenerator.php index b1aecf54d48..4de98f4bba5 100644 --- a/src/Documentation/FixerDocumentGenerator.php +++ b/src/Documentation/FixerDocumentGenerator.php @@ -37,15 +37,9 @@ */ final class FixerDocumentGenerator { - /** - * @var DocumentationLocator - */ - private $locator; + private DocumentationLocator $locator; - /** - * @var FullDiffer - */ - private $differ; + private FullDiffer $differ; public function __construct(DocumentationLocator $locator) { diff --git a/src/Documentation/ListDocumentGenerator.php b/src/Documentation/ListDocumentGenerator.php index b5da8e1775e..be5375d53dd 100644 --- a/src/Documentation/ListDocumentGenerator.php +++ b/src/Documentation/ListDocumentGenerator.php @@ -30,10 +30,7 @@ */ final class ListDocumentGenerator { - /** - * @var DocumentationLocator - */ - private $locator; + private DocumentationLocator $locator; public function __construct(DocumentationLocator $locator) { diff --git a/src/Documentation/RuleSetDocumentationGenerator.php b/src/Documentation/RuleSetDocumentationGenerator.php index 0aed34affe5..81b879400e3 100644 --- a/src/Documentation/RuleSetDocumentationGenerator.php +++ b/src/Documentation/RuleSetDocumentationGenerator.php @@ -24,10 +24,7 @@ */ final class RuleSetDocumentationGenerator { - /** - * @var DocumentationLocator - */ - private $locator; + private DocumentationLocator $locator; public function __construct(DocumentationLocator $locator) { diff --git a/src/Error/Error.php b/src/Error/Error.php index f4e30a198a1..b2ad97dfc4b 100644 --- a/src/Error/Error.php +++ b/src/Error/Error.php @@ -38,25 +38,16 @@ final class Error */ public const TYPE_LINT = 3; - /** - * @var int - */ - private $type; + private int $type; - /** - * @var string - */ - private $filePath; + private string $filePath; /** * @var null|\Throwable */ private $source; - /** - * @var array - */ - private $appliedFixers; + private array $appliedFixers; /** * @var null|string diff --git a/src/Error/ErrorsManager.php b/src/Error/ErrorsManager.php index 2d70a3e6d63..01006673a89 100644 --- a/src/Error/ErrorsManager.php +++ b/src/Error/ErrorsManager.php @@ -26,7 +26,7 @@ final class ErrorsManager /** * @var Error[] */ - private $errors = []; + private array $errors = []; /** * Returns errors reported during linting before fixing. diff --git a/src/FileRemoval.php b/src/FileRemoval.php index 6264d3b67c2..f3fd7f8ee90 100644 --- a/src/FileRemoval.php +++ b/src/FileRemoval.php @@ -26,10 +26,8 @@ final class FileRemoval { /** * List of observed files to be removed. - * - * @var array */ - private $files = []; + private array $files = []; public function __construct() { @@ -77,6 +75,7 @@ public function delete(string $path): void if (isset($this->files[$path])) { unset($this->files[$path]); } + $this->unlink($path); } @@ -88,6 +87,7 @@ public function clean(): void foreach ($this->files as $file => $value) { $this->unlink($file); } + $this->files = []; } diff --git a/src/Fixer/Alias/EregToPregFixer.php b/src/Fixer/Alias/EregToPregFixer.php index 21d44f8dedd..a0ca7197df1 100644 --- a/src/Fixer/Alias/EregToPregFixer.php +++ b/src/Fixer/Alias/EregToPregFixer.php @@ -33,7 +33,7 @@ final class EregToPregFixer extends AbstractFixer * @var array the list of the ext/ereg function names, their preg equivalent and the preg modifier(s), if any * all condensed in an array of arrays */ - private static $functions = [ + private static array $functions = [ ['ereg', 'preg_match', ''], ['eregi', 'preg_match', 'i'], ['ereg_replace', 'preg_replace', ''], @@ -45,7 +45,7 @@ final class EregToPregFixer extends AbstractFixer /** * @var array the list of preg delimiters, in order of preference */ - private static $delimiters = ['/', '#', '!']; + private static array $delimiters = ['/', '#', '!']; /** * {@inheritdoc} diff --git a/src/Fixer/Alias/MbStrFunctionsFixer.php b/src/Fixer/Alias/MbStrFunctionsFixer.php index 17c5fd897e9..d496975559e 100644 --- a/src/Fixer/Alias/MbStrFunctionsFixer.php +++ b/src/Fixer/Alias/MbStrFunctionsFixer.php @@ -30,7 +30,7 @@ final class MbStrFunctionsFixer extends AbstractFunctionReferenceFixer /** * @var array the list of the string-related function names and their mb_ equivalent */ - private static $functionsMap = [ + private static array $functionsMap = [ 'str_split' => ['alternativeName' => 'mb_str_split', 'argumentCount' => [1, 2, 3]], 'stripos' => ['alternativeName' => 'mb_stripos', 'argumentCount' => [2, 3]], 'stristr' => ['alternativeName' => 'mb_stristr', 'argumentCount' => [2, 3]], diff --git a/src/Fixer/Alias/NoAliasFunctionsFixer.php b/src/Fixer/Alias/NoAliasFunctionsFixer.php index d67e7786725..bf6fb579f47 100644 --- a/src/Fixer/Alias/NoAliasFunctionsFixer.php +++ b/src/Fixer/Alias/NoAliasFunctionsFixer.php @@ -155,8 +155,10 @@ final class NoAliasFunctionsFixer extends AbstractFixer implements ConfigurableF ], ]; - /** @var array|string> stores alias (key) - master (value) functions mapping */ - private $aliases = []; + /** + * @var array|string> stores alias (key) - master (value) functions mapping + */ + private array $aliases = []; public function configure(array $configuration): void { diff --git a/src/Fixer/Alias/RandomApiMigrationFixer.php b/src/Fixer/Alias/RandomApiMigrationFixer.php index 282d878888b..c8049913212 100644 --- a/src/Fixer/Alias/RandomApiMigrationFixer.php +++ b/src/Fixer/Alias/RandomApiMigrationFixer.php @@ -32,10 +32,7 @@ */ final class RandomApiMigrationFixer extends AbstractFunctionReferenceFixer implements ConfigurableFixerInterface { - /** - * @var array - */ - private static $argumentCounts = [ + private static array $argumentCounts = [ 'getrandmax' => [0], 'mt_rand' => [1, 2], 'rand' => [0, 2], diff --git a/src/Fixer/Basic/NonPrintableCharacterFixer.php b/src/Fixer/Basic/NonPrintableCharacterFixer.php index c7cbb18495f..953e709c402 100644 --- a/src/Fixer/Basic/NonPrintableCharacterFixer.php +++ b/src/Fixer/Basic/NonPrintableCharacterFixer.php @@ -36,12 +36,12 @@ final class NonPrintableCharacterFixer extends AbstractFixer implements Configur /** * @var array */ - private $symbolsReplace; + private array $symbolsReplace; /** * @var int[] */ - private static $tokens = [ + private static array $tokens = [ T_STRING_VARNAME, T_INLINE_HTML, T_VARIABLE, diff --git a/src/Fixer/Casing/LowercaseKeywordsFixer.php b/src/Fixer/Casing/LowercaseKeywordsFixer.php index 9edd6d0e7dd..304b10aa7f6 100644 --- a/src/Fixer/Casing/LowercaseKeywordsFixer.php +++ b/src/Fixer/Casing/LowercaseKeywordsFixer.php @@ -31,7 +31,7 @@ final class LowercaseKeywordsFixer extends AbstractFixer /** * @var int[] */ - private static $excludedTokens = [T_HALT_COMPILER]; + private static array $excludedTokens = [T_HALT_COMPILER]; /** * {@inheritdoc} diff --git a/src/Fixer/Casing/MagicMethodCasingFixer.php b/src/Fixer/Casing/MagicMethodCasingFixer.php index c9d4f914624..9179845fdf4 100644 --- a/src/Fixer/Casing/MagicMethodCasingFixer.php +++ b/src/Fixer/Casing/MagicMethodCasingFixer.php @@ -26,7 +26,7 @@ final class MagicMethodCasingFixer extends AbstractFixer /** * @var array */ - private static $magicNames = [ + private static array $magicNames = [ '__call' => '__call', '__callstatic' => '__callStatic', '__clone' => '__clone', diff --git a/src/Fixer/Casing/NativeFunctionTypeDeclarationCasingFixer.php b/src/Fixer/Casing/NativeFunctionTypeDeclarationCasingFixer.php index e36d96cf653..070a68e5296 100644 --- a/src/Fixer/Casing/NativeFunctionTypeDeclarationCasingFixer.php +++ b/src/Fixer/Casing/NativeFunctionTypeDeclarationCasingFixer.php @@ -46,12 +46,9 @@ final class NativeFunctionTypeDeclarationCasingFixer extends AbstractFixer * * @var array */ - private $hints; + private array $hints; - /** - * @var FunctionsAnalyzer - */ - private $functionsAnalyzer; + private FunctionsAnalyzer $functionsAnalyzer; public function __construct() { diff --git a/src/Fixer/ClassNotation/ClassAttributesSeparationFixer.php b/src/Fixer/ClassNotation/ClassAttributesSeparationFixer.php index 61a1a42e1ff..735f1fe75f8 100644 --- a/src/Fixer/ClassNotation/ClassAttributesSeparationFixer.php +++ b/src/Fixer/ClassNotation/ClassAttributesSeparationFixer.php @@ -54,7 +54,7 @@ final class ClassAttributesSeparationFixer extends AbstractFixer implements Conf /** * @var array */ - private $classElementTypes = []; + private array $classElementTypes = []; /** * {@inheritdoc} diff --git a/src/Fixer/ClassNotation/FinalPublicMethodForAbstractClassFixer.php b/src/Fixer/ClassNotation/FinalPublicMethodForAbstractClassFixer.php index e25dd001281..c13c69db880 100644 --- a/src/Fixer/ClassNotation/FinalPublicMethodForAbstractClassFixer.php +++ b/src/Fixer/ClassNotation/FinalPublicMethodForAbstractClassFixer.php @@ -26,10 +26,7 @@ */ final class FinalPublicMethodForAbstractClassFixer extends AbstractFixer { - /** - * @var array - */ - private $magicMethods = [ + private array $magicMethods = [ '__construct' => true, '__destruct' => true, '__call' => true, diff --git a/src/Fixer/ClassNotation/OrderedClassElementsFixer.php b/src/Fixer/ClassNotation/OrderedClassElementsFixer.php index 1f1480d64d5..b62bea3fed8 100644 --- a/src/Fixer/ClassNotation/OrderedClassElementsFixer.php +++ b/src/Fixer/ClassNotation/OrderedClassElementsFixer.php @@ -46,7 +46,7 @@ final class OrderedClassElementsFixer extends AbstractFixer implements Configura /** * @var array Array containing all class element base types (keys) and their parent types (values) */ - private static $typeHierarchy = [ + private static array $typeHierarchy = [ 'use_trait' => null, 'public' => null, 'protected' => null, @@ -86,7 +86,7 @@ final class OrderedClassElementsFixer extends AbstractFixer implements Configura /** * @var array Array containing special method types */ - private static $specialTypes = [ + private static array $specialTypes = [ 'construct' => null, 'destruct' => null, 'magic' => null, diff --git a/src/Fixer/Comment/CommentToPhpdocFixer.php b/src/Fixer/Comment/CommentToPhpdocFixer.php index 9d5df5a131a..c28b8891a7f 100644 --- a/src/Fixer/Comment/CommentToPhpdocFixer.php +++ b/src/Fixer/Comment/CommentToPhpdocFixer.php @@ -37,7 +37,7 @@ final class CommentToPhpdocFixer extends AbstractFixer implements ConfigurableFi /** * @var string[] */ - private $ignoredTags = []; + private array $ignoredTags = []; /** * {@inheritdoc} diff --git a/src/Fixer/ConstantNotation/NativeConstantInvocationFixer.php b/src/Fixer/ConstantNotation/NativeConstantInvocationFixer.php index 959ef0f1b36..d14f7f5a1bd 100644 --- a/src/Fixer/ConstantNotation/NativeConstantInvocationFixer.php +++ b/src/Fixer/ConstantNotation/NativeConstantInvocationFixer.php @@ -38,12 +38,12 @@ final class NativeConstantInvocationFixer extends AbstractFixer implements Confi /** * @var array */ - private $constantsToEscape = []; + private array $constantsToEscape = []; /** * @var array */ - private $caseInsensitiveConstantsToEscape = []; + private array $caseInsensitiveConstantsToEscape = []; /** * {@inheritdoc} diff --git a/src/Fixer/ControlStructure/NoUnneededControlParenthesesFixer.php b/src/Fixer/ControlStructure/NoUnneededControlParenthesesFixer.php index 800dc7e5ebb..b705105d6bd 100644 --- a/src/Fixer/ControlStructure/NoUnneededControlParenthesesFixer.php +++ b/src/Fixer/ControlStructure/NoUnneededControlParenthesesFixer.php @@ -34,10 +34,7 @@ */ final class NoUnneededControlParenthesesFixer extends AbstractFixer implements ConfigurableFixerInterface { - /** - * @var array - */ - private static $loops = [ + private static array $loops = [ 'break' => ['lookupTokens' => T_BREAK, 'neededSuccessors' => [';']], 'clone' => ['lookupTokens' => T_CLONE, 'neededSuccessors' => [';', ':', ',', ')'], 'forbiddenContents' => ['?', ':', [T_COALESCE, '??']]], 'continue' => ['lookupTokens' => T_CONTINUE, 'neededSuccessors' => [';']], diff --git a/src/Fixer/ControlStructure/SimplifiedIfReturnFixer.php b/src/Fixer/ControlStructure/SimplifiedIfReturnFixer.php index 155453c3f3b..30d02673e61 100644 --- a/src/Fixer/ControlStructure/SimplifiedIfReturnFixer.php +++ b/src/Fixer/ControlStructure/SimplifiedIfReturnFixer.php @@ -29,7 +29,7 @@ final class SimplifiedIfReturnFixer extends AbstractFixer /** * @var array[] */ - private $sequences = [ + private array $sequences = [ [ 'isNegative' => false, 'sequence' => [ diff --git a/src/Fixer/ControlStructure/SwitchContinueToBreakFixer.php b/src/Fixer/ControlStructure/SwitchContinueToBreakFixer.php index 4ee70479588..22ce3c17916 100644 --- a/src/Fixer/ControlStructure/SwitchContinueToBreakFixer.php +++ b/src/Fixer/ControlStructure/SwitchContinueToBreakFixer.php @@ -27,7 +27,7 @@ final class SwitchContinueToBreakFixer extends AbstractFixer /** * @var int[] */ - private $switchLevels = []; + private array $switchLevels = []; /** * {@inheritdoc} diff --git a/src/Fixer/FunctionNotation/PhpdocToPropertyTypeFixer.php b/src/Fixer/FunctionNotation/PhpdocToPropertyTypeFixer.php index b7cde6f9662..db3c812ac0f 100644 --- a/src/Fixer/FunctionNotation/PhpdocToPropertyTypeFixer.php +++ b/src/Fixer/FunctionNotation/PhpdocToPropertyTypeFixer.php @@ -28,7 +28,7 @@ final class PhpdocToPropertyTypeFixer extends AbstractPhpdocToTypeDeclarationFix /** * @var array */ - private $skippedTypes = [ + private array $skippedTypes = [ 'mixed' => true, 'resource' => true, 'null' => true, diff --git a/src/Fixer/FunctionNotation/PhpdocToReturnTypeFixer.php b/src/Fixer/FunctionNotation/PhpdocToReturnTypeFixer.php index 5b316b49260..b11d07e7b50 100644 --- a/src/Fixer/FunctionNotation/PhpdocToReturnTypeFixer.php +++ b/src/Fixer/FunctionNotation/PhpdocToReturnTypeFixer.php @@ -32,7 +32,7 @@ final class PhpdocToReturnTypeFixer extends AbstractPhpdocToTypeDeclarationFixer /** * @var array> */ - private $excludeFuncNames = [ + private array $excludeFuncNames = [ [T_STRING, '__construct'], [T_STRING, '__destruct'], [T_STRING, '__clone'], @@ -41,7 +41,7 @@ final class PhpdocToReturnTypeFixer extends AbstractPhpdocToTypeDeclarationFixer /** * @var array */ - private $skippedTypes = [ + private array $skippedTypes = [ 'mixed' => true, 'resource' => true, 'null' => true, diff --git a/src/Fixer/LanguageConstruct/ClassKeywordRemoveFixer.php b/src/Fixer/LanguageConstruct/ClassKeywordRemoveFixer.php index 23b2b48142b..491aa89fc5f 100644 --- a/src/Fixer/LanguageConstruct/ClassKeywordRemoveFixer.php +++ b/src/Fixer/LanguageConstruct/ClassKeywordRemoveFixer.php @@ -35,7 +35,7 @@ final class ClassKeywordRemoveFixer extends AbstractFixer implements DeprecatedF /** * @var string[] */ - private $imports = []; + private array $imports = []; /** * {@inheritdoc} diff --git a/src/Fixer/LanguageConstruct/SingleSpaceAfterConstructFixer.php b/src/Fixer/LanguageConstruct/SingleSpaceAfterConstructFixer.php index 92b25baea43..030eb9aa214 100644 --- a/src/Fixer/LanguageConstruct/SingleSpaceAfterConstructFixer.php +++ b/src/Fixer/LanguageConstruct/SingleSpaceAfterConstructFixer.php @@ -36,7 +36,7 @@ final class SingleSpaceAfterConstructFixer extends AbstractFixer implements Conf /** * @var array */ - private static $tokenMap = [ + private static array $tokenMap = [ 'abstract' => T_ABSTRACT, 'as' => T_AS, 'attribute' => CT::T_ATTRIBUTE_CLOSE, @@ -102,7 +102,7 @@ final class SingleSpaceAfterConstructFixer extends AbstractFixer implements Conf /** * @var array */ - private $fixTokenMap = []; + private array $fixTokenMap = []; /** * {@inheritdoc} diff --git a/src/Fixer/Naming/NoHomoglyphNamesFixer.php b/src/Fixer/Naming/NoHomoglyphNamesFixer.php index 40a40aa4f12..ae4cfb29e8a 100644 --- a/src/Fixer/Naming/NoHomoglyphNamesFixer.php +++ b/src/Fixer/Naming/NoHomoglyphNamesFixer.php @@ -45,10 +45,8 @@ final class NoHomoglyphNamesFixer extends AbstractFixer * * This is not the complete list of unicode homographs, but limited * to those you are more likely to have typed/copied by accident - * - * @var array */ - private static $replacements = [ + private static array $replacements = [ 'O' => '0', '0' => '0', 'I' => '1', diff --git a/src/Fixer/Operator/BinaryOperatorSpacesFixer.php b/src/Fixer/Operator/BinaryOperatorSpacesFixer.php index 3aad82bd97e..dd0e3ac52fd 100644 --- a/src/Fixer/Operator/BinaryOperatorSpacesFixer.php +++ b/src/Fixer/Operator/BinaryOperatorSpacesFixer.php @@ -117,24 +117,20 @@ final class BinaryOperatorSpacesFixer extends AbstractFixer implements Configura * Keep track of the deepest level ever achieved while * parsing the code. Used later to replace alignment * placeholders with spaces. - * - * @var int */ - private $deepestLevel; + private int $deepestLevel; /** * Level counter of the current nest level. * So one level alignments are not mixed with * other level ones. - * - * @var int */ - private $currentLevel; + private int $currentLevel; /** * @var array */ - private static $allowedValues = [ + private static array $allowedValues = [ self::ALIGN, self::ALIGN_SINGLE_SPACE, self::ALIGN_SINGLE_SPACE_MINIMAL, @@ -143,20 +139,17 @@ final class BinaryOperatorSpacesFixer extends AbstractFixer implements Configura null, ]; - /** - * @var TokensAnalyzer - */ - private $tokensAnalyzer; + private TokensAnalyzer $tokensAnalyzer; /** * @var array */ - private $alignOperatorTokens = []; + private array $alignOperatorTokens = []; /** * @var array */ - private $operators = []; + private array $operators = []; /** * {@inheritdoc} @@ -526,10 +519,7 @@ private function fixAlignment(Tokens $tokens, array $toAlign): void private function injectAlignmentPlaceholders(Tokens $tokens, int $startAt, int $endAt, string $tokenContent): void { - $functionKind = [T_FUNCTION]; - if (\PHP_VERSION_ID >= 70400) { - $functionKind[] = T_FN; - } + $functionKind = [T_FUNCTION, T_FN]; for ($index = $startAt; $index < $endAt; ++$index) { $token = $tokens[$index]; diff --git a/src/Fixer/Operator/OperatorLinebreakFixer.php b/src/Fixer/Operator/OperatorLinebreakFixer.php index 73a3e64506f..a5f8a687939 100644 --- a/src/Fixer/Operator/OperatorLinebreakFixer.php +++ b/src/Fixer/Operator/OperatorLinebreakFixer.php @@ -38,15 +38,12 @@ final class OperatorLinebreakFixer extends AbstractFixer implements Configurable { private const BOOLEAN_OPERATORS = [[T_BOOLEAN_AND], [T_BOOLEAN_OR], [T_LOGICAL_AND], [T_LOGICAL_OR], [T_LOGICAL_XOR]]; - /** - * @var string - */ - private $position = 'beginning'; + private string $position = 'beginning'; /** * @var array|string> */ - private $operators = []; + private array $operators = []; /** * {@inheritdoc} diff --git a/src/Fixer/PhpUnit/PhpUnitConstructFixer.php b/src/Fixer/PhpUnit/PhpUnitConstructFixer.php index 08916229b5f..104f97d76de 100644 --- a/src/Fixer/PhpUnit/PhpUnitConstructFixer.php +++ b/src/Fixer/PhpUnit/PhpUnitConstructFixer.php @@ -35,7 +35,7 @@ final class PhpUnitConstructFixer extends AbstractPhpUnitFixer implements Config /** * @var array */ - private static $assertionFixers = [ + private static array $assertionFixers = [ 'assertSame' => 'fixAssertPositive', 'assertEquals' => 'fixAssertPositive', 'assertNotEquals' => 'fixAssertNegative', diff --git a/src/Fixer/PhpUnit/PhpUnitDedicateAssertFixer.php b/src/Fixer/PhpUnit/PhpUnitDedicateAssertFixer.php index 96ccb832bca..25bbaf9d058 100644 --- a/src/Fixer/PhpUnit/PhpUnitDedicateAssertFixer.php +++ b/src/Fixer/PhpUnit/PhpUnitDedicateAssertFixer.php @@ -35,7 +35,7 @@ final class PhpUnitDedicateAssertFixer extends AbstractPhpUnitFixer implements C /** * @var array */ - private static $fixMap = [ + private static array $fixMap = [ 'array_key_exists' => [ 'positive' => 'assertArrayHasKey', 'negative' => 'assertArrayNotHasKey', @@ -110,7 +110,7 @@ final class PhpUnitDedicateAssertFixer extends AbstractPhpUnitFixer implements C /** * @var string[] */ - private $functions = []; + private array $functions = []; /** * {@inheritdoc} diff --git a/src/Fixer/PhpUnit/PhpUnitDedicateAssertInternalTypeFixer.php b/src/Fixer/PhpUnit/PhpUnitDedicateAssertInternalTypeFixer.php index e8365c4b23f..e960653f793 100644 --- a/src/Fixer/PhpUnit/PhpUnitDedicateAssertInternalTypeFixer.php +++ b/src/Fixer/PhpUnit/PhpUnitDedicateAssertInternalTypeFixer.php @@ -31,10 +31,7 @@ */ final class PhpUnitDedicateAssertInternalTypeFixer extends AbstractPhpUnitFixer implements ConfigurableFixerInterface { - /** - * @var array - */ - private $typeToDedicatedAssertMap = [ + private array $typeToDedicatedAssertMap = [ 'array' => 'assertIsArray', 'boolean' => 'assertIsBool', 'bool' => 'assertIsBool', diff --git a/src/Fixer/PhpUnit/PhpUnitExpectationFixer.php b/src/Fixer/PhpUnit/PhpUnitExpectationFixer.php index 4bb80013455..7f2c3530bc9 100644 --- a/src/Fixer/PhpUnit/PhpUnitExpectationFixer.php +++ b/src/Fixer/PhpUnit/PhpUnitExpectationFixer.php @@ -36,7 +36,7 @@ final class PhpUnitExpectationFixer extends AbstractPhpUnitFixer implements Conf /** * @var array */ - private $methodMap = []; + private array $methodMap = []; /** * {@inheritdoc} diff --git a/src/Fixer/PhpUnit/PhpUnitStrictFixer.php b/src/Fixer/PhpUnit/PhpUnitStrictFixer.php index 8f23634caf1..914e1b0f3a0 100644 --- a/src/Fixer/PhpUnit/PhpUnitStrictFixer.php +++ b/src/Fixer/PhpUnit/PhpUnitStrictFixer.php @@ -36,7 +36,7 @@ final class PhpUnitStrictFixer extends AbstractPhpUnitFixer implements Configura /** * @var array */ - private static $assertionMap = [ + private static array $assertionMap = [ 'assertAttributeEquals' => 'assertAttributeSame', 'assertAttributeNotEquals' => 'assertAttributeNotSame', 'assertEquals' => 'assertSame', diff --git a/src/Fixer/PhpUnit/PhpUnitTestCaseStaticMethodCallsFixer.php b/src/Fixer/PhpUnit/PhpUnitTestCaseStaticMethodCallsFixer.php index c26ffd1e528..056addf13d3 100644 --- a/src/Fixer/PhpUnit/PhpUnitTestCaseStaticMethodCallsFixer.php +++ b/src/Fixer/PhpUnit/PhpUnitTestCaseStaticMethodCallsFixer.php @@ -52,7 +52,7 @@ final class PhpUnitTestCaseStaticMethodCallsFixer extends AbstractPhpUnitFixer i /** * @var array */ - private $allowedValues = [ + private array $allowedValues = [ self::CALL_TYPE_THIS => true, self::CALL_TYPE_SELF => true, self::CALL_TYPE_STATIC => true, @@ -61,7 +61,7 @@ final class PhpUnitTestCaseStaticMethodCallsFixer extends AbstractPhpUnitFixer i /** * @var array */ - private $staticMethods = [ + private array $staticMethods = [ // Assert methods 'anything' => true, 'arrayHasKey' => true, @@ -300,7 +300,7 @@ final class PhpUnitTestCaseStaticMethodCallsFixer extends AbstractPhpUnitFixer i 'throwException' => true, ]; - private $conversionMap = [ + private array $conversionMap = [ self::CALL_TYPE_THIS => [[T_OBJECT_OPERATOR, '->'], [T_VARIABLE, '$this']], self::CALL_TYPE_SELF => [[T_DOUBLE_COLON, '::'], [T_STRING, 'self']], self::CALL_TYPE_STATIC => [[T_DOUBLE_COLON, '::'], [T_STATIC, 'static']], diff --git a/src/Fixer/Phpdoc/PhpdocAnnotationWithoutDotFixer.php b/src/Fixer/Phpdoc/PhpdocAnnotationWithoutDotFixer.php index b0c73745473..02451992fe1 100644 --- a/src/Fixer/Phpdoc/PhpdocAnnotationWithoutDotFixer.php +++ b/src/Fixer/Phpdoc/PhpdocAnnotationWithoutDotFixer.php @@ -31,7 +31,7 @@ final class PhpdocAnnotationWithoutDotFixer extends AbstractFixer /** * @var string[] */ - private $tags = ['throws', 'return', 'param', 'internal', 'deprecated', 'var', 'type']; + private array $tags = ['throws', 'return', 'param', 'internal', 'deprecated', 'var', 'type']; /** * {@inheritdoc} diff --git a/src/Fixer/Phpdoc/PhpdocReturnSelfReferenceFixer.php b/src/Fixer/Phpdoc/PhpdocReturnSelfReferenceFixer.php index 527492d7612..cc083a32eb3 100644 --- a/src/Fixer/Phpdoc/PhpdocReturnSelfReferenceFixer.php +++ b/src/Fixer/Phpdoc/PhpdocReturnSelfReferenceFixer.php @@ -34,7 +34,7 @@ final class PhpdocReturnSelfReferenceFixer extends AbstractFixer implements Conf /** * @var string[] */ - private static $toTypes = [ + private static array $toTypes = [ '$this', 'static', 'self', diff --git a/src/Fixer/Phpdoc/PhpdocScalarFixer.php b/src/Fixer/Phpdoc/PhpdocScalarFixer.php index 140b6d67495..a77761b9c43 100644 --- a/src/Fixer/Phpdoc/PhpdocScalarFixer.php +++ b/src/Fixer/Phpdoc/PhpdocScalarFixer.php @@ -31,10 +31,8 @@ final class PhpdocScalarFixer extends AbstractPhpdocTypesFixer implements Config { /** * The types to fix. - * - * @var array */ - private static $types = [ + private static array $types = [ 'boolean' => 'bool', 'callback' => 'callable', 'double' => 'float', diff --git a/src/Fixer/Phpdoc/PhpdocToCommentFixer.php b/src/Fixer/Phpdoc/PhpdocToCommentFixer.php index 4475443e798..a536afa9008 100644 --- a/src/Fixer/Phpdoc/PhpdocToCommentFixer.php +++ b/src/Fixer/Phpdoc/PhpdocToCommentFixer.php @@ -36,7 +36,7 @@ final class PhpdocToCommentFixer extends AbstractFixer implements ConfigurableFi /** * @var string[] */ - private $ignoredTags = []; + private array $ignoredTags = []; /** * {@inheritdoc} diff --git a/src/Fixer/Phpdoc/PhpdocTypesFixer.php b/src/Fixer/Phpdoc/PhpdocTypesFixer.php index 4ecef2c22f4..b447d1e3ea0 100644 --- a/src/Fixer/Phpdoc/PhpdocTypesFixer.php +++ b/src/Fixer/Phpdoc/PhpdocTypesFixer.php @@ -69,10 +69,7 @@ final class PhpdocTypesFixer extends AbstractPhpdocTypesFixer implements Configu ], ]; - /** - * @var string - */ - private $patternToFix = ''; + private string $patternToFix = ''; /** * {@inheritdoc} diff --git a/src/Fixer/Whitespace/BlankLineBeforeStatementFixer.php b/src/Fixer/Whitespace/BlankLineBeforeStatementFixer.php index 52276b819c0..917d8f47957 100644 --- a/src/Fixer/Whitespace/BlankLineBeforeStatementFixer.php +++ b/src/Fixer/Whitespace/BlankLineBeforeStatementFixer.php @@ -34,10 +34,7 @@ */ final class BlankLineBeforeStatementFixer extends AbstractFixer implements ConfigurableFixerInterface, WhitespacesAwareFixerInterface { - /** - * @var array - */ - private static $tokenMap = [ + private static array $tokenMap = [ 'break' => T_BREAK, 'case' => T_CASE, 'continue' => T_CONTINUE, @@ -63,10 +60,7 @@ final class BlankLineBeforeStatementFixer extends AbstractFixer implements Confi 'yield_from' => T_YIELD_FROM, ]; - /** - * @var array - */ - private $fixTokenMap = []; + private array $fixTokenMap = []; /** * {@inheritdoc} diff --git a/src/Fixer/Whitespace/NoExtraBlankLinesFixer.php b/src/Fixer/Whitespace/NoExtraBlankLinesFixer.php index 915e638d5ed..9c484e0108b 100644 --- a/src/Fixer/Whitespace/NoExtraBlankLinesFixer.php +++ b/src/Fixer/Whitespace/NoExtraBlankLinesFixer.php @@ -39,7 +39,7 @@ final class NoExtraBlankLinesFixer extends AbstractFixer implements Configurable /** * @var string[] */ - private static $availableTokens = [ + private static array $availableTokens = [ 'break', 'case', 'continue', diff --git a/src/FixerConfiguration/AliasedFixerOption.php b/src/FixerConfiguration/AliasedFixerOption.php index 6e54eb8b5f6..8170e9ef032 100644 --- a/src/FixerConfiguration/AliasedFixerOption.php +++ b/src/FixerConfiguration/AliasedFixerOption.php @@ -21,15 +21,9 @@ */ final class AliasedFixerOption implements FixerOptionInterface { - /** - * @var FixerOptionInterface - */ - private $fixerOption; + private FixerOptionInterface $fixerOption; - /** - * @var string - */ - private $alias; + private string $alias; public function __construct(FixerOptionInterface $fixerOption, string $alias) { diff --git a/src/FixerConfiguration/AliasedFixerOptionBuilder.php b/src/FixerConfiguration/AliasedFixerOptionBuilder.php index 6fa23293092..9ba11c8478b 100644 --- a/src/FixerConfiguration/AliasedFixerOptionBuilder.php +++ b/src/FixerConfiguration/AliasedFixerOptionBuilder.php @@ -21,15 +21,9 @@ */ final class AliasedFixerOptionBuilder { - /** - * @var FixerOptionBuilder - */ - private $optionBuilder; + private FixerOptionBuilder $optionBuilder; - /** - * @var string - */ - private $alias; + private string $alias; public function __construct(FixerOptionBuilder $optionBuilder, string $alias) { @@ -39,8 +33,6 @@ public function __construct(FixerOptionBuilder $optionBuilder, string $alias) /** * @param mixed $default - * - * @return $this */ public function setDefault($default): self { @@ -51,8 +43,6 @@ public function setDefault($default): self /** * @param string[] $allowedTypes - * - * @return $this */ public function setAllowedTypes(array $allowedTypes): self { @@ -61,9 +51,6 @@ public function setAllowedTypes(array $allowedTypes): self return $this; } - /** - * @return $this - */ public function setAllowedValues(array $allowedValues): self { $this->optionBuilder->setAllowedValues($allowedValues); @@ -71,9 +58,6 @@ public function setAllowedValues(array $allowedValues): self return $this; } - /** - * @return $this - */ public function setNormalizer(\Closure $normalizer): self { $this->optionBuilder->setNormalizer($normalizer); diff --git a/src/FixerConfiguration/DeprecatedFixerOption.php b/src/FixerConfiguration/DeprecatedFixerOption.php index 41121b11a3f..607aba397ca 100644 --- a/src/FixerConfiguration/DeprecatedFixerOption.php +++ b/src/FixerConfiguration/DeprecatedFixerOption.php @@ -16,15 +16,9 @@ final class DeprecatedFixerOption implements DeprecatedFixerOptionInterface { - /** - * @var FixerOptionInterface - */ - private $option; + private FixerOptionInterface $option; - /** - * @var string - */ - private $deprecationMessage; + private string $deprecationMessage; public function __construct(FixerOptionInterface $option, string $deprecationMessage) { diff --git a/src/FixerConfiguration/FixerConfigurationResolver.php b/src/FixerConfiguration/FixerConfigurationResolver.php index a337c0bf935..53723473388 100644 --- a/src/FixerConfiguration/FixerConfigurationResolver.php +++ b/src/FixerConfiguration/FixerConfigurationResolver.php @@ -23,12 +23,12 @@ final class FixerConfigurationResolver implements FixerConfigurationResolverInte /** * @var FixerOptionInterface[] */ - private $options = []; + private array $options = []; /** * @var string[] */ - private $registeredNames = []; + private array $registeredNames = []; /** * @param iterable $options @@ -39,7 +39,7 @@ public function __construct(iterable $options) $this->addOption($option); } - if (empty($this->registeredNames)) { + if (0 === \count($this->registeredNames)) { throw new \LogicException('Options cannot be empty.'); } } diff --git a/src/FixerConfiguration/FixerOption.php b/src/FixerConfiguration/FixerOption.php index f25b52ba2bb..de75e8098c8 100644 --- a/src/FixerConfiguration/FixerOption.php +++ b/src/FixerConfiguration/FixerOption.php @@ -82,6 +82,7 @@ public function __construct( $this->default = $default; $this->allowedTypes = $allowedTypes; $this->allowedValues = $allowedValues; + if (null !== $normalizer) { $this->normalizer = $this->unbind($normalizer); } diff --git a/src/FixerConfiguration/FixerOptionBuilder.php b/src/FixerConfiguration/FixerOptionBuilder.php index 499be701cb6..2dd6e588e5a 100644 --- a/src/FixerConfiguration/FixerOptionBuilder.php +++ b/src/FixerConfiguration/FixerOptionBuilder.php @@ -16,25 +16,16 @@ final class FixerOptionBuilder { - /** - * @var string - */ - private $name; + private string $name; - /** - * @var string - */ - private $description; + private string $description; /** * @var mixed */ private $default; - /** - * @var bool - */ - private $isRequired = true; + private bool $isRequired = true; /** * @var null|string[] diff --git a/src/FixerDefinition/CodeSample.php b/src/FixerDefinition/CodeSample.php index dd5e47338e5..a0f7c9f4c5d 100644 --- a/src/FixerDefinition/CodeSample.php +++ b/src/FixerDefinition/CodeSample.php @@ -19,10 +19,7 @@ */ final class CodeSample implements CodeSampleInterface { - /** - * @var string - */ - private $code; + private string $code; /** * @var null|array diff --git a/src/FixerDefinition/FileSpecificCodeSample.php b/src/FixerDefinition/FileSpecificCodeSample.php index 24a1f72144e..10698c10b87 100644 --- a/src/FixerDefinition/FileSpecificCodeSample.php +++ b/src/FixerDefinition/FileSpecificCodeSample.php @@ -21,15 +21,9 @@ */ final class FileSpecificCodeSample implements FileSpecificCodeSampleInterface { - /** - * @var CodeSampleInterface - */ - private $codeSample; + private CodeSampleInterface $codeSample; - /** - * @var \SplFileInfo - */ - private $splFileInfo; + private \SplFileInfo $splFileInfo; public function __construct( string $code, diff --git a/src/FixerDefinition/FixerDefinition.php b/src/FixerDefinition/FixerDefinition.php index 87fb055c7c3..8c16a7211a7 100644 --- a/src/FixerDefinition/FixerDefinition.php +++ b/src/FixerDefinition/FixerDefinition.php @@ -19,25 +19,22 @@ */ final class FixerDefinition implements FixerDefinitionInterface { - /** - * @var null|string - */ - private $riskyDescription; + private string $summary; /** * @var CodeSampleInterface[] */ - private $codeSamples; + private array $codeSamples; /** - * @var string + * @var null|string */ - private $summary; + private $description; /** * @var null|string */ - private $description; + private $riskyDescription; /** * @param CodeSampleInterface[] $codeSamples array of samples, where single sample is [code, configuration] diff --git a/src/FixerDefinition/VersionSpecificCodeSample.php b/src/FixerDefinition/VersionSpecificCodeSample.php index aa5a0ab8d4e..e74eebd6101 100644 --- a/src/FixerDefinition/VersionSpecificCodeSample.php +++ b/src/FixerDefinition/VersionSpecificCodeSample.php @@ -19,15 +19,9 @@ */ final class VersionSpecificCodeSample implements VersionSpecificCodeSampleInterface { - /** - * @var CodeSampleInterface - */ - private $codeSample; + private CodeSampleInterface $codeSample; - /** - * @var VersionSpecificationInterface - */ - private $versionSpecification; + private VersionSpecificationInterface $versionSpecification; public function __construct( string $code, diff --git a/src/FixerFactory.php b/src/FixerFactory.php index 56e82b1a69d..3d356334f92 100644 --- a/src/FixerFactory.php +++ b/src/FixerFactory.php @@ -37,20 +37,17 @@ */ final class FixerFactory { - /** - * @var FixerNameValidator - */ - private $nameValidator; + private FixerNameValidator $nameValidator; /** * @var FixerInterface[] */ - private $fixers = []; + private array $fixers = []; /** * @var FixerInterface[] Associative array of fixers with names as keys */ - private $fixersByName = []; + private array $fixersByName = []; public function __construct() { diff --git a/src/FixerFileProcessedEvent.php b/src/FixerFileProcessedEvent.php index d46bb3220b7..27ebed5dc52 100644 --- a/src/FixerFileProcessedEvent.php +++ b/src/FixerFileProcessedEvent.php @@ -38,10 +38,7 @@ final class FixerFileProcessedEvent extends Event public const STATUS_EXCEPTION = 5; public const STATUS_LINT = 6; - /** - * @var int - */ - private $status; + private int $status; public function __construct(int $status) { diff --git a/src/Linter/CachingLinter.php b/src/Linter/CachingLinter.php index 6da3898c5bf..39ff6daa9ee 100644 --- a/src/Linter/CachingLinter.php +++ b/src/Linter/CachingLinter.php @@ -21,15 +21,12 @@ */ final class CachingLinter implements LinterInterface { - /** - * @var LinterInterface - */ - private $sublinter; + private LinterInterface $sublinter; /** * @var array */ - private $cache = []; + private array $cache = []; public function __construct(LinterInterface $linter) { diff --git a/src/Linter/ProcessLinter.php b/src/Linter/ProcessLinter.php index d19b69e2ae7..2ec206aa188 100644 --- a/src/Linter/ProcessLinter.php +++ b/src/Linter/ProcessLinter.php @@ -74,7 +74,6 @@ public function __construct(?string $executable = null) } $this->processBuilder = new ProcessLinterProcessBuilder($executable); - $this->fileRemoval = new FileRemoval(); } diff --git a/src/Linter/ProcessLinterProcessBuilder.php b/src/Linter/ProcessLinterProcessBuilder.php index 4b6403e57ee..ee9a555e55e 100644 --- a/src/Linter/ProcessLinterProcessBuilder.php +++ b/src/Linter/ProcessLinterProcessBuilder.php @@ -23,10 +23,7 @@ */ final class ProcessLinterProcessBuilder { - /** - * @var string - */ - private $executable; + private string $executable; /** * @param string $executable PHP executable diff --git a/src/Runner/FileCachingLintingIterator.php b/src/Runner/FileCachingLintingIterator.php index b8ea84de7e3..d077f5e4bf7 100644 --- a/src/Runner/FileCachingLintingIterator.php +++ b/src/Runner/FileCachingLintingIterator.php @@ -29,10 +29,7 @@ final class FileCachingLintingIterator extends \CachingIterator */ private $currentResult; - /** - * @var LinterInterface - */ - private $linter; + private LinterInterface $linter; /** * @var LintingResultInterface diff --git a/src/Runner/FileFilterIterator.php b/src/Runner/FileFilterIterator.php index 8feb19f4118..7210b94e062 100644 --- a/src/Runner/FileFilterIterator.php +++ b/src/Runner/FileFilterIterator.php @@ -32,15 +32,12 @@ final class FileFilterIterator extends \FilterIterator */ private $eventDispatcher; - /** - * @var CacheManagerInterface - */ - private $cacheManager; + private CacheManagerInterface $cacheManager; /** * @var array */ - private $visitedElements = []; + private array $visitedElements = []; public function __construct( \Traversable $iterator, diff --git a/src/Runner/FileLintingIterator.php b/src/Runner/FileLintingIterator.php index fb0a7b40fd0..050d8c5a50e 100644 --- a/src/Runner/FileLintingIterator.php +++ b/src/Runner/FileLintingIterator.php @@ -29,10 +29,7 @@ final class FileLintingIterator extends \IteratorIterator */ private $currentResult; - /** - * @var null|LinterInterface - */ - private $linter; + private LinterInterface $linter; public function __construct(\Iterator $iterator, LinterInterface $linter) { diff --git a/src/Runner/Runner.php b/src/Runner/Runner.php index 215da188ec5..a1b43de7a33 100644 --- a/src/Runner/Runner.php +++ b/src/Runner/Runner.php @@ -37,40 +37,22 @@ */ final class Runner { - /** - * @var DifferInterface - */ - private $differ; + private DifferInterface $differ; - /** - * @var DirectoryInterface - */ - private $directory; + private ?DirectoryInterface $directory; /** * @var null|EventDispatcherInterface */ private $eventDispatcher; - /** - * @var ErrorsManager - */ - private $errorsManager; + private ErrorsManager $errorsManager; - /** - * @var CacheManagerInterface - */ - private $cacheManager; + private CacheManagerInterface $cacheManager; - /** - * @var bool - */ - private $isDryRun; + private bool $isDryRun; - /** - * @var LinterInterface - */ - private $linter; + private LinterInterface $linter; /** * @var \Traversable @@ -80,12 +62,9 @@ final class Runner /** * @var FixerInterface[] */ - private $fixers; + private array $fixers; - /** - * @var bool - */ - private $stopOnViolation; + private bool $stopOnViolation; public function __construct( $finder, diff --git a/src/Tokenizer/Analyzer/Analysis/AbstractControlCaseStructuresAnalysis.php b/src/Tokenizer/Analyzer/Analysis/AbstractControlCaseStructuresAnalysis.php index e1890f7dd40..a2bc675fd57 100644 --- a/src/Tokenizer/Analyzer/Analysis/AbstractControlCaseStructuresAnalysis.php +++ b/src/Tokenizer/Analyzer/Analysis/AbstractControlCaseStructuresAnalysis.php @@ -19,20 +19,11 @@ */ abstract class AbstractControlCaseStructuresAnalysis { - /** - * @var int - */ - private $index; - - /** - * @var int - */ - private $open; - - /** - * @var int - */ - private $close; + private int $index; + + private int $open; + + private int $close; public function __construct(int $index, int $open, int $close) { diff --git a/src/Tokenizer/Analyzer/Analysis/ArgumentAnalysis.php b/src/Tokenizer/Analyzer/Analysis/ArgumentAnalysis.php index 54b8167c31b..1cf22c67371 100644 --- a/src/Tokenizer/Analyzer/Analysis/ArgumentAnalysis.php +++ b/src/Tokenizer/Analyzer/Analysis/ArgumentAnalysis.php @@ -20,25 +20,21 @@ final class ArgumentAnalysis { /** - * The default value of the argument. - * - * @var null|string + * The name of the argument. */ - private $default; + private string $name; /** - * The name of the argument. - * - * @var string + * The index where the name is located in the supplied Tokens object. */ - private $name; + private int $nameIndex; /** - * The index where the name is located in the supplied Tokens object. + * The default value of the argument. * - * @var int + * @var null|string */ - private $nameIndex; + private $default; /** * The type analysis of the argument. diff --git a/src/Tokenizer/Analyzer/Analysis/CaseAnalysis.php b/src/Tokenizer/Analyzer/Analysis/CaseAnalysis.php index 8289b8921d4..df8c0dc3d88 100644 --- a/src/Tokenizer/Analyzer/Analysis/CaseAnalysis.php +++ b/src/Tokenizer/Analyzer/Analysis/CaseAnalysis.php @@ -21,15 +21,9 @@ */ final class CaseAnalysis { - /** - * @var int - */ - private $index; - - /** - * @var int - */ - private $colonIndex; + private int $index; + + private int $colonIndex; public function __construct(int $index, int $colonIndex) { diff --git a/src/Tokenizer/Analyzer/Analysis/DefaultAnalysis.php b/src/Tokenizer/Analyzer/Analysis/DefaultAnalysis.php index c2d6ee799bd..b742b29a098 100644 --- a/src/Tokenizer/Analyzer/Analysis/DefaultAnalysis.php +++ b/src/Tokenizer/Analyzer/Analysis/DefaultAnalysis.php @@ -19,15 +19,9 @@ */ final class DefaultAnalysis { - /** - * @var int - */ - private $index; - - /** - * @var int - */ - private $colonIndex; + private int $index; + + private int $colonIndex; public function __construct(int $index, int $colonIndex) { diff --git a/src/Tokenizer/Analyzer/Analysis/EnumAnalysis.php b/src/Tokenizer/Analyzer/Analysis/EnumAnalysis.php index b337f1fac79..97fe9ce573e 100644 --- a/src/Tokenizer/Analyzer/Analysis/EnumAnalysis.php +++ b/src/Tokenizer/Analyzer/Analysis/EnumAnalysis.php @@ -22,7 +22,7 @@ final class EnumAnalysis extends AbstractControlCaseStructuresAnalysis /** * @var CaseAnalysis[] */ - private $cases; + private array $cases; /** * @param CaseAnalysis[] $cases diff --git a/src/Tokenizer/Analyzer/Analysis/NamespaceAnalysis.php b/src/Tokenizer/Analyzer/Analysis/NamespaceAnalysis.php index e6f18215de9..6702a122612 100644 --- a/src/Tokenizer/Analyzer/Analysis/NamespaceAnalysis.php +++ b/src/Tokenizer/Analyzer/Analysis/NamespaceAnalysis.php @@ -21,45 +21,33 @@ final class NamespaceAnalysis implements StartEndTokenAwareAnalysis { /** * The fully qualified namespace name. - * - * @var string */ - private $fullName; + private string $fullName; /** * The short version of the namespace. - * - * @var string */ - private $shortName; + private string $shortName; /** * The start index of the namespace declaration in the analyzed Tokens. - * - * @var int */ - private $startIndex; + private int $startIndex; /** * The end index of the namespace declaration in the analyzed Tokens. - * - * @var int */ - private $endIndex; + private int $endIndex; /** * The start index of the scope of the namespace in the analyzed Tokens. - * - * @var int */ - private $scopeStartIndex; + private int $scopeStartIndex; /** * The end index of the scope of the namespace in the analyzed Tokens. - * - * @var int */ - private $scopeEndIndex; + private int $scopeEndIndex; public function __construct(string $fullName, string $shortName, int $startIndex, int $endIndex, int $scopeStartIndex, int $scopeEndIndex) { diff --git a/src/Tokenizer/Analyzer/Analysis/NamespaceUseAnalysis.php b/src/Tokenizer/Analyzer/Analysis/NamespaceUseAnalysis.php index beb29d70edd..59127b2fe3d 100644 --- a/src/Tokenizer/Analyzer/Analysis/NamespaceUseAnalysis.php +++ b/src/Tokenizer/Analyzer/Analysis/NamespaceUseAnalysis.php @@ -25,45 +25,33 @@ final class NamespaceUseAnalysis implements StartEndTokenAwareAnalysis /** * The fully qualified use namespace. - * - * @var string */ - private $fullName; + private string $fullName; /** * The short version of use namespace or the alias name in case of aliased use statements. - * - * @var string */ - private $shortName; + private string $shortName; /** * Is the use statement being aliased? - * - * @var bool */ - private $isAliased; + private bool $isAliased; /** * The start index of the namespace declaration in the analyzed Tokens. - * - * @var int */ - private $startIndex; + private int $startIndex; /** * The end index of the namespace declaration in the analyzed Tokens. - * - * @var int */ - private $endIndex; + private int $endIndex; /** * The type of import: class, function or constant. - * - * @var int */ - private $type; + private int $type; public function __construct(string $fullName, string $shortName, bool $isAliased, int $startIndex, int $endIndex, int $type) { diff --git a/src/Tokenizer/Analyzer/Analysis/SwitchAnalysis.php b/src/Tokenizer/Analyzer/Analysis/SwitchAnalysis.php index 228ed88fb06..75ed4af87c9 100644 --- a/src/Tokenizer/Analyzer/Analysis/SwitchAnalysis.php +++ b/src/Tokenizer/Analyzer/Analysis/SwitchAnalysis.php @@ -20,14 +20,14 @@ final class SwitchAnalysis extends AbstractControlCaseStructuresAnalysis { /** - * @var null|DefaultAnalysis + * @var CaseAnalysis[] */ - private $defaultAnalysis; + private array $cases; /** - * @var CaseAnalysis[] + * @var null|DefaultAnalysis */ - private $cases; + private $defaultAnalysis; /** * @param CaseAnalysis[] $cases diff --git a/src/Tokenizer/Analyzer/Analysis/TypeAnalysis.php b/src/Tokenizer/Analyzer/Analysis/TypeAnalysis.php index 9c55d60b423..0c102871e26 100644 --- a/src/Tokenizer/Analyzer/Analysis/TypeAnalysis.php +++ b/src/Tokenizer/Analyzer/Analysis/TypeAnalysis.php @@ -28,9 +28,9 @@ final class TypeAnalysis implements StartEndTokenAwareAnalysis * @see https://php.net/manual/en/reserved.other-reserved-words.php * @see https://php.net/manual/en/language.pseudo-types.php * - * @var array + * @var string[] */ - private static $reservedTypes = [ + private static array $reservedTypes = [ 'array', 'bool', 'callable', @@ -52,20 +52,11 @@ final class TypeAnalysis implements StartEndTokenAwareAnalysis */ private $name; - /** - * @var int - */ - private $startIndex; + private int $startIndex; - /** - * @var int - */ - private $endIndex; + private int $endIndex; - /** - * @var bool - */ - private $nullable; + private bool $nullable; public function __construct(string $name, int $startIndex, int $endIndex) { diff --git a/src/Tokenizer/Analyzer/FunctionsAnalyzer.php b/src/Tokenizer/Analyzer/FunctionsAnalyzer.php index af1b77069f9..e5b6cd7f9f4 100644 --- a/src/Tokenizer/Analyzer/FunctionsAnalyzer.php +++ b/src/Tokenizer/Analyzer/FunctionsAnalyzer.php @@ -26,10 +26,7 @@ */ final class FunctionsAnalyzer { - /** - * @var array - */ - private $functionsAnalysis = ['tokens' => '', 'imports' => [], 'declarations' => []]; + private array $functionsAnalysis = ['tokens' => '', 'imports' => [], 'declarations' => []]; /** * Important: risky because of the limited (file) scope of the tool. diff --git a/src/Tokenizer/Token.php b/src/Tokenizer/Token.php index a1b191217c8..7ce9a507544 100644 --- a/src/Tokenizer/Token.php +++ b/src/Tokenizer/Token.php @@ -38,17 +38,13 @@ final class Token /** * If token prototype is an array. - * - * @var bool */ - private $isArray; + private bool $isArray; /** * Flag is token was changed. - * - * @var bool */ - private $changed = false; + private bool $changed = false; /** * @param array|string $token token prototype diff --git a/src/Tokenizer/Tokens.php b/src/Tokenizer/Tokens.php index b3d8d34cf1d..b3d725c887c 100644 --- a/src/Tokenizer/Tokens.php +++ b/src/Tokenizer/Tokens.php @@ -45,24 +45,22 @@ class Tokens extends \SplFixedArray /** * Static class cache. - * - * @var array */ - private static $cache = []; + private static array $cache = []; /** * Cache of block starts. Any change in collection will invalidate it. * * @var array */ - private $blockStartCache = []; + private array $blockStartCache = []; /** * Cache of block ends. Any change in collection will invalidate it. * * @var array */ - private $blockEndCache = []; + private array $blockEndCache = []; /** * crc32 hash of code string. @@ -75,10 +73,8 @@ class Tokens extends \SplFixedArray * Flag is collection was changed. * * It doesn't know about change of collection's items. To check it run `isChanged` method. - * - * @var bool */ - private $changed = false; + private bool $changed = false; /** * Set of found token kinds. @@ -89,7 +85,7 @@ class Tokens extends \SplFixedArray * * @var array */ - private $foundTokenKinds = []; + private array $foundTokenKinds = []; /** * Clone tokens collection. @@ -1218,6 +1214,7 @@ private function findOppositeBlockEdge(int $type, int $searchIndex, bool $findEn if ($findEnd && isset($this->blockStartCache[$searchIndex])) { return $this->blockStartCache[$searchIndex]; } + if (!$findEnd && isset($this->blockEndCache[$searchIndex])) { return $this->blockEndCache[$searchIndex]; } diff --git a/src/Tokenizer/TokensAnalyzer.php b/src/Tokenizer/TokensAnalyzer.php index 42d4081f8a0..f34ff7b9546 100644 --- a/src/Tokenizer/TokensAnalyzer.php +++ b/src/Tokenizer/TokensAnalyzer.php @@ -31,10 +31,8 @@ final class TokensAnalyzer { /** * Tokens collection instance. - * - * @var Tokens */ - private $tokens; + private Tokens $tokens; /** * @var ?GotoLabelAnalyzer diff --git a/src/Tokenizer/Transformers.php b/src/Tokenizer/Transformers.php index ac6334783d2..b2587e25ab0 100644 --- a/src/Tokenizer/Transformers.php +++ b/src/Tokenizer/Transformers.php @@ -31,7 +31,7 @@ final class Transformers * * @var TransformerInterface[] */ - private $items = []; + private array $items = []; /** * Register built in Transformers. diff --git a/src/Utils.php b/src/Utils.php index 57f7a558668..5eacb3e13f3 100644 --- a/src/Utils.php +++ b/src/Utils.php @@ -29,7 +29,7 @@ final class Utils /** * @var array */ - private static $deprecations = []; + private static array $deprecations = []; private function __construct() { diff --git a/src/WhitespacesFixerConfig.php b/src/WhitespacesFixerConfig.php index 0640a053ce2..e558fd6b9c5 100644 --- a/src/WhitespacesFixerConfig.php +++ b/src/WhitespacesFixerConfig.php @@ -19,15 +19,9 @@ */ final class WhitespacesFixerConfig { - /** - * @var string - */ - private $indent; - - /** - * @var string - */ - private $lineEnding; + private string $indent; + + private string $lineEnding; public function __construct(string $indent = ' ', string $lineEnding = "\n") { diff --git a/src/WordMatcher.php b/src/WordMatcher.php index 5314b1e1c72..36265a885fe 100644 --- a/src/WordMatcher.php +++ b/src/WordMatcher.php @@ -24,7 +24,7 @@ final class WordMatcher /** * @var string[] */ - private $candidates; + private array $candidates; /** * @param string[] $candidates diff --git a/tests/AbstractProxyFixerTest.php b/tests/AbstractProxyFixerTest.php index dae41ca5023..262d1aa4793 100644 --- a/tests/AbstractProxyFixerTest.php +++ b/tests/AbstractProxyFixerTest.php @@ -139,7 +139,7 @@ private function buildProxyFixer(array $fixers): AbstractProxyFixer /** * @var FixerInterface[] */ - private $fixers; + private array $fixers; public function __construct(array $fixers) { diff --git a/tests/Smoke/InstallViaComposerTest.php b/tests/Smoke/InstallViaComposerTest.php index 003387e655e..b215802ad32 100644 --- a/tests/Smoke/InstallViaComposerTest.php +++ b/tests/Smoke/InstallViaComposerTest.php @@ -32,7 +32,7 @@ final class InstallViaComposerTest extends AbstractSmokeTest /** * @var string[] */ - private $stepsToVerifyInstallation = [ + private array $stepsToVerifyInstallation = [ // Confirm we can install. 'composer install -q', // Ensure that autoloader works. diff --git a/tests/Test/AbstractFixerTestCase.php b/tests/Test/AbstractFixerTestCase.php index 9755de0b3f7..9b56f6ce264 100644 --- a/tests/Test/AbstractFixerTestCase.php +++ b/tests/Test/AbstractFixerTestCase.php @@ -59,7 +59,7 @@ abstract class AbstractFixerTestCase extends TestCase * * @var array */ - private $allowedRequiredOptions = [ + private array $allowedRequiredOptions = [ 'header_comment' => ['header' => true], ]; @@ -68,7 +68,7 @@ abstract class AbstractFixerTestCase extends TestCase * * @var array */ - private $allowedFixersWithoutDefaultCodeSample = [ + private array $allowedFixersWithoutDefaultCodeSample = [ 'general_phpdoc_annotation_remove' => true, 'general_phpdoc_tag_rename' => true, ]; diff --git a/tests/Test/IntegrationCase.php b/tests/Test/IntegrationCase.php index bb47b5719c4..a04abaa482e 100644 --- a/tests/Test/IntegrationCase.php +++ b/tests/Test/IntegrationCase.php @@ -23,20 +23,11 @@ */ final class IntegrationCase { - /** - * @var array - */ - private $config; + private array $config; - /** - * @var string - */ - private $expectedCode; + private string $expectedCode; - /** - * @var string - */ - private $fileName; + private string $fileName; /** * @var null|string @@ -45,27 +36,17 @@ final class IntegrationCase /** * Env requirements (possible keys: php). - * - * @var array */ - private $requirements; + private array $requirements; - /** - * @var RuleSet - */ - private $ruleset; + private RuleSet $ruleset; /** * Settings how to perform the test (possible keys: none in base class, use as extension point for custom IntegrationTestCase). - * - * @var array */ - private $settings; + private array $settings; - /** - * @var string - */ - private $title; + private string $title; public function __construct( string $fileName,