From 14af8ef19012758ef61d2d6620880fabb66accab Mon Sep 17 00:00:00 2001 From: Peter Fox Date: Tue, 24 Mar 2026 14:58:17 +0000 Subject: [PATCH 1/2] fix made --- docs/rector_rules_overview.md | 177 +++++++++++++++++- src/NodeFactory/TableAttributeFactory.php | 2 +- .../TablePropertyToTableAttributeRector.php | 4 +- .../combine_existing_attribute.php.inc | 4 +- .../do_not_remove_invalid_properties.php.inc | 2 +- .../Fixture/fixture.php.inc | 2 +- .../Fixture/only_table.php.inc | 2 +- .../replace_existing_attribute.php.inc | 4 +- 8 files changed, 185 insertions(+), 12 deletions(-) diff --git a/docs/rector_rules_overview.md b/docs/rector_rules_overview.md index 77c577fd..cb0f5d96 100644 --- a/docs/rector_rules_overview.md +++ b/docs/rector_rules_overview.md @@ -1,4 +1,4 @@ -# 97 Rules Overview +# 106 Rules Overview ## AbortIfRector @@ -469,6 +469,25 @@ Avoid negated conditionals in `filter()` by using `reject()`, or vice versa.
+## BackoffPropertyToBackoffAttributeRector + +Changes the backoff property to use the Backoff attribute + +- class: [`RectorLaravel\Rector\Class_\BackoffPropertyToBackoffAttributeRector`](../src/Rector/Class_/BackoffPropertyToBackoffAttributeRector.php) + +```diff + use Illuminate\Contracts\Queue\ShouldQueue; ++use Illuminate\Queue\Attributes\Backoff; + ++#[Backoff(3)] + final class ProcessPodcast implements ShouldQueue + { +- public $backoff = 3; + } +``` + +
+ ## CallOnAppArrayAccessToStandaloneAssignRector Replace magical call on `$this->app["something"]` to standalone type assign variable @@ -920,6 +939,25 @@ Use the static factory method instead of global factory function.
+## FailOnTimeoutPropertyToFailOnTimeoutAttributeRector + +Changes the failOnTimeout property to use the FailOnTimeout attribute + +- class: [`RectorLaravel\Rector\Class_\FailOnTimeoutPropertyToFailOnTimeoutAttributeRector`](../src/Rector/Class_/FailOnTimeoutPropertyToFailOnTimeoutAttributeRector.php) + +```diff + use Illuminate\Contracts\Queue\ShouldQueue; ++use Illuminate\Queue\Attributes\FailOnTimeout; + ++#[FailOnTimeout(true)] + final class ProcessPodcast implements ShouldQueue + { +- public $failOnTimeout = true; + } +``` + +
+ ## FillablePropertyToFillableAttributeRector Changes model fillable property to use the fillable attribute @@ -1003,6 +1041,25 @@ Changes model hidden property to use the hidden attribute
+## JobConnectionPropertyToJobConnectionAttributeRector + +Changes the connection property to use the Connection attribute on queue jobs + +- class: [`RectorLaravel\Rector\Class_\JobConnectionPropertyToJobConnectionAttributeRector`](../src/Rector/Class_/JobConnectionPropertyToJobConnectionAttributeRector.php) + +```diff + use Illuminate\Contracts\Queue\ShouldQueue; ++use Illuminate\Queue\Attributes\Connection; + ++#[Connection('redis')] + final class ProcessPodcast implements ShouldQueue + { +- public $connection = 'redis'; + } +``` + +
+ ## JsonCallToExplicitJsonCallRector Change method calls from `$this->json` to `$this->postJson,` `$this->putJson,` etc. @@ -1117,6 +1174,25 @@ Makes Model attributes and scopes protected
+## MaxExceptionsPropertyToMaxExceptionsAttributeRector + +Changes the maxExceptions property to use the MaxExceptions attribute + +- class: [`RectorLaravel\Rector\Class_\MaxExceptionsPropertyToMaxExceptionsAttributeRector`](../src/Rector/Class_/MaxExceptionsPropertyToMaxExceptionsAttributeRector.php) + +```diff + use Illuminate\Contracts\Queue\ShouldQueue; ++use Illuminate\Queue\Attributes\MaxExceptions; + ++#[MaxExceptions(3)] + final class ProcessPodcast implements ShouldQueue + { +- public $maxExceptions = 3; + } +``` + +
+ ## MigrateToSimplifiedAttributeRector Migrate to the new Model attributes syntax @@ -1262,6 +1338,25 @@ Change deprecated `$defer` = true; to `Illuminate\Contracts\Support\DeferrablePr
+## QueuePropertyToQueueAttributeRector + +Changes the queue property to use the Queue attribute + +- class: [`RectorLaravel\Rector\Class_\QueuePropertyToQueueAttributeRector`](../src/Rector/Class_/QueuePropertyToQueueAttributeRector.php) + +```diff + use Illuminate\Contracts\Queue\ShouldQueue; ++use Illuminate\Queue\Attributes\Queue; + ++#[Queue('podcasts')] + final class ProcessPodcast implements ShouldQueue + { +- public $queue = 'podcasts'; + } +``` + +
+ ## Redirect301ToPermanentRedirectRector Change "redirect" call with 301 to "permanentRedirect" @@ -1498,6 +1593,27 @@ Replace deprecated faker property fetch with method call
+## ReplaceQueueTraitsWithQueueableRector + +Replace Dispatchable, InteractsWithQueue, Queueable, and SerializesModels traits with the Queueable trait + +- class: [`RectorLaravel\Rector\Class_\ReplaceQueueTraitsWithQueueableRector`](../src/Rector/Class_/ReplaceQueueTraitsWithQueueableRector.php) + +```diff + use Illuminate\Bus\Queueable; + use Illuminate\Foundation\Bus\Dispatchable; + use Illuminate\Queue\InteractsWithQueue; + use Illuminate\Queue\SerializesModels; + + class SomeJob + { +- use Dispatchable, InteractsWithQueue, Queueable, SerializesModels; ++ use \Illuminate\Foundation\Queue\Queueable; + } +``` + +
+ ## ReplaceServiceContainerCallArgRector Changes the string or class const used for a service container make call @@ -1755,7 +1871,7 @@ Changes model table-related properties to use the Table attribute use Illuminate\Database\Eloquent\Model; +use Illuminate\Database\Eloquent\Attributes\Table; -+#[Table(table: 'users', key: 'user_id', keyType: 'string', incrementing: false)] ++#[Table(name: 'users', key: 'user_id', keyType: 'string', incrementing: false)] class User extends Model { - protected $table = 'users'; @@ -1802,6 +1918,25 @@ Change if throw to throw_if
+## TimeoutPropertyToTimeoutAttributeRector + +Changes the timeout property to use the Timeout attribute + +- class: [`RectorLaravel\Rector\Class_\TimeoutPropertyToTimeoutAttributeRector`](../src/Rector/Class_/TimeoutPropertyToTimeoutAttributeRector.php) + +```diff + use Illuminate\Contracts\Queue\ShouldQueue; ++use Illuminate\Queue\Attributes\Timeout; + ++#[Timeout(120)] + final class ProcessPodcast implements ShouldQueue + { +- public $timeout = 120; + } +``` + +
+ ## TouchesPropertyToTouchesAttributeRector Changes model touches property to use the touches attribute @@ -1823,6 +1958,25 @@ Changes model touches property to use the touches attribute
+## TriesPropertyToTriesAttributeRector + +Changes the tries property to use the Tries attribute + +- class: [`RectorLaravel\Rector\Class_\TriesPropertyToTriesAttributeRector`](../src/Rector/Class_/TriesPropertyToTriesAttributeRector.php) + +```diff + use Illuminate\Contracts\Queue\ShouldQueue; ++use Illuminate\Queue\Attributes\Tries; + ++#[Tries(3)] + final class ProcessPodcast implements ShouldQueue + { +- public $tries = 3; + } +``` + +
+ ## TypeHintTappableCallRector Automatically type hints your tappable closures @@ -1883,6 +2037,25 @@ Unify Model `$dates` property with `$casts`
+## UniqueForPropertyToUniqueForAttributeRector + +Changes the uniqueFor property to use the UniqueFor attribute + +- class: [`RectorLaravel\Rector\Class_\UniqueForPropertyToUniqueForAttributeRector`](../src/Rector/Class_/UniqueForPropertyToUniqueForAttributeRector.php) + +```diff + use Illuminate\Contracts\Queue\ShouldQueue; ++use Illuminate\Queue\Attributes\UniqueFor; + ++#[UniqueFor(1800)] + final class ProcessPodcast implements ShouldQueue + { +- public $uniqueFor = 1800; + } +``` + +
+ ## UseComponentPropertyWithinCommandsRector Use `$this->components` property within commands diff --git a/src/NodeFactory/TableAttributeFactory.php b/src/NodeFactory/TableAttributeFactory.php index 84eb4c0f..89a602a4 100644 --- a/src/NodeFactory/TableAttributeFactory.php +++ b/src/NodeFactory/TableAttributeFactory.php @@ -18,7 +18,7 @@ */ public function create(Expr $table, array $options): AttributeGroup { - $args = [new Arg($table, false, false, [], new Identifier('table'))]; + $args = [new Arg($table, false, false, [], new Identifier('name'))]; foreach ($options as $name => $expr) { $args[] = new Arg($expr, false, false, [], new Identifier($name)); diff --git a/src/Rector/Class_/TablePropertyToTableAttributeRector.php b/src/Rector/Class_/TablePropertyToTableAttributeRector.php index 5c8ac517..8d140052 100644 --- a/src/Rector/Class_/TablePropertyToTableAttributeRector.php +++ b/src/Rector/Class_/TablePropertyToTableAttributeRector.php @@ -49,7 +49,7 @@ class User extends Model use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Attributes\Table; -#[Table(table: 'users', key: 'user_id', keyType: 'string', incrementing: false)] +#[Table(name: 'users', key: 'user_id', keyType: 'string', incrementing: false)] class User extends Model { } @@ -93,7 +93,7 @@ public function refactor(Node $node): ?Node } if (! $tableValue instanceof String_ && $hasExistingAttribute) { - $tableValue = $this->getExistingAttributeArg($node, $tableAttributeClass, 'table'); + $tableValue = $this->getExistingAttributeArg($node, $tableAttributeClass, 'name'); if (! $tableValue instanceof String_) { return null; } diff --git a/tests/Rector/Class_/TablePropertyToTableAttributeRector/Fixture/combine_existing_attribute.php.inc b/tests/Rector/Class_/TablePropertyToTableAttributeRector/Fixture/combine_existing_attribute.php.inc index 816d5fe9..b604c92a 100644 --- a/tests/Rector/Class_/TablePropertyToTableAttributeRector/Fixture/combine_existing_attribute.php.inc +++ b/tests/Rector/Class_/TablePropertyToTableAttributeRector/Fixture/combine_existing_attribute.php.inc @@ -4,7 +4,7 @@ namespace RectorLaravel\Tests\Rector\Class_\TablePropertyToTableAttributeRector\ use Illuminate\Database\Eloquent\Model; -#[\Illuminate\Database\Eloquent\Attributes\Table(table: 'users')] +#[\Illuminate\Database\Eloquent\Attributes\Table(name: 'users')] class CombineExistingAttribute extends Model { protected $primaryKey = 'user_id'; @@ -18,7 +18,7 @@ namespace RectorLaravel\Tests\Rector\Class_\TablePropertyToTableAttributeRector\ use Illuminate\Database\Eloquent\Model; -#[\Illuminate\Database\Eloquent\Attributes\Table(table: 'users', key: 'user_id')] +#[\Illuminate\Database\Eloquent\Attributes\Table(name: 'users', key: 'user_id')] class CombineExistingAttribute extends Model { } diff --git a/tests/Rector/Class_/TablePropertyToTableAttributeRector/Fixture/do_not_remove_invalid_properties.php.inc b/tests/Rector/Class_/TablePropertyToTableAttributeRector/Fixture/do_not_remove_invalid_properties.php.inc index b0f667c8..1437554a 100644 --- a/tests/Rector/Class_/TablePropertyToTableAttributeRector/Fixture/do_not_remove_invalid_properties.php.inc +++ b/tests/Rector/Class_/TablePropertyToTableAttributeRector/Fixture/do_not_remove_invalid_properties.php.inc @@ -18,7 +18,7 @@ namespace RectorLaravel\Tests\Rector\Class_\TablePropertyToTableAttributeRector\ use Illuminate\Database\Eloquent\Model; -#[\Illuminate\Database\Eloquent\Attributes\Table(table: 'users')] +#[\Illuminate\Database\Eloquent\Attributes\Table(name: 'users')] class DoNotRemoveInvalidProperties extends Model { public $primaryKey = 'user_id'; diff --git a/tests/Rector/Class_/TablePropertyToTableAttributeRector/Fixture/fixture.php.inc b/tests/Rector/Class_/TablePropertyToTableAttributeRector/Fixture/fixture.php.inc index a26e87dc..565fd025 100644 --- a/tests/Rector/Class_/TablePropertyToTableAttributeRector/Fixture/fixture.php.inc +++ b/tests/Rector/Class_/TablePropertyToTableAttributeRector/Fixture/fixture.php.inc @@ -23,7 +23,7 @@ namespace RectorLaravel\Tests\Rector\Class_\TablePropertyToTableAttributeRector\ use Illuminate\Database\Eloquent\Model; -#[\Illuminate\Database\Eloquent\Attributes\Table(table: 'users', key: 'user_id', keyType: 'string', incrementing: false)] +#[\Illuminate\Database\Eloquent\Attributes\Table(name: 'users', key: 'user_id', keyType: 'string', incrementing: false)] class User extends Model { } diff --git a/tests/Rector/Class_/TablePropertyToTableAttributeRector/Fixture/only_table.php.inc b/tests/Rector/Class_/TablePropertyToTableAttributeRector/Fixture/only_table.php.inc index 0d0cc9de..a43c3012 100644 --- a/tests/Rector/Class_/TablePropertyToTableAttributeRector/Fixture/only_table.php.inc +++ b/tests/Rector/Class_/TablePropertyToTableAttributeRector/Fixture/only_table.php.inc @@ -17,7 +17,7 @@ namespace RectorLaravel\Tests\Rector\Class_\TablePropertyToTableAttributeRector\ use Illuminate\Database\Eloquent\Model; -#[\Illuminate\Database\Eloquent\Attributes\Table(table: 'users')] +#[\Illuminate\Database\Eloquent\Attributes\Table(name: 'users')] class UserOnlyTable extends Model { } diff --git a/tests/Rector/Class_/TablePropertyToTableAttributeRector/Fixture/replace_existing_attribute.php.inc b/tests/Rector/Class_/TablePropertyToTableAttributeRector/Fixture/replace_existing_attribute.php.inc index 6b7c3e1f..49a28763 100644 --- a/tests/Rector/Class_/TablePropertyToTableAttributeRector/Fixture/replace_existing_attribute.php.inc +++ b/tests/Rector/Class_/TablePropertyToTableAttributeRector/Fixture/replace_existing_attribute.php.inc @@ -4,7 +4,7 @@ namespace RectorLaravel\Tests\Rector\Class_\TablePropertyToTableAttributeRector\ use Illuminate\Database\Eloquent\Model; -#[\Illuminate\Database\Eloquent\Attributes\Table(table: 'customers')] +#[\Illuminate\Database\Eloquent\Attributes\Table(name: 'customers')] class ReplaceExistingAttribute extends Model { protected $table = 'users'; @@ -20,7 +20,7 @@ namespace RectorLaravel\Tests\Rector\Class_\TablePropertyToTableAttributeRector\ use Illuminate\Database\Eloquent\Model; -#[\Illuminate\Database\Eloquent\Attributes\Table(table: 'users', key: 'user_id')] +#[\Illuminate\Database\Eloquent\Attributes\Table(name: 'users', key: 'user_id')] class ReplaceExistingAttribute extends Model { } From 5672e35b0469f958acdfc6d131dcf243a3820a73 Mon Sep 17 00:00:00 2001 From: Peter Fox Date: Tue, 24 Mar 2026 15:08:50 +0000 Subject: [PATCH 2/2] fix set test --- tests/Sets/Laravel130/Fixture/laravel130.php.inc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/Sets/Laravel130/Fixture/laravel130.php.inc b/tests/Sets/Laravel130/Fixture/laravel130.php.inc index 81bd53f2..9cb2cfc7 100644 --- a/tests/Sets/Laravel130/Fixture/laravel130.php.inc +++ b/tests/Sets/Laravel130/Fixture/laravel130.php.inc @@ -72,7 +72,7 @@ use Illuminate\Database\Eloquent\Model; #[\Illuminate\Database\Eloquent\Attributes\Hidden([ 'password', ])] -#[\Illuminate\Database\Eloquent\Attributes\Table(table: 'users', key: 'user_id', keyType: 'string', incrementing: false)] +#[\Illuminate\Database\Eloquent\Attributes\Table(name: 'users', key: 'user_id', keyType: 'string', incrementing: false)] #[\Illuminate\Database\Eloquent\Attributes\Touches([ 'posts', ])]