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

Found 11 rules:

ArrayKeyExistsNullToEmptyStringRector

Replace null key in array_key_exists with empty string

-array_key_exists(null, $array);
+array_key_exists('', $array);
SETS:  PHP 8.5

ChrArgModuloRector

Wrap chr() argument with % 256 to avoid deprecated out-of-range integers

-echo chr(300);
+echo chr(300 % 256);
SETS:  PHP 8.5

RemoveFinfoBufferContextArgRector

Remove argument by position by function name

-finfo_buffer($finfo, $fileContents, FILEINFO_NONE, []);
+finfo_buffer($finfo, $fileContents, FILEINFO_NONE);
SETS:  PHP 8.5

OrdSingleByteRector

Replace ord($str) with ord($str[0])

-echo ord('abc');
+echo ord('a');
SETS:  PHP 8.5

ColonAfterSwitchCaseRector

Change deprecated semicolon to colon after switch case

 switch ($value) {
-    case 'baz';
+    case 'baz':
         echo 'baz';
 }
SETS:  PHP 8.5

ShellExecFunctionCallOverBackticksRector

Replace backticks based with shell_exec() function calls

-$output = `ls -al`;
+$output = shell_exec('ls -al');
 echo "<pre>$output</pre>";
SETS:  PHP 8.5

DeprecatedAnnotationToDeprecatedAttributeRector

Change @deprecated annotation to Deprecated attribute

-/**
- * @deprecated 1.0.0 Use SomeOtherConstant instead
- */
+#[\Deprecated(message: 'Use SomeOtherConstant instead', since: '1.0.0')]
 const SomeConstant = 'irrelevant';
SETS:  PHP 8.5

WakeupToUnserializeRector

Change __wakeup() to __unserialize()

 class User {
-    public function __wakeup() {
+    public function __unserialize(array $data): void{
+        foreach ($data as $property => $value) {
+            if (property_exists($this, $property)) {
+                $this->{$property} = $value;
+            }
+        }
     }
 }
SETS:  PHP 8.5

SleepToSerializeRector

Change __sleep() to __serialize() with correct return values

 class User {
     private $id;
     private $name;

-    public function __sleep() {
-        return ['id', 'name'];
+    public function __serialize(): array {
+        return [
+            'id' => $this->id,
+            'name' => $this->name,
+        ];
     }
 }
SETS:  PHP 8.5

NullDebugInfoReturnRector

Replaces null return value with empty array in __debugInfo methods

 new class
 {
     public function __debugInfo() {
-        return null;
+        return [];
     }
 };
SETS:  PHP 8.5

ArrayFirstLastRector

Make use of array_first() and array_last()

-echo $array[array_key_first($array)];
-echo $array[array_key_last($array)];
+echo array_first($array);
+echo array_last($array;
SETS:  PHP 8.5