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/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/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); }