Static analysis for WordPress plugins and themes with PHPStan
open sourceMITfree
WordPress Extensions for PHPStan lets PHPStan analyse WordPress plugins and themes. It loads the php-stubs/wordpress-stubs package, adds dynamic return types for WordPress functions the stubs don't cover, defines some WordPress core constants, and reads the docblocks WordPress puts before apply_filters() and do_action() calls, treating the first @param as the type. It's installed with Composer as szepeviktor/phpstan-wordpress.
Problems it solves
- run PHPStan on my WordPress plugin without errors about unknown WordPress functions
- catch type errors in my WordPress theme's PHP before it ships
- get PHPStan to understand the types passed through WordPress filters
Features
- loads php-stubs/wordpress-stubs
- dynamic return types for WordPress functions the stubs don't cover
- defines some WordPress core constants
- reads apply_filters() and do_action() docblocks, treating the first @param as the type
Alternatives
The same job
These do what WordPress Extensions for PHPStan does.
