php-stubs/wordpress-stubs
WordPress core stubs for static analysis and IDE autocompletion (functions, classes, interfaces; no globals). Generated from johnpbloch/wordpress-core. Works with PHPStan (via phpstan-wordpress) and Psalm stubs config. Requires PHP 7.4/8.0.
get_post(), wp_insert_post()). The stubs do not conflict with Laravel’s autoloading or service providers.composer require --dev php-stubs/wordpress-stubs), requiring no codebase changes.szepeviktor/phpstan-wordpress already depends on it).$wpdb, $post). Risk:
$wpdb as a service) to avoid globals.v7.0.0 for WP 6.9).$wp_query)? If yes, evaluate custom stubs or refactoring.johnpbloch/wordpress-core?)wp_insert_post()).szepeviktor/phpstan-wordpress for WordPress-specific rules.<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>
- name: Run PHPStan
run: vendor/bin/phpstan analyse --level=5
v7.0.0 for WP 6.9). Ensure your target WordPress version has matching stubs.get_post()).php-stubs/generator.vendor/ if needed (not recommended for shared projects).WP_Error vs. false return types). Mitigate with:
@phpstan-ignore-next-line for known edge cases.vendor/bin/phpstan analyse --memory-limit=512M.wp_insert_post() return types).--autoload-file for Laravel’s PSR-4 paths).| Risk | Impact | Mitigation |
|---|---|---|
| Maintainer abandonment | Stubs become outdated | Fork the repo; contribute fixes. |
| WordPress version mismatch | False positives/errors | Pin stubs to WordPress version in composer.json. |
How can I help you explore Laravel packages today?