A set of PHPStan rules that enforce Hihaho's Laravel guidelines
at analyse time. They flag invade() calls in app code, facade aliases
outside Blade, and stray debug helpers (dump, dd, ray, and friends)
left behind in production or test paths.
If you want the auto-fix counterparts for class-naming and route-group
conventions, see hihaho/rector-rules.
- PHP 8.3 or higher
- PHPStan 2.1 or higher
- Laravel 11.31, 12.x, or 13.x (via
illuminate/support)
composer require --dev hihaho/phpstan-rulesIf you have phpstan/extension-installer,
that's it. The rules register themselves.
Without it, include the extension in your phpstan.neon:
includes:
- vendor/hihaho/phpstan-rules/extension.neonFlags invade() calls inside App\.
invade is a test helper for reaching into private state; it has no place
in production code. Also flags \Livewire\invade() in any namespace; if
you need invade, use the global one from spatie/invade.
namespace App\Services;
invade($user)->privateMethod(); // reportedIdentifiers: hihaho.generic.noInvadeInAppCode,
hihaho.generic.disallowedUsageOfLivewireInvade
Short facade aliases belong in Blade. In PHP, use the fully qualified facade so imports stay explicit.
use Route; // reported
use Illuminate\Support\Facades\Route; // fineIdentifier: hihaho.generic.onlyAllowFacadeAliasInBlade
Three rules that together keep debug calls out of App\ and Tests\:
| Rule | Targets | Examples |
|---|---|---|
NoDebugInNamespaceRule |
Global debug functions | dump(), dd(), ddd(), ray(), print_r(), var_dump() |
ChainedNoDebugInNamespaceRule |
Method chains on Laravel types | collect()->dump(), $builder->dd() |
StaticChainedNoDebugInNamespaceRule |
Static calls on Laravel facades | Http::dump(), Cache::dd() |
The chained and static rules use PHPStan reflection to narrow matches:
they only flag methods declared by (or proxied through) the Illuminate\
namespace, so your own domain classes with a ->dump() method stay clean.
Identifiers: hihaho.debug.noDebugIn{App,Tests},
hihaho.debug.noChainedDebugIn{App,Tests},
hihaho.debug.noStaticChainedDebugIn{App,Tests}
composer testBefore opening a PR, run the full pipeline (Pint, Rector, PHPStan, tests):
composer qaSee CHANGELOG.md for release notes.
See CONTRIBUTING.md.
Please email security@hihaho.com instead of filing a public issue.
MIT. See LICENSE.md.