Fix: Allow lazy ghosts for services without constructor arguments#329
Open
mildabre wants to merge 16 commits intonette:masterfrom
Open
Fix: Allow lazy ghosts for services without constructor arguments#329mildabre wants to merge 16 commits intonette:masterfrom
mildabre wants to merge 16 commits intonette:masterfrom
Conversation
@return, ... and %parameters% are no longer supported
…' moved to visitors
This is a bug fix addressing incorrect behavior where the lazy flag was silently ignored for services without constructor arguments. With PHP 8.4's native lazy ghost support, there is no technical limitation preventing lazy loading for such services. This fix enables valid use cases like services with heavy initialization that doesn't require constructor dependencies. This is NOT a BC break - it only fixes previously broken functionality where explicitly set lazy=true was incorrectly ignored.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fix: Allow lazy ghosts for services without constructor arguments
Problem
Currently,
ServiceDefinition::canBeLazy()prevents lazy ghost creation for services without constructor arguments:This check causes the
lazyflag to be silently ignored for such services, which is incorrect behavior.Use Case
Services with heavy initialization that doesn't require dependencies:
Solution
Remove the constructor arguments/setup check as it's no longer necessary with PHP 8.4's native
ReflectionClass::newLazyGhost()support.The remaining checks are still valid:
Backward Compatibility
✅ NOT a BC break - only fixes previously broken functionality
✅ All existing lazy services continue to work
✅ Enables new valid use cases
Suggested Release
Patch version (v3.3.x) as this is a bug fix, not a feature.