---
title: Extra rules
description: Mago-derived lint rules for Laravel, Pest, and code cleanup.
---

These lint rules come from [Mago](https://github.com/carthage-software/mago). Turn them on in `[lint.rules]`:

```toml pun.toml
[lint.rules]
"laravel/prefer-dedicated-status-assertion" = "error"
"laravel/prefer-fake-helper" = "error"
```

`pun lint --fix` applies available fixes. Review the changes from rules marked risky. Each [rule page](/docs/rules/lint) lists the rule's sets.

## Laravel

| Rule | Rewrites |
| --- | --- |
| `laravel/prefer-dedicated-status-assertion` | `->assertStatus(404)` → `->assertNotFound()` |
| `laravel/prefer-fake-helper` (risky) | `$this->faker` → `fake()` in `*Factory` classes |
| `laravel/prefer-array-validation-rules` | `'required\|string'` → `['required', 'string']` in `rules()` |
| `laravel/no-implicit-model-query` (risky) | `User::where(...)` → `User::query()->where(...)` |
| `laravel/require-final-controller` (risky) | `class UserController` → `final class UserController` |

## Pest

| Rule | Rewrites |
| --- | --- |
| `pest/prefer-specific-expectations` | `->toBe(true)` → `->toBeTrue()`, and the same for `false` and `null` |
| `pest/prefer-dedicated-expectation` (risky) | `expect(is_array($x))->toBeTrue()` → `expect($x)->toBeArray()` |
| `pest/prefer-simpler-expectation` | `expect($a > $b)->toBeTrue()` → `expect($a)->toBeGreaterThan($b)` |
| `pest/no-only` (risky) | removes `->only()` from tests |

## Redundant code and modern PHP

| Rule | Rewrites |
| --- | --- |
| `complexity/no-redundant-isset` | `isset($a, $a['b'])` → `isset($a['b'])` |
| `complexity/no-redundant-literal-return` | `if ($x === null) { return null; } return $x;` → `return $x;` |
| `complexity/no-redundant-nullsafe` | `$user?->name ?? 'Guest'` → `$user->name ?? 'Guest'` |
| `dead-code/no-self-assignment` | deletes `$a = $a;` |
| `arrays/prefer-array-spread` (risky) | `array_merge($a, [1], $b)` → `[...$a, 1, ...$b]` |
| `performance/prefer-explode-over-preg-split` | `preg_split('/, /', $s)` → `explode(', ', $s)` |
| `php-8.1/prefer-first-class-callable` (risky) | `fn ($x) => $this->m($x)` → `$this->m(...)` |
| `security/add-sensitive-parameter` | adds `#[\SensitiveParameter]` to `$password`, `$token`, `$secret` and API-key parameters |

The [Mago mapping](/docs/migrate/from/mago) lists upstream names and Pun equivalents.
