Skip to content

Commit 84541f0

Browse files
committed
Improve compatibility with nikic/php-parser 4.13.0
1 parent a0ce7fd commit 84541f0

23 files changed

+55
-55
lines changed

src/Rules/Symfony/ContainerInterfacePrivateServiceRule.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public function processNode(Node $node, Scope $scope): array
4545
return [];
4646
}
4747

48-
if ($node->name->name !== 'get' || !isset($node->args[0])) {
48+
if ($node->name->name !== 'get' || !isset($node->getArgs()[0])) {
4949
return [];
5050
}
5151

@@ -72,7 +72,7 @@ public function processNode(Node $node, Scope $scope): array
7272
return [];
7373
}
7474

75-
$serviceId = $this->serviceMap::getServiceIdFromNode($node->args[0]->value, $scope);
75+
$serviceId = $this->serviceMap::getServiceIdFromNode($node->getArgs()[0]->value, $scope);
7676
if ($serviceId !== null) {
7777
$service = $this->serviceMap->getService($serviceId);
7878
if ($service !== null && !$service->isPublic()) {

src/Rules/Symfony/ContainerInterfaceUnknownServiceRule.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public function processNode(Node $node, Scope $scope): array
5050
return [];
5151
}
5252

53-
if ($node->name->name !== 'get' || !isset($node->args[0])) {
53+
if ($node->name->name !== 'get' || !isset($node->getArgs()[0])) {
5454
return [];
5555
}
5656

@@ -73,10 +73,10 @@ public function processNode(Node $node, Scope $scope): array
7373
return [];
7474
}
7575

76-
$serviceId = $this->serviceMap::getServiceIdFromNode($node->args[0]->value, $scope);
76+
$serviceId = $this->serviceMap::getServiceIdFromNode($node->getArgs()[0]->value, $scope);
7777
if ($serviceId !== null) {
7878
$service = $this->serviceMap->getService($serviceId);
79-
$serviceIdType = $scope->getType($node->args[0]->value);
79+
$serviceIdType = $scope->getType($node->getArgs()[0]->value);
8080
if ($service === null && !$scope->getType(Helper::createMarkerNode($node->var, $serviceIdType, $this->printer))->equals($serviceIdType)) {
8181
return [sprintf('Service "%s" is not registered in the container.', $serviceId)];
8282
}

src/Rules/Symfony/InvalidArgumentDefaultValueRule.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,11 @@ public function processNode(Node $node, Scope $scope): array
4646
if (!$node->name instanceof Node\Identifier || $node->name->name !== 'addArgument') {
4747
return [];
4848
}
49-
if (!isset($node->args[3])) {
49+
if (!isset($node->getArgs()[3])) {
5050
return [];
5151
}
5252

53-
$modeType = isset($node->args[1]) ? $scope->getType($node->args[1]->value) : new NullType();
53+
$modeType = isset($node->getArgs()[1]) ? $scope->getType($node->getArgs()[1]->value) : new NullType();
5454
if ($modeType instanceof NullType) {
5555
$modeType = new ConstantIntegerType(2); // InputArgument::OPTIONAL
5656
}
@@ -63,7 +63,7 @@ public function processNode(Node $node, Scope $scope): array
6363
}
6464
$mode = $modeTypes[0]->getValue();
6565

66-
$defaultType = $scope->getType($node->args[3]->value);
66+
$defaultType = $scope->getType($node->getArgs()[3]->value);
6767

6868
// not an array
6969
if (($mode & 4) !== 4 && !(new UnionType([new StringType(), new NullType()]))->isSuperTypeOf($defaultType)->yes()) {

src/Rules/Symfony/InvalidOptionDefaultValueRule.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,11 @@ public function processNode(Node $node, Scope $scope): array
4848
if (!$node->name instanceof Node\Identifier || $node->name->name !== 'addOption') {
4949
return [];
5050
}
51-
if (!isset($node->args[4])) {
51+
if (!isset($node->getArgs()[4])) {
5252
return [];
5353
}
5454

55-
$modeType = isset($node->args[2]) ? $scope->getType($node->args[2]->value) : new NullType();
55+
$modeType = isset($node->getArgs()[2]) ? $scope->getType($node->getArgs()[2]->value) : new NullType();
5656
if ($modeType instanceof NullType) {
5757
$modeType = new ConstantIntegerType(1); // InputOption::VALUE_NONE
5858
}
@@ -65,7 +65,7 @@ public function processNode(Node $node, Scope $scope): array
6565
}
6666
$mode = $modeTypes[0]->getValue();
6767

68-
$defaultType = $scope->getType($node->args[4]->value);
68+
$defaultType = $scope->getType($node->getArgs()[4]->value);
6969

7070
// not an array
7171
if (($mode & 8) !== 8) {

src/Rules/Symfony/UndefinedArgumentRule.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -64,11 +64,11 @@ public function processNode(Node $node, Scope $scope): array
6464
if (!$node->name instanceof Node\Identifier || $node->name->name !== 'getArgument') {
6565
return [];
6666
}
67-
if (!isset($node->args[0])) {
67+
if (!isset($node->getArgs()[0])) {
6868
return [];
6969
}
7070

71-
$argType = $scope->getType($node->args[0]->value);
71+
$argType = $scope->getType($node->getArgs()[0]->value);
7272
$argStrings = TypeUtils::getConstantStrings($argType);
7373
if (count($argStrings) !== 1) {
7474
return [];

src/Rules/Symfony/UndefinedOptionRule.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -64,11 +64,11 @@ public function processNode(Node $node, Scope $scope): array
6464
if (!$node->name instanceof Node\Identifier || $node->name->name !== 'getOption') {
6565
return [];
6666
}
67-
if (!isset($node->args[0])) {
67+
if (!isset($node->getArgs()[0])) {
6868
return [];
6969
}
7070

71-
$optType = $scope->getType($node->args[0]->value);
71+
$optType = $scope->getType($node->getArgs()[0]->value);
7272
$optStrings = TypeUtils::getConstantStrings($optType);
7373
if (count($optStrings) !== 1) {
7474
return [];

src/Type/Symfony/ArgumentTypeSpecifyingExtension.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,10 @@ public function isMethodSupported(MethodReflection $methodReflection, MethodCall
3838

3939
public function specifyTypes(MethodReflection $methodReflection, MethodCall $node, Scope $scope, TypeSpecifierContext $context): SpecifiedTypes
4040
{
41-
if (!isset($node->args[0])) {
41+
if (!isset($node->getArgs()[0])) {
4242
return new SpecifiedTypes();
4343
}
44-
$argType = $scope->getType($node->args[0]->value);
44+
$argType = $scope->getType($node->getArgs()[0]->value);
4545
return $this->typeSpecifier->create(
4646
Helper::createMarkerNode($node->var, $argType, $this->printer),
4747
$argType,

src/Type/Symfony/Config/ArrayNodeDefinitionPrototypeDynamicReturnTypeExtension.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -56,11 +56,11 @@ public function getTypeFromMethodCall(
5656
$defaultType = ParametersAcceptorSelector::selectSingle($methodReflection->getVariants())->getReturnType();
5757

5858
if ($methodReflection->getName() === 'prototype') {
59-
if (!isset($methodCall->args[0])) {
59+
if (!isset($methodCall->getArgs()[0])) {
6060
return $defaultType;
6161
}
6262

63-
$argStrings = TypeUtils::getConstantStrings($scope->getType($methodCall->args[0]->value));
63+
$argStrings = TypeUtils::getConstantStrings($scope->getType($methodCall->getArgs()[0]->value));
6464
if (count($argStrings) === 1 && isset(self::MAPPING[$argStrings[0]->getValue()])) {
6565
$type = $argStrings[0]->getValue();
6666

src/Type/Symfony/Config/TreeBuilderDynamicReturnTypeExtension.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ public function getTypeFromStaticMethodCall(MethodReflection $methodReflection,
4444

4545
$type = 'array';
4646

47-
if (isset($methodCall->args[1])) {
48-
$argStrings = TypeUtils::getConstantStrings($scope->getType($methodCall->args[1]->value));
47+
if (isset($methodCall->getArgs()[1])) {
48+
$argStrings = TypeUtils::getConstantStrings($scope->getType($methodCall->getArgs()[1]->value));
4949
if (count($argStrings) === 1 && isset(self::MAPPING[$argStrings[0]->getValue()])) {
5050
$type = $argStrings[0]->getValue();
5151
}

src/Type/Symfony/EnvelopeReturnTypeExtension.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,11 @@ public function getTypeFromMethodCall(
3131
Scope $scope
3232
): Type
3333
{
34-
if (count($methodCall->args) === 0) {
34+
if (count($methodCall->getArgs()) === 0) {
3535
return new ArrayType(new MixedType(), new ArrayType(new MixedType(), new ObjectType('Symfony\Component\Messenger\Stamp\StampInterface')));
3636
}
3737

38-
$argType = $scope->getType($methodCall->args[0]->value);
38+
$argType = $scope->getType($methodCall->getArgs()[0]->value);
3939
if (!$argType instanceof ConstantStringType) {
4040
return new ArrayType(new MixedType(), new ObjectType('Symfony\Component\Messenger\Stamp\StampInterface'));
4141
}

src/Type/Symfony/HeaderBagDynamicReturnTypeExtension.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,13 @@ public function getTypeFromMethodCall(
3434
Scope $scope
3535
): Type
3636
{
37-
$firstArgType = isset($methodCall->args[2]) ? $scope->getType($methodCall->args[2]->value) : new ConstantBooleanType(true);
37+
$firstArgType = isset($methodCall->getArgs()[2]) ? $scope->getType($methodCall->getArgs()[2]->value) : new ConstantBooleanType(true);
3838
$isTrueType = (new ConstantBooleanType(true))->isSuperTypeOf($firstArgType);
3939
$isFalseType = (new ConstantBooleanType(false))->isSuperTypeOf($firstArgType);
4040
$compareTypes = $isTrueType->compareTo($isFalseType);
4141

4242
if ($compareTypes === $isTrueType) {
43-
$defaultArgType = isset($methodCall->args[1]) ? $scope->getType($methodCall->args[1]->value) : new NullType();
43+
$defaultArgType = isset($methodCall->getArgs()[1]) ? $scope->getType($methodCall->getArgs()[1]->value) : new NullType();
4444

4545
return TypeCombinator::union($defaultArgType, new StringType());
4646
}

src/Type/Symfony/InputBagDynamicReturnTypeExtension.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,8 @@ private function getGetTypeFromMethodCall(
5555
Scope $scope
5656
): Type
5757
{
58-
if (isset($methodCall->args[1])) {
59-
$argType = $scope->getType($methodCall->args[1]->value);
58+
if (isset($methodCall->getArgs()[1])) {
59+
$argType = $scope->getType($methodCall->getArgs()[1]->value);
6060
$isNull = (new NullType())->isSuperTypeOf($argType);
6161
if ($isNull->no()) {
6262
return TypeCombinator::removeNull(ParametersAcceptorSelector::selectSingle($methodReflection->getVariants())->getReturnType());
@@ -77,7 +77,7 @@ private function getAllTypeFromMethodCall(
7777
new StringType(),
7878
];
7979
$oneParameterType = new UnionType($types);
80-
if (isset($methodCall->args[0])) {
80+
if (isset($methodCall->getArgs()[0])) {
8181
return new ArrayType(new MixedType(), $oneParameterType);
8282
}
8383

src/Type/Symfony/InputInterfaceGetArgumentDynamicReturnTypeExtension.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,9 @@ public function isMethodSupported(MethodReflection $methodReflection): bool
4040

4141
public function getTypeFromMethodCall(MethodReflection $methodReflection, MethodCall $methodCall, Scope $scope): Type
4242
{
43-
$defaultReturnType = ParametersAcceptorSelector::selectFromArgs($scope, $methodCall->args, $methodReflection->getVariants())->getReturnType();
43+
$defaultReturnType = ParametersAcceptorSelector::selectFromArgs($scope, $methodCall->getArgs(), $methodReflection->getVariants())->getReturnType();
4444

45-
if (!isset($methodCall->args[0])) {
45+
if (!isset($methodCall->getArgs()[0])) {
4646
return $defaultReturnType;
4747
}
4848

@@ -51,7 +51,7 @@ public function getTypeFromMethodCall(MethodReflection $methodReflection, Method
5151
return $defaultReturnType;
5252
}
5353

54-
$argStrings = TypeUtils::getConstantStrings($scope->getType($methodCall->args[0]->value));
54+
$argStrings = TypeUtils::getConstantStrings($scope->getType($methodCall->getArgs()[0]->value));
5555
if (count($argStrings) !== 1) {
5656
return $defaultReturnType;
5757
}

src/Type/Symfony/InputInterfaceGetOptionDynamicReturnTypeExtension.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,9 @@ public function isMethodSupported(MethodReflection $methodReflection): bool
4242

4343
public function getTypeFromMethodCall(MethodReflection $methodReflection, MethodCall $methodCall, Scope $scope): Type
4444
{
45-
$defaultReturnType = ParametersAcceptorSelector::selectFromArgs($scope, $methodCall->args, $methodReflection->getVariants())->getReturnType();
45+
$defaultReturnType = ParametersAcceptorSelector::selectFromArgs($scope, $methodCall->getArgs(), $methodReflection->getVariants())->getReturnType();
4646

47-
if (!isset($methodCall->args[0])) {
47+
if (!isset($methodCall->getArgs()[0])) {
4848
return $defaultReturnType;
4949
}
5050

@@ -53,7 +53,7 @@ public function getTypeFromMethodCall(MethodReflection $methodReflection, Method
5353
return $defaultReturnType;
5454
}
5555

56-
$optStrings = TypeUtils::getConstantStrings($scope->getType($methodCall->args[0]->value));
56+
$optStrings = TypeUtils::getConstantStrings($scope->getType($methodCall->getArgs()[0]->value));
5757
if (count($optStrings) !== 1) {
5858
return $defaultReturnType;
5959
}

src/Type/Symfony/InputInterfaceHasArgumentDynamicReturnTypeExtension.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public function getTypeFromMethodCall(MethodReflection $methodReflection, Method
4040
{
4141
$defaultReturnType = new BooleanType();
4242

43-
if (!isset($methodCall->args[0])) {
43+
if (!isset($methodCall->getArgs()[0])) {
4444
return $defaultReturnType;
4545
}
4646

@@ -49,7 +49,7 @@ public function getTypeFromMethodCall(MethodReflection $methodReflection, Method
4949
return $defaultReturnType;
5050
}
5151

52-
$argStrings = TypeUtils::getConstantStrings($scope->getType($methodCall->args[0]->value));
52+
$argStrings = TypeUtils::getConstantStrings($scope->getType($methodCall->getArgs()[0]->value));
5353
if (count($argStrings) !== 1) {
5454
return $defaultReturnType;
5555
}

src/Type/Symfony/InputInterfaceHasOptionDynamicReturnTypeExtension.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public function getTypeFromMethodCall(MethodReflection $methodReflection, Method
4040
{
4141
$defaultReturnType = new BooleanType();
4242

43-
if (!isset($methodCall->args[0])) {
43+
if (!isset($methodCall->getArgs()[0])) {
4444
return $defaultReturnType;
4545
}
4646

@@ -49,7 +49,7 @@ public function getTypeFromMethodCall(MethodReflection $methodReflection, Method
4949
return $defaultReturnType;
5050
}
5151

52-
$optStrings = TypeUtils::getConstantStrings($scope->getType($methodCall->args[0]->value));
52+
$optStrings = TypeUtils::getConstantStrings($scope->getType($methodCall->getArgs()[0]->value));
5353
if (count($optStrings) !== 1) {
5454
return $defaultReturnType;
5555
}

src/Type/Symfony/KernelInterfaceDynamicReturnTypeExtension.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public function getTypeFromMethodCall(
3232
Scope $scope
3333
): Type
3434
{
35-
$firstArgType = isset($methodCall->args[2]) ? $scope->getType($methodCall->args[2]->value) : new ConstantBooleanType(true);
35+
$firstArgType = isset($methodCall->getArgs()[2]) ? $scope->getType($methodCall->getArgs()[2]->value) : new ConstantBooleanType(true);
3636
$isTrueType = (new ConstantBooleanType(true))->isSuperTypeOf($firstArgType);
3737
$isFalseType = (new ConstantBooleanType(false))->isSuperTypeOf($firstArgType);
3838
$compareTypes = $isTrueType->compareTo($isFalseType);

src/Type/Symfony/OptionTypeSpecifyingExtension.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,10 @@ public function isMethodSupported(MethodReflection $methodReflection, MethodCall
3838

3939
public function specifyTypes(MethodReflection $methodReflection, MethodCall $node, Scope $scope, TypeSpecifierContext $context): SpecifiedTypes
4040
{
41-
if (!isset($node->args[0])) {
41+
if (!isset($node->getArgs()[0])) {
4242
return new SpecifiedTypes();
4343
}
44-
$argType = $scope->getType($node->args[0]->value);
44+
$argType = $scope->getType($node->getArgs()[0]->value);
4545
return $this->typeSpecifier->create(
4646
Helper::createMarkerNode($node->var, $argType, $this->printer),
4747
$argType,

src/Type/Symfony/ParameterDynamicReturnTypeExtension.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -92,11 +92,11 @@ private function getGetTypeFromMethodCall(
9292
new StringType(),
9393
new NullType(),
9494
]);
95-
if (!isset($methodCall->args[0])) {
95+
if (!isset($methodCall->getArgs()[0])) {
9696
return $returnType;
9797
}
9898

99-
$parameterKey = $this->parameterMap::getParameterKeyFromNode($methodCall->args[0]->value, $scope);
99+
$parameterKey = $this->parameterMap::getParameterKeyFromNode($methodCall->getArgs()[0]->value, $scope);
100100
if ($parameterKey !== null) {
101101
$parameter = $this->parameterMap->getParameter($parameterKey);
102102
if ($parameter !== null) {
@@ -130,11 +130,11 @@ private function getHasTypeFromMethodCall(
130130
): Type
131131
{
132132
$returnType = ParametersAcceptorSelector::selectSingle($methodReflection->getVariants())->getReturnType();
133-
if (!isset($methodCall->args[0]) || !$this->constantHassers) {
133+
if (!isset($methodCall->getArgs()[0]) || !$this->constantHassers) {
134134
return $returnType;
135135
}
136136

137-
$parameterKey = $this->parameterMap::getParameterKeyFromNode($methodCall->args[0]->value, $scope);
137+
$parameterKey = $this->parameterMap::getParameterKeyFromNode($methodCall->getArgs()[0]->value, $scope);
138138
if ($parameterKey !== null) {
139139
$parameter = $this->parameterMap->getParameter($parameterKey);
140140
return new ConstantBooleanType($parameter !== null);

src/Type/Symfony/RequestDynamicReturnTypeExtension.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,11 @@ public function getTypeFromMethodCall(
3131
Scope $scope
3232
): Type
3333
{
34-
if (!isset($methodCall->args[0])) {
34+
if (!isset($methodCall->getArgs()[0])) {
3535
return new StringType();
3636
}
3737

38-
$argType = $scope->getType($methodCall->args[0]->value);
38+
$argType = $scope->getType($methodCall->getArgs()[0]->value);
3939
$isTrueType = (new ConstantBooleanType(true))->isSuperTypeOf($argType);
4040
$isFalseType = (new ConstantBooleanType(false))->isSuperTypeOf($argType);
4141
$compareTypes = $isTrueType->compareTo($isFalseType);

src/Type/Symfony/SerializerDynamicReturnTypeExtension.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,11 @@ public function isMethodSupported(MethodReflection $methodReflection): bool
3939

4040
public function getTypeFromMethodCall(MethodReflection $methodReflection, MethodCall $methodCall, Scope $scope): Type
4141
{
42-
if (!isset($methodCall->args[1])) {
42+
if (!isset($methodCall->getArgs()[1])) {
4343
return new MixedType();
4444
}
4545

46-
$argType = $scope->getType($methodCall->args[1]->value);
46+
$argType = $scope->getType($methodCall->getArgs()[1]->value);
4747
if (!$argType instanceof ConstantStringType) {
4848
return new MixedType();
4949
}

src/Type/Symfony/ServiceDynamicReturnTypeExtension.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -61,11 +61,11 @@ private function getGetTypeFromMethodCall(
6161
): Type
6262
{
6363
$returnType = ParametersAcceptorSelector::selectSingle($methodReflection->getVariants())->getReturnType();
64-
if (!isset($methodCall->args[0])) {
64+
if (!isset($methodCall->getArgs()[0])) {
6565
return $returnType;
6666
}
6767

68-
$serviceId = $this->serviceMap::getServiceIdFromNode($methodCall->args[0]->value, $scope);
68+
$serviceId = $this->serviceMap::getServiceIdFromNode($methodCall->getArgs()[0]->value, $scope);
6969
if ($serviceId !== null) {
7070
$service = $this->serviceMap->getService($serviceId);
7171
if ($service !== null && (!$service->isSynthetic() || $service->getClass() !== null)) {
@@ -83,11 +83,11 @@ private function getHasTypeFromMethodCall(
8383
): Type
8484
{
8585
$returnType = ParametersAcceptorSelector::selectSingle($methodReflection->getVariants())->getReturnType();
86-
if (!isset($methodCall->args[0]) || !$this->constantHassers) {
86+
if (!isset($methodCall->getArgs()[0]) || !$this->constantHassers) {
8787
return $returnType;
8888
}
8989

90-
$serviceId = $this->serviceMap::getServiceIdFromNode($methodCall->args[0]->value, $scope);
90+
$serviceId = $this->serviceMap::getServiceIdFromNode($methodCall->getArgs()[0]->value, $scope);
9191
if ($serviceId !== null) {
9292
$service = $this->serviceMap->getService($serviceId);
9393
return new ConstantBooleanType($service !== null && $service->isPublic());

src/Type/Symfony/ServiceTypeSpecifyingExtension.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,10 @@ public function isMethodSupported(MethodReflection $methodReflection, MethodCall
4242

4343
public function specifyTypes(MethodReflection $methodReflection, MethodCall $node, Scope $scope, TypeSpecifierContext $context): SpecifiedTypes
4444
{
45-
if (!isset($node->args[0])) {
45+
if (!isset($node->getArgs()[0])) {
4646
return new SpecifiedTypes();
4747
}
48-
$argType = $scope->getType($node->args[0]->value);
48+
$argType = $scope->getType($node->getArgs()[0]->value);
4949
return $this->typeSpecifier->create(
5050
Helper::createMarkerNode($node->var, $argType, $this->printer),
5151
$argType,

0 commit comments

Comments
 (0)