Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PHP7.4 - properties types #6290

Merged
merged 1 commit into from Feb 16, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 1 addition & 4 deletions src/AbstractDoctrineAnnotationFixer.php
Expand Up @@ -29,10 +29,7 @@
*/
abstract class AbstractDoctrineAnnotationFixer extends AbstractFixer implements ConfigurableFixerInterface
{
/**
* @var array
*/
private $classyElements;
private array $classyElements;

/**
* {@inheritdoc}
Expand Down
13 changes: 5 additions & 8 deletions src/AbstractPhpdocToTypeDeclarationFixer.php
Expand Up @@ -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<string, int>
*/
private $versionSpecificTypes = [
private array $versionSpecificTypes = [
'void' => 70100,
'iterable' => 70100,
'object' => 70200,
Expand All @@ -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,
Expand All @@ -59,7 +56,7 @@ abstract class AbstractPhpdocToTypeDeclarationFixer extends AbstractFixer implem
/**
* @var array<string, bool>
*/
private static $syntaxValidationCache = [];
private static array $syntaxValidationCache = [];

/**
* {@inheritdoc}
Expand Down Expand Up @@ -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;
}

Expand Down
7 changes: 2 additions & 5 deletions src/Cache/Cache.php
Expand Up @@ -21,15 +21,12 @@
*/
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)
{
Expand Down
5 changes: 1 addition & 4 deletions src/Cache/Directory.php
Expand Up @@ -21,10 +21,7 @@
*/
final class Directory implements DirectoryInterface
{
/**
* @var string
*/
private $directoryName;
private string $directoryName;

public function __construct(string $directoryName)
{
Expand Down
24 changes: 6 additions & 18 deletions src/Cache/FileCacheManager.php
Expand Up @@ -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,
Expand Down
5 changes: 1 addition & 4 deletions src/Cache/FileHandler.php
Expand Up @@ -23,10 +23,7 @@
*/
final class FileHandler implements FileHandlerInterface
{
/**
* @var string
*/
private $file;
private string $file;

public function __construct(string $file)
{
Expand Down
33 changes: 9 additions & 24 deletions src/Cache/Signature.php
Expand Up @@ -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)
{
Expand Down
47 changes: 10 additions & 37 deletions src/Config.php
Expand Up @@ -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')
{
Expand Down
Expand Up @@ -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)
{
Expand All @@ -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;
}

Expand Down
5 changes: 1 addition & 4 deletions src/Console/Application.php
Expand Up @@ -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()
{
Expand Down
5 changes: 1 addition & 4 deletions src/Console/Command/DescribeCommand.php
Expand Up @@ -56,10 +56,7 @@ final class DescribeCommand extends Command
*/
private $setNames;

/**
* @var FixerFactory
*/
private $fixerFactory;
private FixerFactory $fixerFactory;

/**
* @var array<string, FixerInterface>
Expand Down
9 changes: 3 additions & 6 deletions src/Console/Command/DescribeNameNotFoundException.php
Expand Up @@ -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)
{
Expand Down
29 changes: 7 additions & 22 deletions src/Console/Command/FixCommand.php
Expand Up @@ -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;
}

Expand Down
10 changes: 2 additions & 8 deletions src/Console/Command/ListFilesCommand.php
Expand Up @@ -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)
{
Expand Down