php-stubs / wordpress-stubs
WordPress function and class declaration stubs for static analysis.
Requires
None
Requires (Dev)
- php: ^7.4 || ^8.0
- dealerdirect/phpcodesniffer-composer-installer: ^1.0
- nikic/php-parser: ^5.5
- php-stubs/generator: ^0.9
- phpdocumentor/reflection-docblock: ^6.0
- phpstan/phpstan: ^2.2
- phpunit/phpunit: ^9.5
- symfony/polyfill-php80: *
- szepeviktor/phpcs-psr-12-neutron-hybrid-ruleset: ^1.2
- wp-coding-standards/wpcs: 3.4.1 as 2.3.0
Suggests
- paragonie/sodium_compat: Pure PHP implementation of libsodium
- symfony/polyfill-php80: Symfony polyfill backporting some PHP 8.0+ features to lower PHP versions
- szepeviktor/phpstan-wordpress: WordPress extensions for PHPStan
Provides
None
Conflicts
Replaces
None
- dev-master
- v7.1.2
- v7.1.0
- v7.0.1
- v7.0.0
- v6.9.4
- v6.9.3
- v6.9.2
- v6.9.1
- v6.9.0
- v6.8.3
- v6.8.2
- v6.8.1
- v6.8.0
- v6.7.4
- v6.7.3
- v6.7.2
- v6.7.1
- v6.7.0
- v6.6.4
- v6.6.3
- v6.6.2
- v6.6.1
- v6.6.0
- v6.5.7
- v6.5.6
- v6.5.5
- v6.5.4
- v6.5.3
- v6.5.2
- v6.5.0
- 6.4.x-dev
- v6.4.7
- v6.4.6
- v6.4.5
- v6.4.4
- v6.4.3
- v6.4.2
- v6.4.1
- v6.4.0
- v6.3.7
- v6.3.6
- v6.3.5
- v6.3.4
- v6.3.3
- v6.3.2
- v6.3.1
- v6.3.0
- v6.2.8
- v6.2.7
- v6.2.6
- v6.2.5
- v6.2.4
- v6.2.3
- v6.2.2
- v6.2.1
- v6.2.0
- v6.1.9
- v6.1.8
- v6.1.7
- v6.1.6
- v6.1.5
- v6.1.4
- v6.1.3
- v6.1.2
- v6.1.1
- v6.1.0
- v6.0.11
- v6.0.10
- v6.0.9
- v6.0.8
- v6.0.7
- v6.0.6
- v6.0.5
- v6.0.4
- v6.0.3
- v6.0.2
- v6.0.1
- v6.0.0
- v5.9.9
- v5.9.8
- v5.9.7
- v5.9.6
- v5.9.5
- v5.9.4
- v5.9.3
- v5.9.2
- v5.9.1
- v5.9.0
- v5.8.9
- v5.8.8
- v5.8.7
- v5.8.6
- v5.8.5
- v5.8.4
- v5.8.3
- v5.8.2
- v5.8.1
- v5.8.0
- v5.7.11
- v5.7.10
- v5.7.9
- v5.7.8
- v5.7.7
- v5.7.6
- v5.7.5
- v5.7.4
- v5.7.3
- v5.7.2
- v5.7.1
- v5.7.0
- v5.6.13
- v5.6.12
- v5.6.11
- v5.6.10
- v5.6.9
- v5.6.8
- v5.6.7
- v5.6.6
- v5.6.5
- v5.6.4
- v5.6.3
- v5.6.2
- v5.6.1
- v5.6.0
- v5.5.14
- v5.5.13
- v5.5.12
- v5.5.11
- v5.5.10
- v5.5.9
- v5.5.8
- v5.5.7
- v5.5.6
- v5.5.5
- v5.5.4
- v5.5.3
- v5.5.2
- v5.5.1
- v5.5.0
- v5.4.15
- v5.4.14
- v5.4.13
- v5.4.12
- v5.4.11
- v5.4.10
- v5.4.9
- v5.4.8
- v5.4.7
- v5.4.6
- v5.4.5
- v5.4.4
- v5.4.3
- v5.4.2
- v5.4.1
- v5.4.0
- v5.3.17
- v5.3.16
- v5.3.15
- v5.3.14
- v5.3.13
- v5.3.12
- v5.3.11
- v5.3.10
- v5.3.9
- v5.3.8
- v5.3.7
- v5.3.6
- v5.3.5
- v5.3.4
- v5.3.3
- v5.3.2
- v5.3.1
- v5.3.0
- v5.2.20
- v5.2.19
- v5.2.18
- v5.2.17
- v5.2.16
- v5.2.15
- v5.2.14
- v5.2.13
- v5.2.12
- v5.2.11
- v5.2.10
- v5.2.9
- v5.2.8
- v5.2.7
- v5.2.6
- v5.2.5
- v5.2.4
- v5.2.3
- v5.2.2
- v5.2.1
- v5.2
- v5.1.18
- v5.1.17
- v5.1.16
- v5.1.15
- v5.1.14
- v5.1.13
- v5.1.12
- v5.1.11
- v5.1.10
- v5.1.9
- v5.1.8
- v5.1.7
- v5.1.6
- v5.1.5
- v5.1.4
- v5.1.3
- v5.1.2
- v5.1.1
- v5.1
- v5.0.21
- v5.0.20
- v5.0.19
- v5.0.18
- v5.0.17
- v5.0.16
- v5.0.15
- v5.0.14
- v5.0.13
- v5.0.12
- v5.0.11
- v5.0.10
- v5.0.9
- v5.0.8
- v5.0.7
- v5.0.6
- v5.0.4
- v5.0.2
- v5.0.1
- v5.0
- v4.9.20
- v4.9.19
- v4.9.18
- v4.9.17
- v4.9.16
- v4.9.15
- v4.9.14
- v4.9.13
- v4.9.12
- v4.9.11
- v4.8.19
- v4.8.18
- v4.8.17
- v4.8.16
- v4.8.15
- v4.8.14
- v4.8.13
- v4.8.12
- v4.8.11
- v4.8.10
- v4.7.23
- v4.7.22
- v4.7.21
- v4.7.20
- v4.7.19
- v4.7.18
- v4.7.17
- v4.7.16
- v4.7.15
- v4.7.14
- dev-szepeviktor-patch-3
- dev-szepeviktor-patch-1
This package is auto-updated.
Last update: 2026-11-28 15:28:31 UTC
README
Important
Need help?
I build and maintain reliable web applications, with a focus on PHP, WordPress, and software quality.
If this package helps your team, feel free to reach out for consulting, development work, or sponsorship.
WordPress Stubs
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.
Requirements
- PHP 7.4 or 8.0
Installation
Require this package as a development dependency with Composer.
composer require --dev php-stubs/wordpress-stubs
Alternatively you may download wordpress-stubs.php directly.
Usage with PHPStan
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.
Usage with Psalm
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>.
Usage in Intellisense
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.
Versioning
This package is versioned to match the WordPress version from which the stubs are generated.
Generating stubs for a different WordPress version
- Run modern PHP version
- Clone this repository and
cdinto it - Update
"johnpbloch/wordpress": "x.x.x"insource/composer.jsonwith the desired version - Run
composer update - And run
./generate.sh
The wordpress-stubs.php file should now be updated.
Reviewing PHPStan annotation overrides
Stub generation logs each overridden annotation as three lines: the symbol name,
the original Core: tag, and the replacement Map: tag. The symbol line also
includes [similarity: N, recommendation: delete|review]. Capture STDERR during
generation, then analyze that log without regenerating stubs:
./generate.sh 2> overrides.log php8.5 recommend-phpstan-tags.php overrides.log > recommendations.json
Each JSON record contains symbol, core, map, similarity, recommendation,
and difference. A similarity of 10 means the parsed annotations are identical
after ignoring descriptions, formatting, global namespace prefixes, and union or
intersection member order. Only these records receive a delete recommendation.
Scores 0–9 estimate structural overlap and always require review. They are not probabilities, subtype checks, or proof that removing a map entry is safe. The report shows up to five differing features on each side. Templates include their name, variance, bound, and default in the identity check. Invalid annotations receive a score of 0 and require manual review.
The command only reads the log; it does not modify the map or run generation. After accepting recommendations, regenerate once and run the full test suite.