Skip to content

Incorrect behavior of RemoveUselessVarTagRector #9633

@staabm

Description

@staabm

Bug Report

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

Minimal PHP Code Causing Issue

See https://getrector.com/demo/67a7213b-f6ae-45c2-bf4c-6b9c789f11b8

<?php

class MyActionController {}

class MyClxProductNet_Translate {
    /**
     * @phpstan-pure
     */
    public static function create(): self
    {
        return new self();
    }


}

/** @var MyActionController $this */

/** @var MyClxProductNet_Translate $translator */
$translator = MyClxProductNet_Translate::create();

$url = $this->bulkConsumerRegistration ?? "abc";

Responsible rules

  • RemoveUselessVarTagRector

Expected Behavior

/** @var MyActionController $this */ should not be removed because $this is used within the file.

removing this comment will create PHPStan errors, because in the context of this non-class files $this is otherwise not known to PHPStan

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