[CodeQuality] Skip InlineConstructorDefaultToPropertyRector on property defined in parent, when parent::__construct() is called - #8297
Merged
Conversation
…ty also defined in parent, when parent::__construct() is called
TomasVotruba
force-pushed
the
skip-inline-constructor-parent-construct
branch
from
August 5, 2026 21:53
17d862f to
96a8806
Compare
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.
When
parent::__construct()is called first, the parent constructor may write to a property that the child also declares. Moving the child's constructor assign to a property default flips the order — the default now applies before the parent constructor runs, so the parent's write wins instead of being overwritten.Real-world case (Mautic
Client extends FOS\OAuthServerBundle\Model\Client):class Client extends BaseClient { - protected array $allowedGrantTypes; + protected array $allowedGrantTypes = [OAuth2::GRANT_TYPE_AUTH_CODE, OAuth2::GRANT_TYPE_REFRESH_TOKEN]; public function __construct() { parent::__construct(); - - $this->allowedGrantTypes = [ - OAuth2::GRANT_TYPE_AUTH_CODE, - OAuth2::GRANT_TYPE_REFRESH_TOKEN, - ]; } }Before the change the value ends up
[auth_code, refresh_token]; after it, the parent appends on top of the default and it becomes[auth_code, refresh_token, auth_code].Fix
Skip the property when both hold:
parent::__construct()is called above the assignReflectionProvider)Properties owned only by the child still get inlined as before, even with a
parent::__construct()call present.