Skip to content

Renaming constructor property promotion parameter does not rename matching @param name #450

@still-dreaming-1

Description

@still-dreaming-1

When using constructor property promotion, the most natural place to add docblock information about both the parameter and the property is to do it as a normal constructor docblock and use the @param like you would if it were a normal parameter. I do this a lot, especially when I want to add Psalm annotations. It works well because Psalm does understand that these @param annotations refer both the parameter and the property.

I discovered that when using the rename refactor feature in VSCode for a parameter like this, it does not rename the parameter name in the docblock like it normally would if it were not a constructor property promotion parameter. It seemed like I was having a lot of intermittent problems when renaming parameters and properties, but now between these last 3 issues I filed here, I finally have figured out exactly what is happening in reproducible ways.

Here is some example code.

<?php

declare(strict_types=1);

namespace MyNamespace;

class MyClass
{
    /**
     * @param list<int> $numList
     */
    public function __construct(private array $numList) {
    }
}

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions