Skip to content

Renaming class is not working #292

Description

@vlady777

Rename class is not working totally (or partially in case of many usages) when there are at least one test case with @covers annotation.
To reproduce behavior, plase create two classes in SF directory structure like the following:

<?php

declare(strict_types=1);

namespace App\Service;

class SomeService
{
    public function someMethod(): bool
    {
        return true;
    }
}

and

<?php

declare(strict_types=1);

namespace App\Tests\Service;

use App\Service\SomeService;
use PHPUnit\Framework\TestCase;

class SomeServiceTest extends TestCase
{
    /**
     * @covers \App\Service\SomeService::someMethod
     */
    public function testSomeMethod(): void
    {
        self::assertTrue((new RenamedService())->someMethod());
    }
}

Next try to rename SomeService to something else (Shift+F6). Class (and file) will not be renamed.
If plugin is disabled renaming works as expected.

It's related to the following lines:

/**
 * @covers \App\Service\SomeService::someMethod
 */

if there will be short classname @covers SomeService::someMethod will works as expected.

Also it works fine if dynamic usages are excluded (plugin enabled)
изображение

Please check and fix.

изображение
изображение

PhpStorm 2023.1.4
Build #PS-231.9225.18, built on July 13, 2023
Licensed to SIA "ATTA-1" / Vlad Yarus
Subscription is active until November 14, 2023.
Runtime version: 17.0.7+10-b829.16 amd64
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o.
Linux 6.2.0-26-generic
GC: G1 Young Generation, G1 Old Generation
Memory: 4096M
Cores: 8
Registry:
debugger.watches.in.variables=false
run.processes.with.pty=TRUE
documentation.show.toolbar=true

Non-Bundled Plugins:
com.kalessil.phpStorm.phpInspectionsEA (5.0.0.0)
ru.adelf.idea.dotenv (2023.1)
de.espend.idea.php.annotation (9.4.0)
fr.adrienbrault.idea.symfony2plugin (2022.1.253)

Current Desktop: X-Cinnamon

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions