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

Found 6 rules:

DynamicClassConstFetchRector

constant(Example::class . '::' . $constName) to dynamic class const fetch Example::{$constName}

-constant(Example::class . '::' . $constName);
+Example::{$constName};
SETS:  PHP 8.3

CombineHostPortLdapUriRector

Combine separated host and port on ldap_connect() args

-ldap_connect('ldap://ldap.example.com', 389);
+ldap_connect('ldap://ldap.example.com:389');
SETS:  PHP 8.3

RemoveGetClassGetParentClassNoArgsRector

Replace calls to get_class() and get_parent_class() without arguments with self::class and parent::class.

 class Example extends StdClass {
     public function whoAreYou() {
-        return get_class() . ' daughter of ' . get_parent_class();
+        return self::class . ' daughter of ' . parent::class;
     }
 }
SETS:  PHP 8.3

AddTypeToConstRector

Add type to constants based on their value

 final class SomeClass
 {
-    public const TYPE = 'some_type';
+    public const string TYPE = 'some_type';
 }
SETS:  PHP 8.3

ReadOnlyAnonymousClassRector

Decorate read-only anonymous class with readonly attribute

-new class
+new readonly class
 {
     public function __construct(
-        private readonly string $name
+        private string $name
     ) {
     }
 };
SETS:  PHP 8.3

Configurable

AddOverrideAttributeToOverriddenMethodsRector

Add override attribute to overridden methods

 class ParentClass
 {
     public function foo()
     {
         echo 'default';
     }
 }

 final class ChildClass extends ParentClass
 {
+    #[\Override]
     public function foo()
     {
         echo 'override default';
     }
 }
SETS:  PHP 8.3