Stub declarations of WooCommerce extensions: their functions, classes, interfaces and constants, without implementations. They let you run static analysis tools like PHPStan on code that integrates with these extensions, without installing them.
The stubs are generated from each extension's release using php-stubs/generator, and published automatically for every new release. This repository is generated, so pull requests are not accepted; please open an issue instead.
Require this package as a development dependency with Composer, next to php-stubs/woocommerce-stubs:
composer require --dev woocommerce/php-stubs:dev-trunk php-stubs/woocommerce-stubsInclude the extensions you integrate with in your PHPStan configuration file:
includes:
# The newest release of an extension.
- vendor/woocommerce/php-stubs/stubs/woocommerce-subscriptions/latest.neon
# Or a specific release, e.g. the minimum version you support.
- vendor/woocommerce/php-stubs/stubs/woocommerce-bookings/3.10.0.neon
# WooCommerce internals that php-stubs/woocommerce-stubs leaves out, for your installed version.
- vendor/woocommerce/php-stubs/supplements/woocommerce-internal.phpEach extension has a directory in stubs/, with a <version>.neon for the first release of
each of its newest 10 minor versions, and for its newest release. Pin your minimum to the first
release of a minor version.
The stubs are plain PHP, so Phan, Psalm and IDEs can read them too. Load the files that a release's
<version>.neon lists under scanFiles: its stub (<version>.overridden.php, with corrected
docblocks, when one exists) and any shared framework stub it needs. latest.neon names the newest
release.
To have the stubs of your WooCommerce Marketplace extension published here, add this line to the header of your main plugin file in your next release:
* Woo Stubs: publicReleasing a version without the line removes your extension from this repository again; what was already published stays in its history.
GPL-3.0-or-later, like the extensions the stubs are generated from.