Skip to content

Commit 9aae875

Browse files
authored
Removed deprecated ParametersAcceptorSelector::selectSingle() (#796)
fixes #795
1 parent 18fe522 commit 9aae875

13 files changed

+80
-16
lines changed

src/Rules/Deprecations/SymfonyCmfRoutingInClassMethodSignatureRule.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,11 @@ public function processNode(Node $node, Scope $scope): array
4646
// @phpstan-ignore-next-line
4747
$cmfLazyRouteCollectionType = new ObjectType(LazyRouteCollection::class);
4848

49-
$methodSignature = ParametersAcceptorSelector::selectSingle($method->getVariants());
49+
$methodSignature = ParametersAcceptorSelector::selectFromArgs(
50+
$scope,
51+
[],
52+
$method->getVariants()
53+
);
5054

5155
$errors = [];
5256
$errorMessage = 'Parameter $%s of method %s() uses deprecated %s and removed in Drupal 10. Use %s instead.';

src/Type/ContainerDynamicReturnTypeExtension.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,11 @@ public function getTypeFromMethodCall(
4343
MethodCall $methodCall,
4444
Scope $scope
4545
): Type {
46-
$returnType = ParametersAcceptorSelector::selectSingle($methodReflection->getVariants())->getReturnType();
46+
$returnType = ParametersAcceptorSelector::selectFromArgs(
47+
$scope,
48+
$methodCall->getArgs(),
49+
$methodReflection->getVariants()
50+
)->getReturnType();
4751
$methodName = $methodReflection->getName();
4852

4953
if ($methodName === 'has') {

src/Type/DrupalClassResolverDynamicReturnTypeExtension.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,11 @@ public function getTypeFromMethodCall(
4040
Scope $scope
4141
): Type {
4242
if (0 === count($methodCall->getArgs())) {
43-
return ParametersAcceptorSelector::selectSingle($methodReflection->getVariants())->getReturnType();
43+
return ParametersAcceptorSelector::selectFromArgs(
44+
$scope,
45+
$methodCall->getArgs(),
46+
$methodReflection->getVariants()
47+
)->getReturnType();
4448
}
4549

4650
return DrupalClassResolverReturnType::getType($methodReflection, $methodCall, $scope, $this->serviceMap);

src/Type/DrupalClassResolverReturnType.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,11 @@ public static function getType(
2525
): Type {
2626
$arg1 = $scope->getType($methodCall->getArgs()[0]->value);
2727
if (count($arg1->getConstantStrings()) === 0) {
28-
return ParametersAcceptorSelector::selectSingle($methodReflection->getVariants())->getReturnType();
28+
return ParametersAcceptorSelector::selectFromArgs(
29+
$scope,
30+
$methodCall->getArgs(),
31+
$methodReflection->getVariants()
32+
)->getReturnType();
2933
}
3034

3135
$serviceName = $arg1->getConstantStrings()[0];

src/Type/DrupalServiceDynamicReturnTypeExtension.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,11 @@ public function getTypeFromStaticMethodCall(
4444
StaticCall $methodCall,
4545
Scope $scope
4646
): Type {
47-
$returnType = ParametersAcceptorSelector::selectSingle($methodReflection->getVariants())->getReturnType();
47+
$returnType = ParametersAcceptorSelector::selectFromArgs(
48+
$scope,
49+
$methodCall->getArgs(),
50+
$methodReflection->getVariants()
51+
)->getReturnType();
4852
if (!isset($methodCall->args[0])) {
4953
return $returnType;
5054
}

src/Type/DrupalStaticEntityQueryDynamicReturnTypeExtension.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,11 @@ public function getTypeFromStaticMethodCall(
4545
StaticCall $methodCall,
4646
Scope $scope
4747
): Type {
48-
$returnType = ParametersAcceptorSelector::selectSingle($methodReflection->getVariants())->getReturnType();
48+
$returnType = ParametersAcceptorSelector::selectFromArgs(
49+
$scope,
50+
$methodCall->getArgs(),
51+
$methodReflection->getVariants()
52+
)->getReturnType();
4953
if (!$returnType instanceof ObjectType) {
5054
return $returnType;
5155
}

src/Type/EntityQuery/AccessCheckTypeSpecifyingExtension.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,11 @@ public function specifyTypes(
4040
Scope $scope,
4141
TypeSpecifierContext $context
4242
): SpecifiedTypes {
43-
$returnType = ParametersAcceptorSelector::selectSingle($methodReflection->getVariants())->getReturnType();
43+
$returnType = ParametersAcceptorSelector::selectFromArgs(
44+
$scope,
45+
[],
46+
$methodReflection->getVariants()
47+
)->getReturnType();
4448
$expr = $node->var;
4549
if (!$returnType instanceof EntityQueryType) {
4650
return new SpecifiedTypes([]);

src/Type/EntityQuery/EntityQueryAccessCheckDynamicReturnTypeExtension.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,11 @@ public function getTypeFromMethodCall(
3232
$varType = $scope->getType($methodCall->var);
3333

3434
if (!$varType instanceof EntityQueryType) {
35-
return ParametersAcceptorSelector::selectSingle($methodReflection->getVariants())->getReturnType();
35+
return ParametersAcceptorSelector::selectFromArgs(
36+
$scope,
37+
$methodCall->getArgs(),
38+
$methodReflection->getVariants()
39+
)->getReturnType();
3640
}
3741

3842
return $varType->withAccessCheck();

src/Type/EntityQuery/EntityQueryDynamicReturnTypeExtension.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,11 @@ public function getTypeFromMethodCall(
3636
MethodCall $methodCall,
3737
Scope $scope
3838
): Type {
39-
$defaultReturnType = ParametersAcceptorSelector::selectSingle($methodReflection->getVariants())->getReturnType();
39+
$defaultReturnType = ParametersAcceptorSelector::selectFromArgs(
40+
$scope,
41+
$methodCall->getArgs(),
42+
$methodReflection->getVariants()
43+
)->getReturnType();
4044
$varType = $scope->getType($methodCall->var);
4145
$methodName = $methodReflection->getName();
4246

src/Type/EntityRepositoryReturnTypeExtension.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,11 @@ public function getTypeFromMethodCall(
6161
): ?Type {
6262
$methodName = $methodReflection->getName();
6363
$methodArgs = $methodCall->getArgs();
64-
$returnType = ParametersAcceptorSelector::selectSingle($methodReflection->getVariants())->getReturnType();
64+
$returnType = ParametersAcceptorSelector::selectFromArgs(
65+
$scope,
66+
$methodCall->getArgs(),
67+
$methodReflection->getVariants()
68+
)->getReturnType();
6569

6670
if (count($methodArgs) === 0) {
6771
return $returnType;

0 commit comments

Comments
 (0)