Skip to content

Commit

Permalink
CS - change to promoted properties
Browse files Browse the repository at this point in the history
  • Loading branch information
ondrejmirtes committed Jan 4, 2022
1 parent 83052f3 commit 74cb1d9
Show file tree
Hide file tree
Showing 514 changed files with 1,198 additions and 5,340 deletions.
20 changes: 4 additions & 16 deletions compiler/src/Console/CompileCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,26 +34,14 @@
final class CompileCommand extends Command
{

private Filesystem $filesystem;

private ProcessFactory $processFactory;

private string $dataDir;

private string $buildDir;

public function __construct(
Filesystem $filesystem,
ProcessFactory $processFactory,
string $dataDir,
string $buildDir,
private Filesystem $filesystem,
private ProcessFactory $processFactory,
private string $dataDir,
private string $buildDir,
)
{
parent::__construct();
$this->filesystem = $filesystem;
$this->processFactory = $processFactory;
$this->dataDir = $dataDir;
$this->buildDir = $buildDir;
}

protected function configure(): void
Expand Down
5 changes: 1 addition & 4 deletions compiler/src/Filesystem/SymfonyFilesystem.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,8 @@
final class SymfonyFilesystem implements Filesystem
{

private \Symfony\Component\Filesystem\Filesystem $filesystem;

public function __construct(\Symfony\Component\Filesystem\Filesystem $filesystem)
public function __construct(private \Symfony\Component\Filesystem\Filesystem $filesystem)
{
$this->filesystem = $filesystem;
}

public function exists(string $dir): bool
Expand Down
20 changes: 4 additions & 16 deletions src/Analyser/Analyser.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,28 +18,16 @@
class Analyser
{

private FileAnalyser $fileAnalyser;

private Registry $registry;

private NodeScopeResolver $nodeScopeResolver;

private int $internalErrorsCountLimit;

/** @var Error[] */
private array $collectedErrors = [];

public function __construct(
FileAnalyser $fileAnalyser,
Registry $registry,
NodeScopeResolver $nodeScopeResolver,
int $internalErrorsCountLimit,
private FileAnalyser $fileAnalyser,
private Registry $registry,
private NodeScopeResolver $nodeScopeResolver,
private int $internalErrorsCountLimit,
)
{
$this->fileAnalyser = $fileAnalyser;
$this->registry = $registry;
$this->nodeScopeResolver = $nodeScopeResolver;
$this->internalErrorsCountLimit = $internalErrorsCountLimit;
}

/**
Expand Down
30 changes: 5 additions & 25 deletions src/Analyser/AnalyserResult.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,32 +11,18 @@ class AnalyserResult
/** @var Error[] */
private array $unorderedErrors;

/** @var Error[] */
private array $errors;

/** @var string[] */
private array $internalErrors;

/** @var array<string, array<string>>|null */
private ?array $dependencies;

/** @var array<string, array<ExportedNode>> */
private array $exportedNodes;

private bool $reachedInternalErrorsCountLimit;

/**
* @param Error[] $errors
* @param string[] $internalErrors
* @param array<string, array<string>>|null $dependencies
* @param array<string, array<ExportedNode>> $exportedNodes
*/
public function __construct(
array $errors,
array $internalErrors,
?array $dependencies,
array $exportedNodes,
bool $reachedInternalErrorsCountLimit,
private array $errors,
private array $internalErrors,
private ?array $dependencies,
private array $exportedNodes,
private bool $reachedInternalErrorsCountLimit,
)
{
$this->unorderedErrors = $errors;
Expand All @@ -53,12 +39,6 @@ public function __construct(
$b->getMessage(),
],
);

$this->errors = $errors;
$this->internalErrors = $internalErrors;
$this->dependencies = $dependencies;
$this->exportedNodes = $exportedNodes;
$this->reachedInternalErrorsCountLimit = $reachedInternalErrorsCountLimit;
}

/**
Expand Down
11 changes: 2 additions & 9 deletions src/Analyser/ConditionalExpressionHolder.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,24 +12,17 @@
class ConditionalExpressionHolder
{

/** @var array<string, Type> */
private array $conditionExpressionTypes;

private VariableTypeHolder $typeHolder;

/**
* @param array<string, Type> $conditionExpressionTypes
*/
public function __construct(
array $conditionExpressionTypes,
VariableTypeHolder $typeHolder,
private array $conditionExpressionTypes,
private VariableTypeHolder $typeHolder,
)
{
if (count($conditionExpressionTypes) === 0) {
throw new ShouldNotHappenException();
}
$this->conditionExpressionTypes = $conditionExpressionTypes;
$this->typeHolder = $typeHolder;
}

/**
Expand Down
55 changes: 11 additions & 44 deletions src/Analyser/DirectScopeFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,58 +23,25 @@
class DirectScopeFactory implements ScopeFactory
{

private string $scopeClass;

private ReflectionProvider $reflectionProvider;

private DynamicReturnTypeExtensionRegistryProvider $dynamicReturnTypeExtensionRegistryProvider;

private OperatorTypeSpecifyingExtensionRegistryProvider $operatorTypeSpecifyingExtensionRegistryProvider;

private Standard $printer;

private TypeSpecifier $typeSpecifier;

private PropertyReflectionFinder $propertyReflectionFinder;

private Parser $parser;

private NodeScopeResolver $nodeScopeResolver;

private bool $treatPhpDocTypesAsCertain;

/** @var string[] */
private array $dynamicConstantNames;

private PhpVersion $phpVersion;

public function __construct(
string $scopeClass,
ReflectionProvider $reflectionProvider,
DynamicReturnTypeExtensionRegistryProvider $dynamicReturnTypeExtensionRegistryProvider,
OperatorTypeSpecifyingExtensionRegistryProvider $operatorTypeSpecifyingExtensionRegistryProvider,
Standard $printer,
TypeSpecifier $typeSpecifier,
PropertyReflectionFinder $propertyReflectionFinder,
Parser $parser,
NodeScopeResolver $nodeScopeResolver,
bool $treatPhpDocTypesAsCertain,
private string $scopeClass,
private ReflectionProvider $reflectionProvider,
private DynamicReturnTypeExtensionRegistryProvider $dynamicReturnTypeExtensionRegistryProvider,
private OperatorTypeSpecifyingExtensionRegistryProvider $operatorTypeSpecifyingExtensionRegistryProvider,
private Standard $printer,
private TypeSpecifier $typeSpecifier,
private PropertyReflectionFinder $propertyReflectionFinder,
private Parser $parser,
private NodeScopeResolver $nodeScopeResolver,
private bool $treatPhpDocTypesAsCertain,
Container $container,
PhpVersion $phpVersion,
private PhpVersion $phpVersion,
)
{
$this->scopeClass = $scopeClass;
$this->reflectionProvider = $reflectionProvider;
$this->dynamicReturnTypeExtensionRegistryProvider = $dynamicReturnTypeExtensionRegistryProvider;
$this->operatorTypeSpecifyingExtensionRegistryProvider = $operatorTypeSpecifyingExtensionRegistryProvider;
$this->printer = $printer;
$this->typeSpecifier = $typeSpecifier;
$this->propertyReflectionFinder = $propertyReflectionFinder;
$this->parser = $parser;
$this->nodeScopeResolver = $nodeScopeResolver;
$this->treatPhpDocTypesAsCertain = $treatPhpDocTypesAsCertain;
$this->dynamicConstantNames = $container->getParameter('dynamicConstantNames');
$this->phpVersion = $phpVersion;
}

/**
Expand Down
9 changes: 1 addition & 8 deletions src/Analyser/EnsuredNonNullabilityResult.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,11 @@
class EnsuredNonNullabilityResult
{

private MutatingScope $scope;

/** @var EnsuredNonNullabilityResultExpression[] */
private array $specifiedExpressions;

/**
* @param EnsuredNonNullabilityResultExpression[] $specifiedExpressions
*/
public function __construct(MutatingScope $scope, array $specifiedExpressions)
public function __construct(private MutatingScope $scope, private array $specifiedExpressions)
{
$this->scope = $scope;
$this->specifiedExpressions = $specifiedExpressions;
}

public function getScope(): MutatingScope
Expand Down
15 changes: 3 additions & 12 deletions src/Analyser/EnsuredNonNullabilityResultExpression.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,12 @@
class EnsuredNonNullabilityResultExpression
{

private Expr $expression;

private Type $originalType;

private Type $originalNativeType;

public function __construct(
Expr $expression,
Type $originalType,
Type $originalNativeType,
private Expr $expression,
private Type $originalType,
private Type $originalNativeType,
)
{
$this->expression = $expression;
$this->originalType = $originalType;
$this->originalNativeType = $originalNativeType;
}

public function getExpression(): Expr
Expand Down
46 changes: 9 additions & 37 deletions src/Analyser/Error.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,30 +14,11 @@
class Error implements JsonSerializable
{

private string $message;

private string $file;

private ?int $line;

private bool|Throwable $canBeIgnored;

private ?string $filePath;

private ?string $traitFilePath;

private ?string $tip;

private ?int $nodeLine;

/** @phpstan-var class-string<Node>|null */
private ?string $nodeType;

private ?string $identifier;

/** @var mixed[] */
private array $metadata;

/**
* Error constructor.
*
Expand All @@ -46,30 +27,21 @@ class Error implements JsonSerializable
* @param mixed[] $metadata
*/
public function __construct(
string $message,
string $file,
?int $line = null,
private string $message,
private string $file,
private ?int $line = null,
$canBeIgnored = true,
?string $filePath = null,
?string $traitFilePath = null,
?string $tip = null,
?int $nodeLine = null,
private ?string $filePath = null,
private ?string $traitFilePath = null,
private ?string $tip = null,
private ?int $nodeLine = null,
?string $nodeType = null,
?string $identifier = null,
array $metadata = [],
private ?string $identifier = null,
private array $metadata = [],
)
{
$this->message = $message;
$this->file = $file;
$this->line = $line;
$this->canBeIgnored = $canBeIgnored;
$this->filePath = $filePath;
$this->traitFilePath = $traitFilePath;
$this->tip = $tip;
$this->nodeLine = $nodeLine;
$this->nodeType = $nodeType;
$this->identifier = $identifier;
$this->metadata = $metadata;
}

public function getMessage(): string
Expand Down
15 changes: 3 additions & 12 deletions src/Analyser/ExpressionContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,12 @@
class ExpressionContext
{

private bool $isDeep;

private ?string $inAssignRightSideVariableName;

private ?Type $inAssignRightSideType;

private function __construct(
bool $isDeep,
?string $inAssignRightSideVariableName,
?Type $inAssignRightSideType,
private bool $isDeep,
private ?string $inAssignRightSideVariableName,
private ?Type $inAssignRightSideType,
)
{
$this->isDeep = $isDeep;
$this->inAssignRightSideVariableName = $inAssignRightSideVariableName;
$this->inAssignRightSideType = $inAssignRightSideType;
}

public static function createTopLevel(): self
Expand Down
16 changes: 3 additions & 13 deletions src/Analyser/ExpressionResult.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,6 @@
class ExpressionResult
{

private MutatingScope $scope;

private bool $hasYield;

/** @var ThrowPoint[] $throwPoints */
private array $throwPoints;

/** @var (callable(): MutatingScope)|null */
private $truthyScopeCallback;

Expand All @@ -28,16 +21,13 @@ class ExpressionResult
* @param (callable(): MutatingScope)|null $falseyScopeCallback
*/
public function __construct(
MutatingScope $scope,
bool $hasYield,
array $throwPoints,
private MutatingScope $scope,
private bool $hasYield,
private array $throwPoints,
?callable $truthyScopeCallback = null,
?callable $falseyScopeCallback = null,
)
{
$this->scope = $scope;
$this->hasYield = $hasYield;
$this->throwPoints = $throwPoints;
$this->truthyScopeCallback = $truthyScopeCallback;
$this->falseyScopeCallback = $falseyScopeCallback;
}
Expand Down

0 comments on commit 74cb1d9

Please sign in to comment.