Skip to content

Commit 249707a

Browse files
authored
Merge branch 'main' into field-type-deprecated-translated-category
2 parents a4d4a19 + 9aae875 commit 249707a

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;

src/Type/EntityStorage/EntityStorageDynamicReturnTypeExtension.php

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,21 +58,33 @@ public function getTypeFromMethodCall(
5858
): Type {
5959
$callerType = $scope->getType($methodCall->var);
6060
if (!$callerType instanceof ObjectType) {
61-
return ParametersAcceptorSelector::selectSingle($methodReflection->getVariants())->getReturnType();
61+
return ParametersAcceptorSelector::selectFromArgs(
62+
$scope,
63+
$methodCall->getArgs(),
64+
$methodReflection->getVariants()
65+
)->getReturnType();
6266
}
6367

6468
if (!$callerType instanceof EntityStorageType) {
6569
$resolvedEntityType = $this->entityDataRepository->resolveFromStorage($callerType);
6670
if ($resolvedEntityType === null) {
67-
return ParametersAcceptorSelector::selectSingle($methodReflection->getVariants())->getReturnType();
71+
return ParametersAcceptorSelector::selectFromArgs(
72+
$scope,
73+
$methodCall->getArgs(),
74+
$methodReflection->getVariants()
75+
)->getReturnType();
6876
}
6977
$type = $resolvedEntityType->getClassType();
7078
} else {
7179
$type = $this->entityDataRepository->get($callerType->getEntityTypeId())->getClassType();
7280
}
7381

7482
if ($type === null) {
75-
return ParametersAcceptorSelector::selectSingle($methodReflection->getVariants())->getReturnType();
83+
return ParametersAcceptorSelector::selectFromArgs(
84+
$scope,
85+
$methodCall->getArgs(),
86+
$methodReflection->getVariants()
87+
)->getReturnType();
7688
}
7789
if (in_array($methodReflection->getName(), ['load', 'loadUnchanged'], true)) {
7890
return TypeCombinator::addNull($type);
@@ -90,6 +102,10 @@ public function getTypeFromMethodCall(
90102
return $type;
91103
}
92104

93-
return ParametersAcceptorSelector::selectSingle($methodReflection->getVariants())->getReturnType();
105+
return ParametersAcceptorSelector::selectFromArgs(
106+
$scope,
107+
$methodCall->getArgs(),
108+
$methodReflection->getVariants()
109+
)->getReturnType();
94110
}
95111
}

src/Type/EntityStorage/GetQueryReturnTypeExtension.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,11 @@ public function getTypeFromMethodCall(
3838
MethodCall $methodCall,
3939
Scope $scope
4040
): Type {
41-
$returnType = ParametersAcceptorSelector::selectSingle($methodReflection->getVariants())->getReturnType();
41+
$returnType = ParametersAcceptorSelector::selectFromArgs(
42+
$scope,
43+
$methodCall->getArgs(),
44+
$methodReflection->getVariants()
45+
)->getReturnType();
4246
if (!$returnType instanceof ObjectType) {
4347
return $returnType;
4448
}

src/Type/EntityTypeManagerGetStorageDynamicReturnTypeExtension.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,11 @@ public function getTypeFromMethodCall(
4848
MethodCall $methodCall,
4949
Scope $scope
5050
): Type {
51-
$returnType = ParametersAcceptorSelector::selectSingle($methodReflection->getVariants())->getReturnType();
51+
$returnType = ParametersAcceptorSelector::selectFromArgs(
52+
$scope,
53+
$methodCall->getArgs(),
54+
$methodReflection->getVariants()
55+
)->getReturnType();
5256
if (!isset($methodCall->args[0])) {
5357
// Parameter is required.
5458
throw new ShouldNotHappenException();

0 commit comments

Comments
 (0)