Find the best Rector rule to solve your problem. Searching through 791 rules.

Found 10 rules:

TicketAnnotationToAttributeRector

Change annotations with value to attribute

 use PHPUnit\Framework\TestCase;
+use PHPUnit\Framework\Attributes\Ticket;

-/**
- * @ticket 123
- */
+#[Ticket('123')]
 final class SomeTest extends TestCase
 {
 }

CoversAnnotationWithValueToAttributeRector

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()
     {
     }
 }

RequiresAnnotationWithValueToAttributeRector

Change Requires annotations with values to attributes

 use PHPUnit\Framework\TestCase;

-/**
- * @requires PHP > 8.4
- * @requires PHPUnit >= 10
- */
-
+#[\PHPUnit\Framework\Attributes\RequiresPhp('> 8.4')]
+#[\PHPUnit\Framework\Attributes\RequiresPhpunit('>= 10')]
 final class SomeTest extends TestCase
 {
-    /**
-     * @requires setting date.timezone Europe/Berlin
-     */
+    #[\PHPUnit\Framework\Attributes\RequiresSetting('date.timezone', 'Europe/Berlin')]
     public function test()
     {
     }
 }

Configurable

AnnotationWithValueToAttributeRector

Change annotations with value to attribute

 use PHPUnit\Framework\TestCase;
+use PHPUnit\Framework\Attributes\BackupGlobals;

-/**
- * @backupGlobals enabled
- */
+#[BackupGlobals(true)]
 final class SomeTest extends TestCase
 {
 }

DependsAnnotationWithValueToAttributeRector

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
     {
     }
 }

TestWithAnnotationToAttributeRector

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
     {
     }
 }

DataProviderAnnotationToAttributeRector

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
     {
     }
 }

MakeModelAttributesAndScopesProtectedRector

Makes Model attributes and scopes protected

 class User extends Model
 {
-    public function foo(): Attribute
+    protected function foo(): Attribute
     {
         return Attribute::get(fn () => $this->bar);
     }

     #[Scope]
-    public function active(Builder $query): Builder
+    protected function active(Builder $query): Builder
     {
         return $query->where('active', true);
     }
 }
SETS:  Code quality

Configurable

NestedAnnotationToAttributeRector

Change nested annotations to attributes

 use Doctrine\ORM\Mapping as ORM;

 class SomeEntity
 {
-    /**
-     * @ORM\JoinTable(name="join_table_name",
-     *     joinColumns={@ORM\JoinColumn(name="origin_id")},
-     *     inverseJoinColumns={@ORM\JoinColumn(name="target_id")}
-     * )
-     */
+    #[ORM\JoinTable(name: 'join_table_name')]
+    #[ORM\JoinColumn(name: 'origin_id')]
+    #[ORM\InverseJoinColumn(name: 'target_id')]
     private $collection;
 }

SortAttributeNamedArgsRector

Sort named arguments in PHP 8 attributes to match their declaration order

-#[SomeAttribute(bar: $bar, foo: $foo)]
+#[SomeAttribute(foo: $foo, bar: $bar)]
 class SomeClass
 {
 }

 #[Attribute]
 class SomeAttribute
 {
     public function __construct(public $foo, public $bar)
     {
     }
 }
SETS:  Code Quality