ConfigToTypedConfigMethodCallRector

Refactor config() calls to use type-specific methods when the expected type is known

-$name = (string) config('app.name');
-$lifetime = (int) config('session.lifetime');
-$debug = (bool) config('app.debug');
-$version = (float) config('app.version');
-$connections = (array) config('database.connections');
+$name = config()->string('app.name');
+$lifetime = config()->integer('session.lifetime');
+$debug = config()->boolean('app.debug');
+$version = config()->float('app.version');
+$connections = config()->array('database.connections');

Configure your rector.php:

<?php

use RectorLaravel\Rector\FuncCall\ConfigToTypedConfigMethodCallRector;
use Rector\Config\RectorConfig;

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