Static analysis (PHPStan)
A macro only exists once a service provider has booted — which PHPStan never does — so $table->morphKey(...) would otherwise be an “undefined method” error under Larastan. The toolkit ships a PHPStan extension that declares the macros statically:
- stubs/BlueprintMacros.stub — the four Blueprint macros.
- RoundlyConsulting\PackageToolkit\PHPStan\QueryMacrosExtension — the whereLikeEscaped() macro on the query and Eloquent builders. Both builder classes are already described by Larastan’s own stub files, and only one stub per class is used, so these are contributed by reflection instead.
Both are registered in extension.neon, which phpstan/extension-installer picks up automatically — nothing to configure. Without the installer, include it by hand:
includes:
- vendor/roundly-consulting/package-toolkit-for-laravel/extension.neonFor reference, this is what extension.neon registers:
parameters:
stubFiles:
- stubs/BlueprintMacros.stub
services:
-
class: RoundlyConsulting\PackageToolkit\PHPStan\QueryMacrosExtension
tags:
- phpstan.broker.methodsClassReflectionExtensionShow your open-source love
This package is free and MIT-licensed. If it saves you time, a one-off donation or a Patreon membership keeps it maintained, tested and documented.
More ways to support, including cryptoBy donating, you agree to our donation terms.
Want this built into your product?
We integrate our packages into custom Laravel and AI builds. Tell us what you're working on and we'll reply within 48 hours.