Shared PHPStan configuration for WordPress/WooCommerce projects.
Includes:
- PHPStan WordPress extension
- WooCommerce stubs
- PHPStan deprecation rules
- selected PHPStan strict rules
- default analysis level
5 - default path
src
composer require --dev wpdesk/phpstan-rulesIf Composer asks about phpstan/extension-installer, allow it.
Run PHPStan:
vendor/bin/phpstan analyseTo override defaults, add phpstan.neon in your project:
includes:
- vendor/wpdesk/phpstan-rules/rules.neon
parameters:
paths:
- src
- testsWhen analysing a plugin that depends on another plugin, generate stubs for the dependency:
composer global require php-stubs/generator
generate-stubs --out=.stubs/dependency.stub -- /path/to/dependency/srcThen include them:
parameters:
scanFiles:
- .stubs/dependency.stub