Skip to content

Incorrect behavior of AnnotationWithValueToAttributeRector, CoversAnnotationWithValueToAttributeRector #9539

@theofidry

Description

@theofidry

Bug Report

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

Minimal PHP Code Causing Issue

See https://getrector.com/demo/313b144d-037f-4b7e-95b6-709f181d40cc

<?php

/*
 * This file is part of the Alice package.
 *
 * (c) Nelmio <[email protected]>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

declare(strict_types=1);

namespace Nelmio\Alice\Generator\Resolver;

use Nelmio\Alice\Definition\Value\UniqueValue;
use Nelmio\Alice\Entity\StdClassFactory;
use PHPUnit\Framework\TestCase;
use stdClass;

/**
 * @covers \Nelmio\Alice\Generator\Resolver\UniqueValuesPool
 * @internal
 */
final class UniqueValuesPoolTest extends TestCase
{
    /**
     * @depends \Nelmio\Alice\Definition\Value\UniqueValueTest::testIsImmutable
     */
    public function testIsImmutable(): void
    {
        self::assertTrue(true, 'Nothing to do.');
    }
}

Responsible rules

  • AnnotationWithValueToAttributeRector

  • CoversAnnotationWithValueToAttributeRector

Expected Behavior

The @depends here should be transformed into #[DependsExternal]:

-    /**
-     * @depends \Nelmio\Alice\Definition\Value\UniqueValueTest::testIsImmutable
-     */
+   #[\PHPUnit\Framework\Attributes\DependsExternal(\Nelmio\Alice\Definition\Value\UniqueValueTest::class, 'testIsImmutable')]

Currently rector gives:

-    /**
-     * @depends \Nelmio\Alice\Definition\Value\UniqueValueTest::testIsImmutable
-     */
+   #[\PHPUnit\Framework\Attributes\Depends(\Nelmio\Alice\Definition\Value\UniqueValueTest::testIsImmutable)]

Which is incorrect.

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