ErrorBagPropertyToErrorBagAttributeRector

Changes the errorBag property to use the ErrorBag attribute

 use Illuminate\Foundation\Http\FormRequest;
+use Illuminate\Foundation\Http\Attributes\ErrorBag;

+#[ErrorBag('custom')]
 class StorePostRequest extends FormRequest
 {
-    protected $errorBag = 'custom';
 }

Configure your rector.php:

<?php

use RectorLaravel\Rector\Class_\ErrorBagPropertyToErrorBagAttributeRector;
use Rector\Config\RectorConfig;

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