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

Improve ParentClassMethodTypeOverrideGuard performance #3660

Merged
merged 2 commits into from
Apr 23, 2023

Conversation

staabm
Copy link
Contributor

@staabm staabm commented Apr 22, 2023

No description provided.

@@ -37,14 +37,20 @@ public function getParentClassMethod(ClassMethod $classMethod): ?MethodReflectio

/** @var string $methodName */
$methodName = $this->nodeNameResolver->getName($classMethod);
$parentClassReflections = array_merge($classReflection->getParents(), $classReflection->getInterfaces());
Copy link
Contributor Author

Choose a reason for hiding this comment

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

before this change the whole type hierarchy had to be reflected which can be costly.

with this PR we only reflect what on level at a time

@staabm staabm marked this pull request as ready for review April 22, 2023 17:50
@@ -37,14 +37,20 @@ public function getParentClassMethod(ClassMethod $classMethod): ?MethodReflectio

/** @var string $methodName */
$methodName = $this->nodeNameResolver->getName($classMethod);
$parentClassReflections = array_merge($classReflection->getParents(), $classReflection->getInterfaces());
$parentClassReflection = $classReflection->getParentClass();
while ($parentClassReflection !== null) {
Copy link
Member

Choose a reason for hiding this comment

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

This should be instanceof check. I'll make a note to make Rector rule to cover these :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed, thanks

Copy link
Member

@samsonasik samsonasik left a comment

Choose a reason for hiding this comment

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

Looks good, thank you @staabm

@samsonasik samsonasik merged commit c7379ec into rectorphp:main Apr 23, 2023
37 checks passed
@staabm staabm deleted the fast-guard branch April 23, 2023 06:14
samsonasik pushed a commit that referenced this pull request May 8, 2023
* Improve ParentClassMethodTypeOverrideGuard performance

* use instanceof
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants