php-stubs/wordpress-stubs
Stub declarations for WordPress core functions, classes, and interfaces (globals excluded), generated from johnpbloch's wordpress-core via php-stubs/generator. Helps plugin and theme developers leverage static analysis tools like PHPStan and Psalm, and improves IDE code completion and intellisense.
get_post(), wp_insert_post()). The stubs do not conflict with Laravel’s autoloading or service providers.paginate_links and absint, removal of duplicated tags/shape keys, and corrections for sealed arrays). These improvements increase static‑analysis precision but may surface new type errors in existing code.composer require --dev php-stubs/wordpress-stubs), requiring no codebase changes.v7.1.2) aligns with WordPress 7.1.2. Ensure your target WordPress version matches; if you are on an older WordPress version, you may need to pin an earlier stub release or accept potential false positives for newer functions.IanDelMar and PeterSmith8nss). The previous assessment noted an abandonment signal; that risk is significantly reduced but not eliminated. Continue to monitor release cadence and consider a fork as a contingency.$wpdb, $post). If your Laravel plugin relies on globals, you’ll need custom stubs or refactoring (e.g., dependency injection for $wpdb).$wp_query)? If yes, evaluate custom stubs or refactoring.paginate_links, absint, and sealed arrays).szepeviktor/phpstan-wordpress.<stubs> in psalm.xml to include wordpress-stubs.php.composer require --dev phpstan/phpstan php-stubs/wordpress-stubs
vendor/bin/phpstan analyse --level=5 src/
szepeviktor/phpstan-wordpress.psalm.xml:
<stubs>
<file name="vendor/php-stubs/wordpress-stubs/wordpress-stubs.php" />
</stubs>
composer update php-stubs/wordpress-stubs.- name: Run PHPStan
run: vendor/bin/phpstan analyse --level=5
paginate_links conditional return, absint conditional return). These are static‑analysis‑only changes and do not affect runtime, but they may require code adjustments to satisfy stricter type checks.php-stubs/generator. Avoid overriding vendor stubs directly.@phpstan-ignore-next-line for known edge cases or update code to match accurate types.--memory-limit=512M. CI/CD impact is minimal if cached.wp_insert_post() return types). Emphasize static analysis as a safety net.| Risk | Impact | Mitigation |
|---|---|---|
| Maintainer abandonment | Stubs become outdated | Fork the repo; contribute fixes. (Risk reduced by active maintenance.) |
| WordPress version mismatch | False positives/errors | Pin stubs to WordPress version in composer.json. |
| New type errors after upgrade | CI failures, developer friction | Re‑baseline static analysis after upgrading; suppress known false positives. |
| IDE ignoring stubs | Reduced autocompletion accuracy | Pre‑test IDE configuration; rely on PHPStan/Psalm for critical checks. |
How can I help you explore Laravel packages today?