Find the best Rector rule to solve your problem. Searching through 1036 rules.
Found 10 rules:
Enable "framework.validation.enable_attributes" config, to load validation rules from attributes
$container->loadFromExtension('framework', [
'validation' => [
- 'enable_attributes' => false,
+ 'enable_attributes' => true,
],
]);
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 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()
{
}
}
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
{
}
}
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);
}
}
Replace deprecated '#item_attributes' with '#attributes' in image_formatter and responsive_image_formatter render arrays
$element = [
'#theme' => 'image_formatter',
'#item' => $item,
- '#item_attributes' => ['class' => ['my-image']],
+ '#attributes' => ['class' => ['my-image']],
];