Skip to content

Incorrect behavior of CoversAnnotationWithValueToAttributeRector, AnnotationToAttributeRector #9474

Description

@irosner

Bug Report

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

Minimal PHP Code Causing Issue

See https://getrector.com/demo/cea98a8c-aac7-47b1-b887-dbf3242d83c8

<?php

use PHPUnit\Framework\TestCase;

/**
 * @coversDefaultClass \Commons\Behavior\ValueObject\AbstractValueObject
 */
class RectorTest extends TestCase
{
    /**
     * @covers ::getValue
     * @test
     *
     */
    public function it_works()
    {
        $this->assertTrue(true);
    }

    /**
     * @covers ::equals
     * @test
     *
     */
    public function it_works2()
    {
        $this->assertTrue(true);
    }
}

Responsible rules

  • CoversAnnotationWithValueToAttributeRector

  • AnnotationToAttributeRector

Expected Behavior

<?php

use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\CoversMethod;
use PHPUnit\Framework\Attributes\Test;
use PHPUnit\Framework\TestCase;

#[CoversClass(\Commons\Behavior\ValueObject\AbstractValueObject::class)]
#[CoversMethod(\Commons\Behavior\ValueObject\AbstractValueObject::class, 'getValue')]
#[CoversMethod(\Commons\Behavior\ValueObject\AbstractValueObject::class, 'equals')]
class RectorTest extends TestCase
{
    #[Test]
    public function it_works()
    {
        $this->assertTrue(true);
    }

    #[Test]
    public function it_works2()
    {
        $this->assertTrue(true);
    }
}

Activity

  1. TomasVotruba commented on Oct 30, 2025

    @TomasVotruba
    Member

    Thanks for reporting. Could you send a PR with a fix?

  2. irosner commented on Oct 30, 2025

    @irosner
    Author

    @TomasVotruba thank you!

    This is actually my first use of Rector. I did try to patch up CoversAnnotationWithValueToAttributeRector locally but was unsuccessful as I am not familiar enough with the entire process.

  3. TomasVotruba commented on Oct 30, 2025

    @TomasVotruba
    Member

    @irosner First step is the hardest, but this one is quite easy-pick. Give it a go, open PR with what you have and we'll guide you 👍

  4. giacomomasseron commented on Oct 31, 2025

    @giacomomasseron

    @irosner if you want, I can do it. Let me know what you prefer.

  5. irosner commented on Nov 2, 2025

    @irosner
    Author

    @giacomomasseron yes, please do it. Thank you!

  6. irosner commented on Nov 16, 2025

    @irosner
    Author

    @TomasVotruba put my attempt into a PR - rectorphp/rector-phpunit#588

  7. samsonasik commented on Nov 22, 2025

    @samsonasik
    Member
  8. github-actions commented on Apr 26, 2026

    @github-actions
    Contributor

    This issue has been automatically locked because it has been closed for 150 days. Please open a new issue if you have a similar problem.

  9. locked as resolved and limited conversation to collaborators on Apr 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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