Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[NodeTypeResolver] Handle nullable extended class on ->isObjectType() on DowngradeReflectionGetAttributesRector #5224

Merged
merged 5 commits into from
Nov 5, 2023

Conversation

samsonasik
Copy link
Member

@samsonasik samsonasik commented Nov 5, 2023

@malteschlueter @TomasVotruba let see if nullable extended class can be checked via isObjectType(), ref

rectorphp/rector-downgrade-php#203 (review)
Closes rectorphp/rector-downgrade-php#203

Comment on lines +441 to 442
return $requiredObjectType->isSuperTypeOf($type)
->yes();
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@TomasVotruba here is the fix, the ->superTypeOf() must use $requiredObjectType like used in other method for object type check:

private function isMatchObjectWithoutClassType(
ObjectWithoutClassType $objectWithoutClassType,
ObjectType $requiredObjectType
): bool {
if ($objectWithoutClassType instanceof ObjectWithoutClassTypeWithParentTypes) {
foreach ($objectWithoutClassType->getParentTypes() as $typeWithClassName) {
if ($requiredObjectType->isSuperTypeOf($typeWithClassName)->yes()) {

@samsonasik
Copy link
Member Author

All checks have passed 🎉 @TomasVotruba I think it is ready.

@@ -29,7 +29,7 @@
new MethodCallRename(DifferentInterface::class, 'renameMe', 'toNewVersion'),

// reflection method name
new MethodCallRename(ReflectionMethod::class, 'getTentativeReturnType', 'getReturnType'),
new MethodCallRename(ReflectionFunctionAbstract::class, 'getTentativeReturnType', 'getReturnType'),
Copy link
Member Author

@samsonasik samsonasik Nov 5, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this for test union: \ReflectionMethod|\ReflectionFunction which both instanceof ReflectionFunctionAbstract

public function run(\ReflectionMethod|\ReflectionFunction $reflectionMethod)

@samsonasik
Copy link
Member Author

@TomasVotruba I am merging it ;)

@samsonasik samsonasik merged commit 8615d40 into main Nov 5, 2023
41 checks passed
@samsonasik samsonasik deleted the handle-nullable-reflection-get-attributes branch November 5, 2023 13:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants