Skip to content

Commit

Permalink
Manual changes
Browse files Browse the repository at this point in the history
  • Loading branch information
ondrejmirtes committed Jan 5, 2022
1 parent 63fae98 commit e086607
Show file tree
Hide file tree
Showing 19 changed files with 36 additions and 105 deletions.
5 changes: 2 additions & 3 deletions src/Analyser/DirectScopeFactory.php
Expand Up @@ -45,8 +45,7 @@ public function __construct(
}

/**
* @param array<string, Type> $constantTypes
* @param FunctionReflection|MethodReflection|null $function
* @param array<string, Type> $constantTypes
* @param VariableTypeHolder[] $variablesTypes
* @param VariableTypeHolder[] $moreSpecificTypes
* @param array<string, ConditionalExpressionHolder[]> $conditionalExpressions
Expand All @@ -59,7 +58,7 @@ public function create(
ScopeContext $context,
bool $declareStrictTypes = false,
array $constantTypes = [],
$function = null,
FunctionReflection|MethodReflection|null $function = null,
?string $namespace = null,
array $variablesTypes = [],
array $moreSpecificTypes = [],
Expand Down
6 changes: 1 addition & 5 deletions src/Analyser/Error.php
Expand Up @@ -14,23 +14,20 @@
class Error implements JsonSerializable
{

private bool|Throwable $canBeIgnored;

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

/**
* Error constructor.
*
* @param bool|Throwable $canBeIgnored
* @param class-string<Node>|null $nodeType
* @param mixed[] $metadata
*/
public function __construct(
private string $message,
private string $file,
private ?int $line = null,
$canBeIgnored = true,
private bool|Throwable $canBeIgnored = true,
private ?string $filePath = null,
private ?string $traitFilePath = null,
private ?string $tip = null,
Expand All @@ -40,7 +37,6 @@ public function __construct(
private array $metadata = [],
)
{
$this->canBeIgnored = $canBeIgnored;
$this->nodeType = $nodeType;
}

Expand Down
3 changes: 1 addition & 2 deletions src/Analyser/LazyScopeFactory.php
Expand Up @@ -35,7 +35,6 @@ public function __construct(

/**
* @param array<string, Type> $constantTypes
* @param FunctionReflection|MethodReflection|null $function
* @param VariableTypeHolder[] $variablesTypes
* @param VariableTypeHolder[] $moreSpecificTypes
* @param array<string, ConditionalExpressionHolder[]> $conditionalExpressions
Expand All @@ -48,7 +47,7 @@ public function create(
ScopeContext $context,
bool $declareStrictTypes = false,
array $constantTypes = [],
$function = null,
FunctionReflection|MethodReflection|null $function = null,
?string $namespace = null,
array $variablesTypes = [],
array $moreSpecificTypes = [],
Expand Down
14 changes: 3 additions & 11 deletions src/Analyser/MutatingScope.php
Expand Up @@ -146,17 +146,11 @@ class MutatingScope implements Scope
/** @var Type[] */
private array $resolvedTypes = [];

private FunctionReflection|MethodReflection|null $function = null;

private ?string $namespace;

/** @var VariableTypeHolder[] */
private array $variableTypes;

/**
* @param array<string, Type> $constantTypes
* @param FunctionReflection|MethodReflection|null $function
* @param VariableTypeHolder[] $variablesTypes
* @param VariableTypeHolder[] $variableTypes
* @param VariableTypeHolder[] $moreSpecificTypes
* @param array<string, ConditionalExpressionHolder[]> $conditionalExpressions
* @param array<string, true> $currentlyAssignedExpressions
Expand All @@ -178,9 +172,9 @@ public function __construct(
private PhpVersion $phpVersion,
private bool $declareStrictTypes = false,
private array $constantTypes = [],
$function = null,
private FunctionReflection|MethodReflection|null $function = null,
?string $namespace = null,
array $variablesTypes = [],
private array $variableTypes = [],
private array $moreSpecificTypes = [],
private array $conditionalExpressions = [],
private ?string $inClosureBindScopeClass = null,
Expand All @@ -199,9 +193,7 @@ public function __construct(
$namespace = null;
}

$this->function = $function;
$this->namespace = $namespace;
$this->variableTypes = $variablesTypes;
}

/** @api */
Expand Down
6 changes: 1 addition & 5 deletions src/Analyser/NodeScopeResolver.php
Expand Up @@ -154,9 +154,6 @@ class NodeScopeResolver
private const LOOP_SCOPE_ITERATIONS = 3;
private const GENERALIZE_AFTER_ITERATION = 1;

/** @var string[][] className(string) => methods(string[]) */
private array $earlyTerminatingMethodCalls;

/** @var bool[] filePath(string) => bool(true) */
private array $analysedFiles = [];

Expand All @@ -178,12 +175,11 @@ public function __construct(
private DynamicThrowTypeExtensionProvider $dynamicThrowTypeExtensionProvider,
private bool $polluteScopeWithLoopInitialAssignments,
private bool $polluteScopeWithAlwaysIterableForeach,
array $earlyTerminatingMethodCalls,
private array $earlyTerminatingMethodCalls,
private array $earlyTerminatingFunctionCalls,
private bool $implicitThrows,
)
{
$this->earlyTerminatingMethodCalls = $earlyTerminatingMethodCalls;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/Analyser/ResultCache/ResultCacheManager.php
Expand Up @@ -74,7 +74,7 @@ public function __construct(
private array $bootstrapFiles,
private array $scanFiles,
private array $scanDirectories,
private array $fileReplacements = [],
private array $fileReplacements,
private bool $checkDependenciesOfProjectExtensionFiles,
)
{
Expand Down
3 changes: 1 addition & 2 deletions src/Analyser/ScopeFactory.php
Expand Up @@ -13,7 +13,6 @@ interface ScopeFactory
/**
* @api
* @param array<string, Type> $constantTypes
* @param FunctionReflection|MethodReflection|null $function
* @param VariableTypeHolder[] $variablesTypes
* @param VariableTypeHolder[] $moreSpecificTypes
* @param array<string, ConditionalExpressionHolder[]> $conditionalExpressions
Expand All @@ -26,7 +25,7 @@ public function create(
ScopeContext $context,
bool $declareStrictTypes = false,
array $constantTypes = [],
$function = null,
FunctionReflection|MethodReflection|null $function = null,
?string $namespace = null,
array $variablesTypes = [],
array $moreSpecificTypes = [],
Expand Down
2 changes: 1 addition & 1 deletion src/Command/InceptionResult.php
Expand Up @@ -16,7 +16,7 @@ class InceptionResult

/**
* @param callable(): (array{string[], bool}) $filesCallback
* @param mixed[] $projectConfigArray
* @param mixed[]|null $projectConfigArray
*/
public function __construct(
callable $filesCallback,
Expand Down
8 changes: 1 addition & 7 deletions src/Node/BooleanAndNode.php
Expand Up @@ -11,15 +11,9 @@
class BooleanAndNode extends NodeAbstract implements VirtualNode
{

private BooleanAnd|LogicalAnd $originalNode;

/**
* @param BooleanAnd|LogicalAnd $originalNode
*/
public function __construct($originalNode, private Scope $rightScope)
public function __construct(private BooleanAnd|LogicalAnd $originalNode, private Scope $rightScope)
{
parent::__construct($originalNode->getAttributes());
$this->originalNode = $originalNode;
}

/**
Expand Down
8 changes: 1 addition & 7 deletions src/Node/BooleanOrNode.php
Expand Up @@ -11,15 +11,9 @@
class BooleanOrNode extends NodeAbstract implements VirtualNode
{

private BooleanOr|LogicalOr $originalNode;

/**
* @param BooleanOr|LogicalOr $originalNode
*/
public function __construct($originalNode, private Scope $rightScope)
public function __construct(private BooleanOr|LogicalOr $originalNode, private Scope $rightScope)
{
parent::__construct($originalNode->getAttributes());
$this->originalNode = $originalNode;
}

/**
Expand Down
8 changes: 1 addition & 7 deletions src/Node/ClassPropertyNode.php
Expand Up @@ -13,23 +13,17 @@
class ClassPropertyNode extends NodeAbstract implements VirtualNode
{

private Identifier|Name|Node\ComplexType|null $type = null;

/**
* @param Identifier|Name|Node\ComplexType|null $type
*/
public function __construct(
private string $name,
private int $flags,
$type,
private Identifier|Name|Node\ComplexType|null $type,
private ?Expr $default,
private ?string $phpDoc,
private bool $isPromoted,
Node $originalNode,
)
{
parent::__construct($originalNode->getAttributes());
$this->type = $type;
}

public function getName(): string
Expand Down
6 changes: 1 addition & 5 deletions src/Node/FunctionCallableNode.php
Expand Up @@ -9,16 +9,12 @@
class FunctionCallableNode extends Expr implements VirtualNode
{

private Name|Expr $name;

/**
* @param Expr|Name $name
* @param mixed[] $attributes
*/
public function __construct($name, array $attributes = [])
public function __construct(private Name|Expr $name, array $attributes = [])
{
parent::__construct($attributes);
$this->name = $name;
}

/**
Expand Down
6 changes: 1 addition & 5 deletions src/Node/InstantiationCallableNode.php
Expand Up @@ -9,16 +9,12 @@
class InstantiationCallableNode extends Expr implements VirtualNode
{

private Name|Expr $class;

/**
* @param Expr|Name $class
* @param mixed[] $attributes
*/
public function __construct($class, array $attributes = [])
public function __construct(private Name|Expr $class, array $attributes = [])
{
parent::__construct($attributes);
$this->class = $class;
}

/**
Expand Down
11 changes: 4 additions & 7 deletions src/Node/Method/MethodCall.php
Expand Up @@ -11,14 +11,11 @@
class MethodCall
{

private Node\Expr\MethodCall|StaticCall|Array_ $node;

/**
* @param Node\Expr\MethodCall|StaticCall|Array_ $node
*/
public function __construct($node, private Scope $scope)
public function __construct(
private Node\Expr\MethodCall|StaticCall|Array_ $node,
private Scope $scope,
)
{
$this->node = $node;
}

/**
Expand Down
12 changes: 5 additions & 7 deletions src/Node/MethodCallableNode.php
Expand Up @@ -9,15 +9,13 @@
class MethodCallableNode extends Expr implements VirtualNode
{

private Identifier|Expr $name;

/**
* @param Expr|Identifier $name
*/
public function __construct(private Expr $var, $name, private Expr\MethodCall $originalNode)
public function __construct(
private Expr $var,
private Identifier|Expr $name,
private Expr\MethodCall $originalNode,
)
{
parent::__construct($originalNode->getAttributes());
$this->name = $name;
}

public function getVar(): Expr
Expand Down
13 changes: 4 additions & 9 deletions src/Node/Property/PropertyRead.php
Expand Up @@ -10,16 +10,11 @@
class PropertyRead
{

private PropertyFetch|StaticPropertyFetch $fetch;

/**
* PropertyWrite constructor.
*
* @param PropertyFetch|StaticPropertyFetch $fetch
*/
public function __construct($fetch, private Scope $scope)
public function __construct(
private PropertyFetch|StaticPropertyFetch $fetch,
private Scope $scope,
)
{
$this->fetch = $fetch;
}

/**
Expand Down
10 changes: 1 addition & 9 deletions src/Node/Property/PropertyWrite.php
Expand Up @@ -10,16 +10,8 @@
class PropertyWrite
{

private PropertyFetch|StaticPropertyFetch $fetch;

/**
* PropertyWrite constructor.
*
* @param PropertyFetch|StaticPropertyFetch $fetch
*/
public function __construct($fetch, private Scope $scope)
public function __construct(private PropertyFetch|StaticPropertyFetch $fetch, private Scope $scope)
{
$this->fetch = $fetch;
}

/**
Expand Down
16 changes: 5 additions & 11 deletions src/Node/StaticMethodCallableNode.php
Expand Up @@ -10,19 +10,13 @@
class StaticMethodCallableNode extends Expr implements VirtualNode
{

private Name|Expr $class;

private Identifier|Expr $name;

/**
* @param Name|Expr $class
* @param Identifier|Expr $name
*/
public function __construct($class, $name, private Expr\StaticCall $originalNode)
public function __construct(
private Name|Expr $class,
private Identifier|Expr $name,
private Expr\StaticCall $originalNode,
)
{
parent::__construct($originalNode->getAttributes());
$this->class = $class;
$this->name = $name;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/Type/Constant/ConstantArrayTypeBuilder.php
Expand Up @@ -23,7 +23,7 @@ class ConstantArrayTypeBuilder
private bool $degradeToGeneralArray = false;

/**
* @param array<int, ConstantIntegerType|ConstantStringType> $keyTypes
* @param array<int, Type> $keyTypes
* @param array<int, Type> $valueTypes
* @param array<int> $optionalKeys
*/
Expand Down

0 comments on commit e086607

Please sign in to comment.