Skip to content

No need to copy @psalm-var against existing @psalm-param on ClassPropertyAssignToConstructorPromotionRector #7686

@samsonasik

Description

@samsonasik

Bug Report

Subject Details
Rector version last dev-main
Installed as composer dependency

Minimal PHP Code Causing Issue

See https://getrector.org/demo/ad857b8b-eea2-4117-b472-037ee4a9d67f

<?php

final class EqualMirrorPropertyVar
{
    /** @psalm-var non-empty-string */
    private string $property;
    
    /** @psalm-param non-empty-string $property */
    public function __construct(string $property)
    {
        $this->property = $property;
    }
}

Responsible rules

  • ClassPropertyAssignToConstructorPromotionRector

Expected Behavior

The @psalm-var no need to be copied, as there is already @psalm-param with equal type.

Only move the property to param, psalm-var can be deleted.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions