Skip to content

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

Merged
taylorotwell merged 6 commits into
laravel:12.xfrom
cosmastech:cache-container-attribute-checks
Aug 13, 2025
Merged

[12.x] Cache Singleton/Scoped attribute checks#56633
taylorotwell merged 6 commits into
laravel:12.xfrom
cosmastech:cache-container-attribute-checks

Conversation

@cosmastech

@cosmastech cosmastech commented Aug 12, 2025

Copy link
Copy Markdown
Contributor

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. 🤷

@github-actions

Copy link
Copy Markdown

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
@cosmastech cosmastech deleted the cache-container-attribute-checks branch January 24, 2026 13:06
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