Tooling
Static analysis
The PHPStan extension that types custom types, descriptor macros and the testing helpers.
The package ships a PHPStan extension, extension.neon. It is included automatically by
phpstan/extension-installer; otherwise include it by hand:
phpstan.neon
includes:
- vendor/ark4ne/laravel-api-revisions/extension.neon
It types:
Route::revisioned();assertMatchesRevisionSchema()on aTestResponse;- your custom types, called on
Schema; - your descriptor macros, called on any descriptor.
Map your types and macros
PHPStan cannot see what is registered at boot. Map each name:
phpstan.neon
parameters:
apiRevisions:
types:
money: App\Schema\MoneySchema
macros:
whenInFields: 'App\Schema\FieldMacros::whenInFields'
Schema::money(...)then takes the parameters ofMoneySchema's constructor and returns aMoneySchema.->whenInFields(...)takes the parameters of the method after the descriptor, and returns the type it is called on:Schema::string()->whenInFields('notes')is aStringSchema.
Retiring a revision
When you delete a case from the enum, PHPStan reports every reference left to it: the since(), until() and
was() that revision:prune listed, and any guard on it.