wp-phpstan-static-analysis
Installation
SKILL.md
PHPStan static analysis for WordPress
PHPStan catches type errors, dead code, and bad calls without running anything. It doesn't load WordPress, so it needs stubs for core's functions/classes — szepeviktor/phpstan-wordpress provides those plus WP-aware rules. This skill wires it up and tames the WP-specific noise. PHPCS (wp-phpcs-coding-standards) covers style; PHPStan covers types/logic — run both.
When to use this skill
- Adding static analysis to a plugin/theme.
- Writing or reviewing
phpstan.neon/phpstan.neon.dist. - Raising the analysis level on existing code (and baselining the backlog).
- Killing WP-specific false positives (
apply_filtersarg counts,is_wp_error(),$wpdb, conditional constants).
Install
composer require --dev szepeviktor/phpstan-wordpress
composer require --dev phpstan/extension-installer # recommended: auto-registers the extension
szepeviktor/phpstan-wordpress (2.0.3) pulls in phpstan/phpstan ^2.0 and php-stubs/wordpress-stubs ^6.6.2 transitively — you don't normally add those yourself. It requires PHPStan 2.0+.