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;
Configure your rector.php
:
<?php
use Rector\Config\RectorConfig;
use Rector\Php85\Rector\ArrayDimFetch\ArrayFirstLastRector;
return RectorConfig::configure()
->withRules([
ArrayFirstLastRector::class,
]);