Find the best Rector rule to solve your problem
Remove extra parameters
-strlen("asdf", 1);
+strlen("asdf");
String cannot be turned into array by assignment anymore
-$string = '';
+$string = [];
$string[] = 1;
Change binary operation between some number + string to PHP 7.1 compatible version
class SomeClass
{
public function run()
{
- $value = 5 + '';
- $value = 5.0 + 'hi';
+ $value = 5 + 0;
+ $value = 5.0 + 0.0;
}
}
Changes multi catch of same exception to single one | separated.
try {
// Some code...
-} catch (ExceptionType1 $exception) {
- $sameCode;
-} catch (ExceptionType2 $exception) {
+} catch (ExceptionType1 | ExceptionType2 $exception) {
$sameCode;
}
Changes is_array + Traversable check to is_iterable
-is_array($foo) || $foo instanceof Traversable;
+is_iterable($foo);
Change list() to array destruct
class SomeClass
{
public function run()
{
- list($id1, $name1) = $data;
+ [$id1, $name1] = $data;
- foreach ($data as list($id, $name)) {
+ foreach ($data as [$id, $name]) {
}
}
}