diff --git a/rules/CodeQuality/Rector/Identical/FlipTypeControlToUseExclusiveTypeRector.php b/rules/CodeQuality/Rector/Identical/FlipTypeControlToUseExclusiveTypeRector.php index 1b21c18e52b..2ab099b423d 100644 --- a/rules/CodeQuality/Rector/Identical/FlipTypeControlToUseExclusiveTypeRector.php +++ b/rules/CodeQuality/Rector/Identical/FlipTypeControlToUseExclusiveTypeRector.php @@ -107,7 +107,7 @@ public function refactor(Node $node): ?Node $type = $phpDocInfo->getVarType(); if (! $type instanceof UnionType) { - $type = $this->getObjectType($assign->expr); + $type = $this->getType($assign->expr); } if (! $type instanceof UnionType) { diff --git a/rules/CodeQuality/Rector/Isset_/IssetOnPropertyObjectToPropertyExistsRector.php b/rules/CodeQuality/Rector/Isset_/IssetOnPropertyObjectToPropertyExistsRector.php index 0be54ec9fb2..2c069750a79 100644 --- a/rules/CodeQuality/Rector/Isset_/IssetOnPropertyObjectToPropertyExistsRector.php +++ b/rules/CodeQuality/Rector/Isset_/IssetOnPropertyObjectToPropertyExistsRector.php @@ -95,7 +95,7 @@ public function refactor(Node $node): ?Node continue; } - $propertyFetchVarType = $this->getObjectType($issetVar->var); + $propertyFetchVarType = $this->getType($issetVar->var); if ($propertyFetchVarType instanceof TypeWithClassName) { if (! $this->reflectionProvider->hasClass($propertyFetchVarType->getClassName())) { diff --git a/rules/CodeQuality/Rector/PropertyFetch/ExplicitMethodCallOverMagicGetSetRector.php b/rules/CodeQuality/Rector/PropertyFetch/ExplicitMethodCallOverMagicGetSetRector.php index acbec30f125..f35926e5b03 100644 --- a/rules/CodeQuality/Rector/PropertyFetch/ExplicitMethodCallOverMagicGetSetRector.php +++ b/rules/CodeQuality/Rector/PropertyFetch/ExplicitMethodCallOverMagicGetSetRector.php @@ -110,7 +110,7 @@ public function refactor(Node $node): ?Node private function refactorPropertyFetch(PropertyFetch $propertyFetch): MethodCall|null { - $callerType = $this->getObjectType($propertyFetch->var); + $callerType = $this->getType($propertyFetch->var); if (! $callerType instanceof TypeWithClassName) { return null; } @@ -143,7 +143,7 @@ private function refactorPropertyFetch(PropertyFetch $propertyFetch): MethodCall private function refactorMagicSet(Expr $expr, PropertyFetch $propertyFetch): MethodCall|null { - $propertyCallerType = $this->getObjectType($propertyFetch->var); + $propertyCallerType = $this->getType($propertyFetch->var); if (! $propertyCallerType instanceof ObjectType) { return null; } diff --git a/rules/Defluent/Rector/ClassMethod/NormalToFluentRector.php b/rules/Defluent/Rector/ClassMethod/NormalToFluentRector.php index 367f74a3c54..fa3c8ed9c60 100644 --- a/rules/Defluent/Rector/ClassMethod/NormalToFluentRector.php +++ b/rules/Defluent/Rector/ClassMethod/NormalToFluentRector.php @@ -207,12 +207,12 @@ private function fluentizeCollectedMethodCalls(ClassMethod $classMethod): void private function matchMethodCall(MethodCall $methodCall): ?ObjectType { foreach ($this->callsToFluent as $callToFluent) { - if (! $this->isObjectType($methodCall->var, $callToFluent->getObjectType())) { + if (! $this->isObjectType($methodCall->var, $callToFluent->getType())) { continue; } if ($this->isNames($methodCall->name, $callToFluent->getMethodNames())) { - return $callToFluent->getObjectType(); + return $callToFluent->getType(); } } diff --git a/rules/DependencyInjection/Rector/Class_/ActionInjectionToConstructorInjectionRector.php b/rules/DependencyInjection/Rector/Class_/ActionInjectionToConstructorInjectionRector.php index cf4f4f6e71e..a739fcc30fa 100644 --- a/rules/DependencyInjection/Rector/Class_/ActionInjectionToConstructorInjectionRector.php +++ b/rules/DependencyInjection/Rector/Class_/ActionInjectionToConstructorInjectionRector.php @@ -99,7 +99,7 @@ private function processClassMethod(Class_ $class, ClassMethod $classMethod): vo continue; } - $paramType = $this->getObjectType($paramNode); + $paramType = $this->getType($paramNode); /** @var string $paramName */ $paramName = $this->getName($paramNode->var); @@ -124,7 +124,7 @@ private function isActionInjectedParamNode(Param $param): bool return false; } - $paramStaticType = $this->getObjectType($param); + $paramStaticType = $this->getType($param); if (! $paramStaticType instanceof ObjectType) { return false; } diff --git a/rules/Php70/Rector/StaticCall/StaticCallOnNonStaticToInstanceCallRector.php b/rules/Php70/Rector/StaticCall/StaticCallOnNonStaticToInstanceCallRector.php index 5b23ef07f71..6063edf813e 100644 --- a/rules/Php70/Rector/StaticCall/StaticCallOnNonStaticToInstanceCallRector.php +++ b/rules/Php70/Rector/StaticCall/StaticCallOnNonStaticToInstanceCallRector.php @@ -130,7 +130,7 @@ public function refactor(Node $node): ?Node private function resolveStaticCallClassName(StaticCall $staticCall): ?string { if ($staticCall->class instanceof PropertyFetch) { - $objectType = $this->getObjectType($staticCall->class); + $objectType = $this->getType($staticCall->class); if ($objectType instanceof ObjectType) { return $objectType->getClassName(); } diff --git a/rules/Php80/Rector/Class_/ClassPropertyAssignToConstructorPromotionRector.php b/rules/Php80/Rector/Class_/ClassPropertyAssignToConstructorPromotionRector.php index 597dc37ce09..28a2b47ed38 100644 --- a/rules/Php80/Rector/Class_/ClassPropertyAssignToConstructorPromotionRector.php +++ b/rules/Php80/Rector/Class_/ClassPropertyAssignToConstructorPromotionRector.php @@ -149,7 +149,7 @@ public function provideMinPhpVersion(): int private function processNullableType(Property $property, Param $param): void { if ($this->nodeTypeResolver->isNullableType($property)) { - $objectType = $this->getObjectType($property); + $objectType = $this->getType($property); $param->type = $this->staticTypeMapper->mapPHPStanTypeToPhpParserNode($objectType, TypeKind::PARAM()); } } diff --git a/rules/Renaming/Rector/ClassMethod/RenameAnnotationRector.php b/rules/Renaming/Rector/ClassMethod/RenameAnnotationRector.php index a79a236cd01..96dd9263517 100644 --- a/rules/Renaming/Rector/ClassMethod/RenameAnnotationRector.php +++ b/rules/Renaming/Rector/ClassMethod/RenameAnnotationRector.php @@ -98,7 +98,7 @@ public function refactor(Node $node): ?Node $phpDocInfo = $this->phpDocInfoFactory->createFromNodeOrEmpty($node); foreach ($this->renamedAnnotations as $renamedAnnotation) { - if (! $this->isObjectType($classLike, $renamedAnnotation->getObjectType())) { + if (! $this->isObjectType($classLike, $renamedAnnotation->getType())) { continue; } diff --git a/rules/Renaming/Rector/PropertyFetch/RenamePropertyRector.php b/rules/Renaming/Rector/PropertyFetch/RenamePropertyRector.php index 19866d9024c..4afdfee7687 100644 --- a/rules/Renaming/Rector/PropertyFetch/RenamePropertyRector.php +++ b/rules/Renaming/Rector/PropertyFetch/RenamePropertyRector.php @@ -116,7 +116,7 @@ private function processFromPropertyFetch(PropertyFetch $propertyFetch): ?Proper { $class = $propertyFetch->getAttribute(AttributeKey::CLASS_NODE); foreach ($this->renamedProperties as $renamedProperty) { - if (! $this->isObjectType($propertyFetch->var, $renamedProperty->getObjectType())) { + if (! $this->isObjectType($propertyFetch->var, $renamedProperty->getType())) { continue; } diff --git a/rules/Transform/Rector/Assign/PropertyAssignToMethodCallRector.php b/rules/Transform/Rector/Assign/PropertyAssignToMethodCallRector.php index 7439111367f..bec56ff197d 100644 --- a/rules/Transform/Rector/Assign/PropertyAssignToMethodCallRector.php +++ b/rules/Transform/Rector/Assign/PropertyAssignToMethodCallRector.php @@ -76,7 +76,7 @@ public function refactor(Node $node): ?Node $propertyNode = $propertyFetchNode->var; foreach ($this->propertyAssignsToMethodCalls as $propertyAssignToMethodCall) { - if (! $this->isObjectType($propertyFetchNode->var, $propertyAssignToMethodCall->getObjectType())) { + if (! $this->isObjectType($propertyFetchNode->var, $propertyAssignToMethodCall->getType())) { continue; } diff --git a/rules/Transform/Rector/MethodCall/MethodCallToAnotherMethodCallWithArgumentsRector.php b/rules/Transform/Rector/MethodCall/MethodCallToAnotherMethodCallWithArgumentsRector.php index 8f1c4eb4a6d..af3058cbc02 100644 --- a/rules/Transform/Rector/MethodCall/MethodCallToAnotherMethodCallWithArgumentsRector.php +++ b/rules/Transform/Rector/MethodCall/MethodCallToAnotherMethodCallWithArgumentsRector.php @@ -71,7 +71,7 @@ public function getNodeTypes(): array public function refactor(Node $node): ?Node { foreach ($this->methodCallRenamesWithAddedArguments as $methodCallRenameWithAddedArgument) { - if (! $this->isObjectType($node->var, $methodCallRenameWithAddedArgument->getObjectType())) { + if (! $this->isObjectType($node->var, $methodCallRenameWithAddedArgument->getType())) { continue; } diff --git a/rules/Transform/Rector/New_/NewToStaticCallRector.php b/rules/Transform/Rector/New_/NewToStaticCallRector.php index 638980a76c0..9c4c47b8366 100644 --- a/rules/Transform/Rector/New_/NewToStaticCallRector.php +++ b/rules/Transform/Rector/New_/NewToStaticCallRector.php @@ -73,7 +73,7 @@ public function getNodeTypes(): array public function refactor(Node $node): ?Node { foreach ($this->typeToStaticCalls as $typeToStaticCall) { - if (! $this->isObjectType($node->class, $typeToStaticCall->getObjectType())) { + if (! $this->isObjectType($node->class, $typeToStaticCall->getType())) { continue; } diff --git a/src/Rector/AbstractRector.php b/src/Rector/AbstractRector.php index 31f1a2efd5d..2faf707d789 100644 --- a/src/Rector/AbstractRector.php +++ b/src/Rector/AbstractRector.php @@ -323,6 +323,10 @@ protected function isObjectType(Node $node, ObjectType $objectType): bool return $this->nodeTypeResolver->isObjectType($node, $objectType); } + /** + * @deprecated + * Use @see AbstractRector::getType() instead, as single method to get types + */ protected function getStaticType(Node $node): Type { return $this->nodeTypeResolver->getStaticType($node); @@ -330,9 +334,17 @@ protected function getStaticType(Node $node): Type /** * @deprecated - * Use getStaticType() instead, as single method to get types + * Use @see AbstractRector::getType() instead, as single method to get types */ protected function getObjectType(Node $node): Type + { + return $this->getType($node); + } + + /** + * Use this method for getting expr|node type + */ + protected function getType(Node $node): Type { return $this->nodeTypeResolver->resolve($node); }