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.

Steps to reproduce

Proposed resolution

Remaining tasks

User interface changes

Introduced terminology

API changes

Data model changes

Release notes snippet

Issue fork drupal-3641170

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

catch created an issue. See original summary.

mondrake’s picture

StatusFileSize
new3.84 KB
new2.84 KB

I asked LLM to write a script to identify the constructors that may be impacted. It developed the attached script, that uses nikic/php-parser to scan through the codebase, and run it to produce the attached results.

I think the script is currently missing many cases, but it looks like a starting point. I'll see into enhancing it humanly.

mondrake’s picture

A custom PHPStan rule could be well suited for the purpose. Asked LLM to draft one, that I then adjusted humanly.

mondrake’s picture

Status: Active » Needs review

Made a couple of example fixes. NR to get early feedback on approach.

needs-review-queue-bot’s picture

Status: Needs review » Needs work
StatusFileSize
new189.58 KB

The Needs Review Queue Bot tested this issue. It fails the Drupal core commit checks. Therefore, this issue status is now "Needs work".

This does not mean that the patch necessarily needs to be re-rolled or the MR rebased. Read the Issue Summary, the issue tags and the latest discussion here to determine what needs to be done.

Consult the Drupal Contributor Guide to find step-by-step guides for working with issues.

mondrake’s picture

Status: Needs work » Needs review
Issue tags: +no-needs-review-bot
catch’s picture

ListDataDefinition is what I'd expect things to look like.

NodeGrantDatabaseStorage looks like it got missed by phpstan due to incomplete docs? If so, we might want to split this issue into two for the two kinds of change.

mondrake’s picture

Title: Call parent constructor instead of duplicating property assignment » [meta] Call parent constructor instead of duplicating property assignment
Status: Needs review » Active
Issue tags: -no-needs-review-bot

Chaning to meta. I suggest we introduce the PHPStan rule first, with baselined errors, then open issues to fix the baselined errors.