Fix the behavior of ClassPropertyAssignToConstructorPromotionRector when types do not match#7972
Merged
TomasVotruba merged 14 commits intorectorphp:mainfrom Apr 23, 2026
Merged
Conversation
… when types do not match
Member
|
Could you show the diff on https://getrector.com/demo/ first? thank you. |
Contributor
Author
|
Yes. Here's the diff: https://getrector.com/demo/4534848e-f616-4cf9-ae28-46adbf6a8859 These changes can cause the following errors: |
samsonasik
reviewed
Apr 21, 2026
samsonasik
reviewed
Apr 22, 2026
samsonasik
reviewed
Apr 22, 2026
mspirkov
commented
Apr 22, 2026
samsonasik
reviewed
Apr 22, 2026
samsonasik
reviewed
Apr 22, 2026
Member
|
Could you split into separate fixtures per new use case? That will be easier to check |
Contributor
Author
It sounds logical. I'll do it now |
Contributor
Author
|
I made separate fixtures |
samsonasik
reviewed
Apr 22, 2026
samsonasik
reviewed
Apr 23, 2026
Member
|
Let's go:) thank you |
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.
I encountered a problem where the property type and parameter type did not match, and the parameter type was replaced with the property type. This led to an issue because the DI container could only resolve a specific implementation of the interface and could not resolve the interface itself, resulting in a crash when attempting to instantiate the class.
I believe it would be more appropriate to use the parameter type in this case. I would appreciate your feedback :)