Skip to content

Commit 1f6a175

Browse files
authored
Merge branch refs/heads/2.1.x into 2.2.x
2 parents c6a1c9b + cd5a6f6 commit 1f6a175

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+1669
-1422
lines changed

src/Analyser/DirectInternalScopeFactory.php

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
use PhpParser\Node;
66
use PHPStan\Analyser\Fiber\FiberScope;
77
use PHPStan\DependencyInjection\Container;
8-
use PHPStan\DependencyInjection\Type\DynamicReturnTypeExtensionRegistryProvider;
98
use PHPStan\DependencyInjection\Type\ExpressionTypeResolverExtensionRegistryProvider;
109
use PHPStan\Node\Printer\ExprPrinter;
1110
use PHPStan\Parser\Parser;
@@ -28,13 +27,11 @@ public function __construct(
2827
private Container $container,
2928
private ReflectionProvider $reflectionProvider,
3029
private InitializerExprTypeResolver $initializerExprTypeResolver,
31-
private DynamicReturnTypeExtensionRegistryProvider $dynamicReturnTypeExtensionRegistryProvider,
3230
private ExpressionTypeResolverExtensionRegistryProvider $expressionTypeResolverExtensionRegistryProvider,
3331
private ExprPrinter $exprPrinter,
3432
private TypeSpecifier $typeSpecifier,
3533
private PropertyReflectionFinder $propertyReflectionFinder,
3634
private Parser $parser,
37-
private NodeScopeResolver $nodeScopeResolver,
3835
private PhpVersion $phpVersion,
3936
private AttributeReflectionFactory $attributeReflectionFactory,
4037
private int|array|null $configPhpVersion,
@@ -74,13 +71,11 @@ public function create(
7471
$this,
7572
$this->reflectionProvider,
7673
$this->initializerExprTypeResolver,
77-
$this->dynamicReturnTypeExtensionRegistryProvider->getRegistry(),
7874
$this->expressionTypeResolverExtensionRegistryProvider->getRegistry(),
7975
$this->exprPrinter,
8076
$this->typeSpecifier,
8177
$this->propertyReflectionFinder,
8278
$this->parser,
83-
$this->nodeScopeResolver,
8479
$this->constantResolver,
8580
$context,
8681
$this->phpVersion,
@@ -111,13 +106,11 @@ public function toFiberFactory(): InternalScopeFactory
111106
$this->container,
112107
$this->reflectionProvider,
113108
$this->initializerExprTypeResolver,
114-
$this->dynamicReturnTypeExtensionRegistryProvider,
115109
$this->expressionTypeResolverExtensionRegistryProvider,
116110
$this->exprPrinter,
117111
$this->typeSpecifier,
118112
$this->propertyReflectionFinder,
119113
$this->parser,
120-
$this->nodeScopeResolver,
121114
$this->phpVersion,
122115
$this->attributeReflectionFactory,
123116
$this->configPhpVersion,
@@ -133,13 +126,11 @@ public function toMutatingFactory(): InternalScopeFactory
133126
$this->container,
134127
$this->reflectionProvider,
135128
$this->initializerExprTypeResolver,
136-
$this->dynamicReturnTypeExtensionRegistryProvider,
137129
$this->expressionTypeResolverExtensionRegistryProvider,
138130
$this->exprPrinter,
139131
$this->typeSpecifier,
140132
$this->propertyReflectionFinder,
141133
$this->parser,
142-
$this->nodeScopeResolver,
143134
$this->phpVersion,
144135
$this->attributeReflectionFactory,
145136
$this->configPhpVersion,

src/Analyser/DirectInternalScopeFactoryFactory.php

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
use PhpParser\Node;
66
use PHPStan\DependencyInjection\Container;
7-
use PHPStan\DependencyInjection\Type\DynamicReturnTypeExtensionRegistryProvider;
87
use PHPStan\DependencyInjection\Type\ExpressionTypeResolverExtensionRegistryProvider;
98
use PHPStan\Node\Printer\ExprPrinter;
109
use PHPStan\Parser\Parser;
@@ -24,13 +23,11 @@ public function __construct(
2423
private Container $container,
2524
private ReflectionProvider $reflectionProvider,
2625
private InitializerExprTypeResolver $initializerExprTypeResolver,
27-
private DynamicReturnTypeExtensionRegistryProvider $dynamicReturnTypeExtensionRegistryProvider,
2826
private ExpressionTypeResolverExtensionRegistryProvider $expressionTypeResolverExtensionRegistryProvider,
2927
private ExprPrinter $exprPrinter,
3028
private TypeSpecifier $typeSpecifier,
3129
private PropertyReflectionFinder $propertyReflectionFinder,
3230
private Parser $parser,
33-
private NodeScopeResolver $nodeScopeResolver,
3431
private PhpVersion $phpVersion,
3532
private AttributeReflectionFactory $attributeReflectionFactory,
3633
private int|array|null $configPhpVersion,
@@ -48,13 +45,11 @@ public function create(?callable $nodeCallback): DirectInternalScopeFactory
4845
$this->container,
4946
$this->reflectionProvider,
5047
$this->initializerExprTypeResolver,
51-
$this->dynamicReturnTypeExtensionRegistryProvider,
5248
$this->expressionTypeResolverExtensionRegistryProvider,
5349
$this->exprPrinter,
5450
$this->typeSpecifier,
5551
$this->propertyReflectionFinder,
5652
$this->parser,
57-
$this->nodeScopeResolver,
5853
$this->phpVersion,
5954
$this->attributeReflectionFactory,
6055
$this->configPhpVersion,

src/Analyser/ExprHandler.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
use PhpParser\Node;
66
use PhpParser\Node\Expr;
77
use PhpParser\Node\Stmt;
8+
use PHPStan\Type\Type;
89

910
/**
1011
* @template T of Expr
@@ -31,4 +32,9 @@ public function processExpr(
3132
ExpressionContext $context,
3233
): ExpressionResult;
3334

35+
/**
36+
* @param T $expr
37+
*/
38+
public function resolveType(MutatingScope $scope, Expr $expr): Type;
39+
3440
}

src/Analyser/ExprHandler/ArrayDimFetchHandler.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,6 @@ public function supports(Expr $expr): bool
3535
return $expr instanceof ArrayDimFetch;
3636
}
3737

38-
/**
39-
* @param ArrayDimFetch $expr
40-
*/
4138
public function resolveType(MutatingScope $scope, Expr $expr): Type
4239
{
4340
if ($expr->dim === null) {

src/Analyser/ExprHandler/ArrayHandler.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,6 @@ public function supports(Expr $expr): bool
3636
return $expr instanceof Array_;
3737
}
3838

39-
/**
40-
* @param Array_ $expr
41-
*/
4239
public function resolveType(MutatingScope $scope, Expr $expr): Type
4340
{
4441
return $this->initializerExprTypeResolver->getArrayType($expr, static fn (Expr $expr): Type => $scope->getType($expr));

src/Analyser/ExprHandler/ArrowFunctionHandler.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,11 @@
99
use PHPStan\Analyser\ExpressionResult;
1010
use PHPStan\Analyser\ExpressionResultStorage;
1111
use PHPStan\Analyser\ExprHandler;
12+
use PHPStan\Analyser\ExprHandler\Helper\ClosureTypeResolver;
1213
use PHPStan\Analyser\MutatingScope;
1314
use PHPStan\Analyser\NodeScopeResolver;
1415
use PHPStan\DependencyInjection\AutowiredService;
16+
use PHPStan\Type\Type;
1517

1618
/**
1719
* @implements ExprHandler<ArrowFunction>
@@ -20,6 +22,12 @@
2022
final class ArrowFunctionHandler implements ExprHandler
2123
{
2224

25+
public function __construct(
26+
private ClosureTypeResolver $closureTypeResolver,
27+
)
28+
{
29+
}
30+
2331
public function supports(Expr $expr): bool
2432
{
2533
return $expr instanceof ArrowFunction;
@@ -38,4 +46,9 @@ public function processExpr(NodeScopeResolver $nodeScopeResolver, Stmt $stmt, Ex
3846
);
3947
}
4048

49+
public function resolveType(MutatingScope $scope, Expr $expr): Type
50+
{
51+
return $this->closureTypeResolver->getClosureType($scope, $expr);
52+
}
53+
4154
}

src/Analyser/ExprHandler/AssignHandler.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,9 +88,6 @@ public function supports(Expr $expr): bool
8888
return $expr instanceof Assign || $expr instanceof AssignRef;
8989
}
9090

91-
/**
92-
* @param Assign|AssignRef $expr
93-
*/
9491
public function resolveType(MutatingScope $scope, Expr $expr): Type
9592
{
9693
return $scope->getType($expr->expr);

src/Analyser/ExprHandler/AssignOpHandler.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,9 +102,6 @@ static function (MutatingScope $scope) use ($stmt, $expr, $nodeCallback, $contex
102102
);
103103
}
104104

105-
/**
106-
* @param AssignOp $expr
107-
*/
108105
public function resolveType(MutatingScope $scope, Expr $expr): Type
109106
{
110107
$getType = static fn (Expr $expr): Type => $scope->getType($expr);

src/Analyser/ExprHandler/BinaryOpHandler.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,9 +89,6 @@ public function processExpr(NodeScopeResolver $nodeScopeResolver, Stmt $stmt, Ex
8989
);
9090
}
9191

92-
/**
93-
* @param BinaryOp $expr
94-
*/
9592
public function resolveType(MutatingScope $scope, Expr $expr): Type
9693
{
9794
$getType = static fn (Expr $expr): Type => $scope->getType($expr);

src/Analyser/ExprHandler/BitwiseNotHandler.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,6 @@ public function processExpr(NodeScopeResolver $nodeScopeResolver, Stmt $stmt, Ex
4949
);
5050
}
5151

52-
/**
53-
* @param BitwiseNot $expr
54-
*/
5552
public function resolveType(MutatingScope $scope, Expr $expr): Type
5653
{
5754
return $this->initializerExprTypeResolver->getBitwiseNotType($expr->expr, static fn (Expr $expr): Type => $scope->getType($expr));

0 commit comments

Comments
 (0)