Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork5.3k
[Console][LockableTrait] Do not redeclare $lockFactory through constructor property promotion in the code example#21507
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
…erty promotion in the code exampleAdding visibility on the constructor parameter results in constructor property promotion and in redeclaring the property in a way which is incompatible with the declaration from the trait, resulting in a fatal error if the example is used as is.For reference:https://www.php.net/manual/en/language.oop5.traits.php#language.oop5.traits.properties.exampleInstead, I think the visibility should be removed in order to prevent redeclaration (and incompatibility with the property from the trait), and just use dependency injection and overwrite the default value so that the trait won't create a new instance for the $lockFactory.
fa8ff31 intosymfony:7.3Uh oh!
There was an error while loading.Please reload this page.
javiereguiluz commentedOct 17, 2025
Good catch Nicolae 👏 and perfectly explained in the PR desription. Thanks for fixing this. |
nicuserban commentedOct 17, 2025 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
Thank you for your review and for merging this PR, Javier! |
Adding visibility on the constructor parameter results in constructor property promotion and in redeclaring the property in a way which is incompatible with the declaration from the trait, resulting in a fatal error if the example is used as is. For reference:https://www.php.net/manual/en/language.oop5.traits.php#language.oop5.traits.properties.example
Instead, I think the visibility should be removed in order to prevent redeclaration (and incompatibility with the property from the trait), and just use dependency injection and overwrite the default value so that the trait won't create a new instance for the $lockFactory.