Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions config/sets/laravel130-attributes.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
use RectorLaravel\Rector\Class_\HiddenPropertyToHiddenAttributeRector;
use RectorLaravel\Rector\Class_\JobConnectionPropertyToJobConnectionAttributeRector;
use RectorLaravel\Rector\Class_\MaxExceptionsPropertyToMaxExceptionsAttributeRector;
use RectorLaravel\Rector\Class_\ObserveCallsToObservedByAttributeRector;
use RectorLaravel\Rector\Class_\PreserveKeysPropertyToPreserveKeysAttributeRector;
use RectorLaravel\Rector\Class_\QueuePropertyToQueueAttributeRector;
use RectorLaravel\Rector\Class_\SignaturePropertyToSignatureAttributeRector;
Expand All @@ -34,6 +35,7 @@
use RectorLaravel\Rector\Class_\VisiblePropertyToVisibleAttributeRector;
use RectorLaravel\Rector\Class_\WithoutIncrementingPropertyToWithoutIncrementingAttributeRector;
use RectorLaravel\Rector\Class_\WithoutTimestampsPropertyToWithoutTimestampsAttributeRector;
use RectorLaravel\Rector\ClassMethod\RemoveModelObserveCallsFromBootRector;

return static function (RectorConfig $rectorConfig): void {
$rectorConfig->import(__DIR__ . '/../config.php');
Expand All @@ -53,6 +55,8 @@
$rectorConfig->rule(FillablePropertyToFillableAttributeRector::class);
$rectorConfig->rule(GuardedPropertyToGuardedAttributeRector::class);
$rectorConfig->rule(HiddenPropertyToHiddenAttributeRector::class);
$rectorConfig->rule(ObserveCallsToObservedByAttributeRector::class);
$rectorConfig->rule(RemoveModelObserveCallsFromBootRector::class);
$rectorConfig->rule(TablePropertyToTableAttributeRector::class);
$rectorConfig->rule(TouchesPropertyToTouchesAttributeRector::class);
$rectorConfig->rule(VisiblePropertyToVisibleAttributeRector::class);
Expand Down
43 changes: 42 additions & 1 deletion docs/rector_rules_overview.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# 106 Rules Overview
# 108 Rules Overview

## AbortIfRector

Expand Down Expand Up @@ -1284,6 +1284,25 @@ Swap the use of NotBooleans used with `filled()` and `blank()` to the correct he

<br>

## ObserveCallsToObservedByAttributeRector

Changes manual model `observe()` registrations in boot methods to use the `ObservedBy` attribute

- class: [`RectorLaravel\Rector\Class_\ObserveCallsToObservedByAttributeRector`](../src/Rector/Class_/ObserveCallsToObservedByAttributeRector.php)

```diff
use App\Observers\UserObserver;
+use Illuminate\Database\Eloquent\Attributes\ObservedBy;
use Illuminate\Foundation\Auth\User as Authenticatable;

+#[ObservedBy([UserObserver::class])]
class User extends Authenticatable
{
}
```

<br>

## NowFuncWithStartOfDayMethodCallToTodayFuncRector

Use `today()` instead of `now()->startOfDay()`
Expand Down Expand Up @@ -1357,6 +1376,28 @@ Changes the queue property to use the Queue attribute

<br>

## RemoveModelObserveCallsFromBootRector

Removes direct model `observe()` registrations from boot methods when they can be represented by `ObservedBy`

- class: [`RectorLaravel\Rector\ClassMethod\RemoveModelObserveCallsFromBootRector`](../src/Rector/ClassMethod/RemoveModelObserveCallsFromBootRector.php)

```diff
use App\Models\User;
use App\Observers\UserObserver;

class AppServiceProvider
{
public function boot(): void
{
- User::observe(UserObserver::class);
$this->bootSomethingElse();
}
}
```

<br>

## Redirect301ToPermanentRedirectRector

Change "redirect" call with 301 to "permanentRedirect"
Expand Down
Loading