Find the best Rector rule to solve your problem
Change annotation to attribute
use Symfony\Component\Routing\Annotation\Route;
class SymfonyRoute
{
- /**
- * @Route("/path", name="action") api route
- */
+ #[Route(path: '/path', name: 'action')] // api route
public function action()
{
}
}
Change annotations with value to attribute
use PHPUnit\Framework\TestCase;
+use PHPUnit\Framework\Attributes\Ticket;
-/**
- * @ticket 123
- */
+#[Ticket('123')]
final class SomeTest extends TestCase
{
}
Change covers annotations with value to attribute
use PHPUnit\Framework\TestCase;
+use PHPUnit\Framework\Attributes\CoversClass;
+use PHPUnit\Framework\Attributes\CoversFunction;
-/**
- * @covers SomeClass
- */
+#[CoversClass(SomeClass::class)]
+#[CoversFunction('someFunction')]
final class SomeTest extends TestCase
{
- /**
- * @covers ::someFunction()
- */
public function test()
{
}
}
Change annotations with value to attribute
use PHPUnit\Framework\TestCase;
+use PHPUnit\Framework\Attributes\BackupGlobals;
-/**
- * @backupGlobals enabled
- */
+#[BackupGlobals(true)]
final class SomeTest extends TestCase
{
}
Change depends annotations with value to attribute
use PHPUnit\Framework\TestCase;
final class SomeTest extends TestCase
{
public function testOne() {}
- /**
- * @depends testOne
- */
+ #[\PHPUnit\Framework\Attributes\Depends('testOne')]
public function testThree(): void
{
}
}
Change @testWith() annotation to #[TestWith] attribute
use PHPUnit\Framework\TestCase;
+use PHPUnit\Framework\Attributes\TestWith;
final class SomeFixture extends TestCase
{
- /**
- * @testWith ["foo"]
- * ["bar"]
- */
+ #[TestWith(['foo'])]
+ #[TestWith(['bar'])]
public function test(): void
{
}
}
Change dataProvider annotations to attribute
use PHPUnit\Framework\TestCase;
final class SomeTest extends TestCase
{
- /**
- * @dataProvider someMethod()
- */
+ #[\PHPUnit\Framework\Attributes\DataProvider('someMethod')]
public function test(): void
{
}
}