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

Remove runtime autoloading from NodeTypeResolver #3627

Merged
merged 2 commits into from
Apr 20, 2023

Conversation

staabm
Copy link
Contributor

@staabm staabm commented Apr 17, 2023

see #3502 (comment) for background

@@ -354,11 +349,7 @@ private function isObjectTypeOfObjectType(ObjectType $resolvedObjectType, Object
}

$classReflection = $this->reflectionProvider->getClass($resolvedObjectType->getClassName());
if (! isset($this->traitExistsCache[$classReflection->getName()])) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think since we already checked with hasClass that $resolvedObjectType->getClassName() exists, we only need to check with isTrait() whether its a trait.

in my thinking it should be equivalent to what this cache was doing before.

@keulinho could you verify this has the same perf characteristics for your use case, as measured in #3501 ?

Copy link
Contributor

Choose a reason for hiding this comment

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

The change in general looks good to me and the solution way more elegant that mine 🙈

actually i've paused trying to get rector running smoothly with our codebase for now, i will get back when i have the time to look at it again

@staabm
Copy link
Contributor Author

staabm commented Apr 17, 2023

I think the failling job shows us one of the side-effects I mentioned in #3502 (comment).

the test-case worked before this PR because it autoloaded the trait at runtime, which doesn't look right to me.

@staabm staabm marked this pull request as ready for review April 17, 2023 20:32
@staabm staabm requested a review from TomasVotruba as a code owner April 17, 2023 20:32
@TomasVotruba
Copy link
Member

I think the failling job shows us one of the side-effects I mentioned in #3502 (comment).

It must be fixed before this gets merged, so we have always updated and working code here. Could you handle it?

@staabm
Copy link
Contributor Author

staabm commented Apr 18, 2023

I think the test here would be green after rectorphp/rector-symfony#391 is merged.

I was not able to test it though.

@samsonasik
Copy link
Member

build restarted

@samsonasik
Copy link
Member

@staabm test still error unfortunately

@samsonasik
Copy link
Member

@staabm I am reverting your PR rectorphp/rector-symfony#392

@staabm staabm changed the title Simplify isObjectTypeOfObjectType() Remove runtime autoloading from NodeTypeResolver Apr 19, 2023
@staabm
Copy link
Contributor Author

staabm commented Apr 19, 2023

should be good to go now. no changes in rector-symfony are needed anymore


if ($this->traitExistsCache[$classReflection->getName()]) {
foreach ($classReflection->getAncestors() as $ancestorClassReflection) {
Copy link
Contributor Author

@staabm staabm Apr 19, 2023

Choose a reason for hiding this comment

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

this ancestor traversal is slow.

after this PR we only do it for trait-classes. before we did it for every class, which was unnecessary, as only traits can be contained in a traitUse.

@staabm
Copy link
Contributor Author

staabm commented Apr 20, 2023

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.

Lets give it a try, thank you @staabm

@samsonasik samsonasik merged commit 9f5d6b9 into rectorphp:main Apr 20, 2023
@staabm staabm deleted the simple branch April 20, 2023 10:59
@TomasVotruba
Copy link
Member

Thank you 😊

samsonasik pushed a commit that referenced this pull request May 8, 2023
* Remove runtime autoloading from NodeTypeResolver

* refactor
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.

4 participants