Stars: 118
Forks: 14
Pull Requests: 57
Issues: 45
Watchers: 7
Last Updated: 2023-08-10 16:41:41
Up-to-date WordPress function and class declaration stubs for static analysis by PHPStan
License: MIT License
Languages: PHP, Shell
It provides stub declarations for WordPress core functions, classes and interfaces, globals are not included. These stubs can help plugin and theme developers leverage static analysis tools like PHPStan.
The stubs are generated from @johnpbloch's package using php-stubs/generator.
Require this package as a development dependency with Composer.
composer require --dev php-stubs/wordpress-stubs
Alternatively you may download wordpress-stubs.php
directly.
composer require --dev szepeviktor/phpstan-wordpress
The package szepeviktor/phpstan-wordpress
depends on phpstan/phpstan
and this one.
Please do read
that package's README
and see the example
directory over there.
Update your Psalm config to include this section.
<stubs>
<file name="vendor/php-stubs/wordpress-stubs/wordpress-stubs.php" />
</stubs>
Furthermore ensure WordPress core is not included in <projectFiles>
.
If your IDE has trouble parsing all of WordPress you may find the stubs useful for enabling code completion and related features. For example there are instructions for usage with VSCode's Intelephense extension.
This package is versioned to match the WordPress version from which the stubs are generated.
cd
into it"johnpbloch/wordpress": "x.x.x"
in source/composer.json
with the desired versioncomposer update
./generate.sh
The wordpress-stubs.php
file should now be updated.