Part of #3641170: [meta] Call parent constructor instead of duplicating property assignment.

Problem/Motivation

#3635402: Promote remaining properties in constructors and add @param docs where needed flagged up that we have several classes in core where instead of calling the parent constructor, the class assigns the property itself. For property promotion, it would be better to call the parent constructor (which can then do property promotion). This will also make it easier to handle adding readonly.

Proposed resolution

In this issue, refactor Component/Diff constructors.

Remaining tasks

User interface changes

Introduced terminology

API changes

Data model changes

Release notes snippet

Issue fork drupal-3641664

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

mondrake created an issue. See original summary.

mondrake’s picture

Status: Active » Needs review
smustgrave’s picture

Status: Needs review » Reviewed & tested by the community
Issue tags: +Needs Review Queue Initiative

Going to mark this one as it least touches 6 files but almost feel like this could be a massive MR too, sure we have a lot of files missing constructor promotion.

Almost moved to NW that we could we could drop the docblock for _construct but the variable names aren't actually super clear so think it does bring value.

dcam’s picture

@smustgrave beat me to it. I tried to find something to comment about, but I couldn't. It's pretty straightforward. I verified that all the parameters are in the right place. I suppose we can't add property type hints. That's about the only thing I could think of to mention.

mondrake’s picture

Status: Reviewed & tested by the community » Needs review

I think for BC we need to make the DiffOp parameters optional.

mondrake’s picture

almost feel like this could be a massive MR too, sure we have a lot of files missing constructor promotion

Over 380 cases, see #3641651: Introduce PHPStan rule to control property promotion in constructors - which could use a review BTW ;)