DowngradeArrayIsListRector
Replace array_is_list() function
-array_is_list([1 => 'apple', 'orange']);
+$arrayIsList = function (array $array) : bool {
+ if (function_exists('array_is_list')) {
+ return array_is_list($array);
+ }
+
+ if ($array === []) {
+ return true;
+ }
+
+ $current_key = 0;
+ foreach ($array as $key => $noop) {
+ if ($key !== $current_key) {
+ return false;
+ }
+ ++$current_key;
+ }
+
+ return true;
+};
+$arrayIsList([1 => 'apple', 'orange']);
Configure your rector.php:
<?php
use Rector\Config\RectorConfig;
use Rector\DowngradePhp81\Rector\FuncCall\DowngradeArrayIsListRector;
return RectorConfig::configure()
->withRules([
DowngradeArrayIsListRector::class,
]);