Skip to content

Incorrect behavior of ReplaceTestAnnotationWithPrefixedFunctionRector #9752

@Dukecz

Description

@Dukecz

Bug Report

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

Minimal PHP Code Causing Issue

See https://getrector.com/demo/de31b175-d8e1-4350-a5d4-bddad0d34775

<?php

declare(strict_types=1);

namespace App\Tests;

use PHPUnit\Framework\TestCase;

final class ExampleTest extends TestCase
{
    /**
     * there is some comment with something@test
     */
    private function someFunction()
    {
        return true;
    }
    
    public function testSomething()
    {
        $this->assertTrue($this->someFunction());
    }      
}

Responsible rules

  • ReplaceTestAnnotationWithPrefixedFunctionRector

Is applied if there is "@test" anywhere in doc comment even if it is part of word.

  • RemoveUnusedPrivateMethodRector (this rule works correctly, just makes the problem of previous rule worse)

Builds on previous rule and removes the renamed private (now testSomeFunction) function.

Expected Behavior

No changes should be made.

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