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

feat: cache the result of ClassReflection::hasMethod method #3825

Merged
merged 1 commit into from
Feb 13, 2025

Conversation

canvural
Copy link
Contributor

Hello 👋🏽

This PR caches the result of the ClassReflection::hasMethod method. While investigating some performance issues I found that PHPStan calls method class reflection extensions multiple times for the same class and method. And some extensions might do the actual work in hasMethod method rather than getMethod, for example Larastan does this to cache stuff internally.

I can add tests if wanted. Couldn't think of an easy way to do it right away 😅

src/Reflection/ClassReflection.php Outdated Show resolved Hide resolved
@canvural canvural changed the base branch from 2.1.x to 1.12.x February 13, 2025 13:40
@canvural canvural changed the base branch from 1.12.x to 2.1.x February 13, 2025 13:40
@canvural canvural changed the base branch from 2.1.x to 1.12.x February 13, 2025 13:48
@ondrejmirtes ondrejmirtes merged commit fde29a5 into phpstan:1.12.x Feb 13, 2025
111 checks passed
@ondrejmirtes
Copy link
Member

Thank you.

@canvural canvural deleted the has-method-cache branch February 13, 2025 13:50
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