ArrayToArrGetRector

Convert array access to Arr::get() method call, skips null coalesce with throw expressions

-$array['key'];
-$array['nested']['key'];
-$array['key'] ?? 'default';
-$array['nested']['key'] ?? 'default';
+\Illuminate\Support\Arr::get($array, 'key');
+\Illuminate\Support\Arr::get($array, 'nested.key');
+\Illuminate\Support\Arr::get($array, 'key', 'default');
+\Illuminate\Support\Arr::get($array, 'nested.key', 'default');
 $array['key'] ?? throw new Exception('Required');

Configure your rector.php:

<?php

use RectorLaravel\Rector\ArrayDimFetch\ArrayToArrGetRector;
use Rector\Config\RectorConfig;

return RectorConfig::configure()
    ->withRules([
        ArrayToArrGetRector::class,
    ]);