概要
Up-to-date WordPress function and class declaration stubs for static analysis by PHPStan
Web・アプリ開発計測したスター増加
- 24時間
- 0
- 7日間
- 0
- 15日間
- 0
- 1か月
- 履歴を収集中
期間ごとの純増数です。期間は重複しており、日別の値ではありません。未計測の値は空欄です。スター数は注目度の指標であり、品質の保証ではありません。
README.md
オリジナル[!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.
関連プロジェクトを探す
読み込み中…