Convert DB Expression string casts to getValue() method calls.
use Illuminate\Support\Facades\DB;
-$string = (string) DB::raw('select 1');
+$string = DB::raw('select 1')->getValue(DB::connection()->getQueryGrammar());
Configure your rector.php
:
<?php
use RectorLaravel\Rector\Cast\DatabaseExpressionCastsToMethodCallRector;
use Rector\Config\RectorConfig;
return RectorConfig::configure()
->withRules([
DatabaseExpressionCastsToMethodCallRector::class,
]);