Skip to content

[12.x] Cache Singleton/Scoped attribute checks #56633

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

Merged

Conversation

cosmastech
Copy link
Contributor

@cosmastech cosmastech commented Aug 12, 2025

Currently, when the container is building a class, we perform reflection to check if the class has #[Scoped] or #[Singleton] attributes. This is unnecessary to check more than once on a particular class.

This keeps a memo of the class-string to the outcome of the Container@getScopedTyped() call. This is similar to how we keep a cache of classes we have checked for #[Bind] attributes.


I would normally reach for an enum here but did not because they aren't particularly common in the framework. 🤷

Copy link

Thanks for submitting a PR!

Note that draft PR's are not reviewed. If you would like a review, please mark your pull request as ready for review in the GitHub user interface.

Pull requests that are abandoned in draft may be closed due to inactivity.

@cosmastech cosmastech force-pushed the cache-container-attribute-checks branch from 2f59a36 to 88bdd73 Compare August 13, 2025 00:04
@cosmastech cosmastech changed the title [12.x] Cache container attribute checks [12.x] Cache Singleton/Scoped attribute checks Aug 13, 2025
@cosmastech cosmastech marked this pull request as ready for review August 13, 2025 00:35
@taylorotwell taylorotwell merged commit f64a924 into laravel:12.x Aug 13, 2025
60 checks passed
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