Find the best Rector rule to solve your problem. Searching through 895 rules.

Found 31 rules:

DelayPropertyToDelayAttributeRector

Changes the delay property to use the Delay attribute

 use Illuminate\Contracts\Queue\ShouldQueue;
+use Illuminate\Queue\Attributes\Delay;

+#[Delay(10)]
 final class ProcessPodcast implements ShouldQueue
 {
-    public $delay = 10;
 }

VisiblePropertyToVisibleAttributeRector

Changes model visible property to use the Visible attribute

 use Illuminate\Database\Eloquent\Model;
+use Illuminate\Database\Eloquent\Attributes\Visible;

+#[Visible(['name', 'email'])]
 class User extends Model
 {
-    protected $visible = [
-        'name',
-        'email',
-    ];
 }

WithoutTimestampsPropertyToWithoutTimestampsAttributeRector

Changes model timestamps = false property to use the WithoutTimestamps attribute

 use Illuminate\Database\Eloquent\Model;
+use Illuminate\Database\Eloquent\Attributes\WithoutTimestamps;

+#[WithoutTimestamps]
 class EventLog extends Model
 {
-    public $timestamps = false;
 }

TablePropertyToTableAttributeRector

Changes model table-related properties to use the Table attribute

 use Illuminate\Database\Eloquent\Model;
+use Illuminate\Database\Eloquent\Attributes\Table;

+#[Table(name: 'users', key: 'user_id', keyType: 'string', incrementing: false)]
 class User extends Model
 {
-    protected $table = 'users';
-
-    protected $primaryKey = 'user_id';
-
-    protected $keyType = 'string';
-
-    protected $incrementing = false;
 }

CollectedByPropertyToCollectedByAttributeRector

Changes model newCollection method to use the CollectedBy attribute

 use Illuminate\Database\Eloquent\Model;
-use Illuminate\Database\Eloquent\Collection;
 use App\Collections\UserCollection;
+use Illuminate\Database\Eloquent\Attributes\CollectedBy;

+#[CollectedBy(UserCollection::class)]
 class User extends Model
 {
-    /**
-     * @param  array<int, \Illuminate\Database\Eloquent\Model>  $models
-     * @return \Illuminate\Database\Eloquent\Collection<int, \Illuminate\Database\Eloquent\Model>
-     */
-    public function newCollection(array $models = []): Collection
-    {
-        return new UserCollection($models);
-    }
 }

FillablePropertyToFillableAttributeRector

Changes model fillable property to use the fillable attribute

 use Illuminate\Database\Eloquent\Model;
+use Illuminate\Database\Eloquent\Attributes\Fillable;

+#[Fillable(['name', 'email'])]
 class User extends Model
 {
-    protected $fillable = [
-        'name',
-        'email',
-    ];
 }

GuardedPropertyToGuardedAttributeRector

Changes model guarded property to use the guarded attribute

 use Illuminate\Database\Eloquent\Model;
+use Illuminate\Database\Eloquent\Attributes\Guarded;

+#[Guarded(['is_admin'])]
 class User extends Model
 {
-    protected $guarded = [
-        'is_admin',
-    ];
 }

CommandHiddenPropertyToHiddenAttributeRector

Changes the hidden property to use the Hidden attribute on console commands

 use Illuminate\Console\Command;
+use Illuminate\Console\Attributes\Hidden;

+#[Hidden]
 class SendEmails extends Command
 {
-    protected $hidden = true;
 }

HelpPropertyToHelpAttributeRector

Changes the help property to use the Help attribute

 use Illuminate\Console\Command;
+use Illuminate\Console\Attributes\Help;

+#[Help('This command sends emails to all users')]
 class SendEmails extends Command
 {
-    protected $help = 'This command sends emails to all users';
 }

WithoutIncrementingPropertyToWithoutIncrementingAttributeRector

Changes model incrementing = false property to use the WithoutIncrementing attribute

 use Illuminate\Database\Eloquent\Model;
+use Illuminate\Database\Eloquent\Attributes\WithoutIncrementing;

+#[WithoutIncrementing]
 class User extends Model
 {
-    public $incrementing = false;
 }

AppendsPropertyToAppendsAttributeRector

Changes model appends property to use the appends attribute

 use Illuminate\Database\Eloquent\Model;
+use Illuminate\Database\Eloquent\Attributes\Appends;

+#[Appends(['full_name'])]
 class User extends Model
 {
-    protected $appends = [
-        'full_name',
-    ];
 }

BackoffPropertyToBackoffAttributeRector

Changes the backoff property to use the Backoff attribute

 use Illuminate\Contracts\Queue\ShouldQueue;
+use Illuminate\Queue\Attributes\Backoff;

+#[Backoff(3)]
 final class ProcessPodcast implements ShouldQueue
 {
-    public $backoff = 3;
 }

MaxExceptionsPropertyToMaxExceptionsAttributeRector

Changes the maxExceptions property to use the MaxExceptions attribute

 use Illuminate\Contracts\Queue\ShouldQueue;
+use Illuminate\Queue\Attributes\MaxExceptions;

+#[MaxExceptions(3)]
 final class ProcessPodcast implements ShouldQueue
 {
-    public $maxExceptions = 3;
 }

SignaturePropertyToSignatureAttributeRector

Changes the signature property to use the Signature attribute

 use Illuminate\Console\Command;
+use Illuminate\Console\Attributes\Signature;

+#[Signature('mail:send {user}')]
 class SendEmails extends Command
 {
-    protected $signature = 'mail:send {user}';
 }

TimeoutPropertyToTimeoutAttributeRector

Changes the timeout property to use the Timeout attribute

 use Illuminate\Contracts\Queue\ShouldQueue;
+use Illuminate\Queue\Attributes\Timeout;

+#[Timeout(120)]
 final class ProcessPodcast implements ShouldQueue
 {
-    public $timeout = 120;
 }

JobConnectionPropertyToJobConnectionAttributeRector

Changes the connection property to use the Connection attribute on queue jobs

 use Illuminate\Contracts\Queue\ShouldQueue;
+use Illuminate\Queue\Attributes\Connection;

+#[Connection('redis')]
 final class ProcessPodcast implements ShouldQueue
 {
-    public $connection = 'redis';
 }

CollectsPropertyToCollectsAttributeRector

Changes the collects property to use the Collects attribute

 use App\Http\Resources\UserResource;
+use Illuminate\Http\Resources\Attributes\Collects;
 use Illuminate\Http\Resources\Json\JsonResource;

+#[Collects(UserResource::class)]
 class UserCollection extends JsonResource
 {
-    protected $collects = UserResource::class;
 }

QueuePropertyToQueueAttributeRector

Changes the queue property to use the Queue attribute

 use Illuminate\Contracts\Queue\ShouldQueue;
+use Illuminate\Queue\Attributes\Queue;

+#[Queue('podcasts')]
 final class ProcessPodcast implements ShouldQueue
 {
-    public $queue = 'podcasts';
 }

FailOnTimeoutPropertyToFailOnTimeoutAttributeRector

Changes the failOnTimeout property to use the FailOnTimeout attribute

 use Illuminate\Contracts\Queue\ShouldQueue;
+use Illuminate\Queue\Attributes\FailOnTimeout;

+#[FailOnTimeout(true)]
 final class ProcessPodcast implements ShouldQueue
 {
-    public $failOnTimeout = true;
 }

DeleteWhenMissingModelsPropertyToDeleteWhenMissingModelsAttributeRector

Changes the deleteWhenMissingModels property to use the DeleteWhenMissingModels attribute

 use Illuminate\Contracts\Queue\ShouldQueue;
+use Illuminate\Queue\Attributes\DeleteWhenMissingModels;

+#[DeleteWhenMissingModels]
 final class ProcessPodcast implements ShouldQueue
 {
-    public $deleteWhenMissingModels = true;
 }

UniqueForPropertyToUniqueForAttributeRector

Changes the uniqueFor property to use the UniqueFor attribute

 use Illuminate\Contracts\Queue\ShouldQueue;
+use Illuminate\Queue\Attributes\UniqueFor;

+#[UniqueFor(1800)]
 final class ProcessPodcast implements ShouldQueue
 {
-    public $uniqueFor = 1800;
 }

ConnectionPropertyToConnectionAttributeRector

Changes model connection property to use the Connection attribute

 use Illuminate\Database\Eloquent\Model;
+use Illuminate\Database\Eloquent\Attributes\Connection;

+#[Connection('sqlite')]
 class User extends Model
 {
-    protected $connection = 'sqlite';
 }

TouchesPropertyToTouchesAttributeRector

Changes model touches property to use the touches attribute

 use Illuminate\Database\Eloquent\Model;
+use Illuminate\Database\Eloquent\Attributes\Touches;

+#[Touches(['posts'])]
 class User extends Model
 {
-    protected $touches = [
-        'posts',
-    ];
 }

AliasesPropertyToAliasesAttributeRector

Changes the aliases property to use the Aliases attribute

 use Illuminate\Console\Command;
+use Illuminate\Console\Attributes\Aliases;

+#[Aliases(['email:send'])]
 class SendEmails extends Command
 {
-    protected $aliases = ['email:send'];
 }

StopOnFirstFailurePropertyToStopOnFirstFailureAttributeRector

Changes the stopOnFirstFailure property to use the StopOnFirstFailure attribute

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

+#[StopOnFirstFailure]
 class StorePostRequest extends FormRequest
 {
-    protected $stopOnFirstFailure = true;
 }

PreserveKeysPropertyToPreserveKeysAttributeRector

Changes the preserveKeys property to use the PreserveKeys attribute

+use Illuminate\Http\Resources\Attributes\PreserveKeys;
 use Illuminate\Http\Resources\Json\JsonResource;

+#[PreserveKeys]
 class UserResource extends JsonResource
 {
-    protected $preserveKeys = true;
 }

HiddenPropertyToHiddenAttributeRector

Changes model hidden property to use the hidden attribute

 use Illuminate\Database\Eloquent\Model;
+use Illuminate\Database\Eloquent\Attributes\Hidden;

+#[Hidden(['password'])]
 class User extends Model
 {
-    protected $hidden = [
-        'password',
-    ];
 }

TriesPropertyToTriesAttributeRector

Changes the tries property to use the Tries attribute

 use Illuminate\Contracts\Queue\ShouldQueue;
+use Illuminate\Queue\Attributes\Tries;

+#[Tries(3)]
 final class ProcessPodcast implements ShouldQueue
 {
-    public $tries = 3;
 }

DateFormatPropertyToDateFormatAttributeRector

Changes model dateFormat property to use the DateFormat attribute

 use Illuminate\Database\Eloquent\Model;
+use Illuminate\Database\Eloquent\Attributes\DateFormat;

+#[DateFormat('U')]
 class User extends Model
 {
-    protected $dateFormat = 'U';
 }

DescriptionPropertyToDescriptionAttributeRector

Changes the description property to use the Description attribute

 use Illuminate\Console\Command;
+use Illuminate\Console\Attributes\Description;

+#[Description('Send marketing emails to users')]
 class SendEmails extends Command
 {
-    protected $description = 'Send marketing emails to users';
 }

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';
 }