Skip to content

Improve ParentClassMethodTypeOverrideGuard performance#3660

Merged
samsonasik merged 2 commits intorectorphp:mainfrom
staabm:fast-guard
Apr 23, 2023
Merged

Improve ParentClassMethodTypeOverrideGuard performance#3660
samsonasik merged 2 commits intorectorphp:mainfrom
staabm:fast-guard

Conversation

@staabm
Copy link
Copy Markdown
Contributor

@staabm staabm commented Apr 22, 2023

No description provided.


/** @var string $methodName */
$methodName = $this->nodeNameResolver->getName($classMethod);
$parentClassReflections = array_merge($classReflection->getParents(), $classReflection->getInterfaces());
Copy link
Copy Markdown
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
@staabm staabm requested a review from TomasVotruba as a code owner April 22, 2023 17:50
$methodName = $this->nodeNameResolver->getName($classMethod);
$parentClassReflections = array_merge($classReflection->getParents(), $classReflection->getInterfaces());
$parentClassReflection = $classReflection->getParentClass();
while ($parentClassReflection !== null) {
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
@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

Development

Successfully merging this pull request may close these issues.

3 participants