php-stubs/wp-cli-stubs
PHP stub definitions for WP-CLI, providing classes, functions, and constants for IDE autocompletion and static analysis. Helps PHPStan, Psalm, and editors understand WP-CLI APIs without running the command-line tool.
WP_CLI:: static calls, WP_CLI\Utils\* helpers, and WP-CLI command classes without loading WP-CLI at analysis time. That directly supports the decision "do we raise our PHPStan level and enforce it in CI for our WP-CLI surface?" — the answer becomes yes far more cheaply than writing or hand-maintaining declarations.php-stubs/generator) or running analysis against the full wp-cli/wp-cli-bundle in vendor/. This package is the "buy" (adopt) option: a tiny, MIT-licensed, declaration-only dev dependency that removes an internal maintenance task from the roadmap.require-dev, it can be evaluated as a pure DX/CI decision with no production runtime, attack-surface, or autoload-footprint impact — decoupled from release risk.Adopt when:
WP_CLI::add_command, WP_CLI::success/error/log, WP_CLI\Utils\get_flag_value, WP_CLI::confirm, etc.) and want them type-checked.WP_CLI::* with near-zero setup.php-stubs/wordpress-stubs and pin stub versions in lockstep with the WP-CLI version your CI runners use.Look elsewhere or de-scope when:
composer.json.php-stubs/generator as a documented fallback.For executives (30 seconds): This is a free, MIT-licensed, development-only package that adds type information for WP-CLI — the command-line tool our teams use for deploys, migrations, and data operations. Adding it means our static-analysis and CI checks can actually validate that code, catching bugs before they reach production. Cost: one line in composer.json, no runtime dependency, no production risk. The tradeoff is maintenance concentration in a small open-source project, which we contain by pinning a version and keeping an internal fallback to generate stubs ourselves — roughly an hour of work if the project stalls.
For engineering: Add php-stubs/wp-cli-stubs to require-dev and register its path in phpstan.neon/Psalm config. It supplies declaration-only stubs for WP_CLI and the WP_CLI\Utils helpers, so PHPStan can resolve static calls without booting WP-CLI or scanning wp-cli/wp-cli-bundle in vendor/ — faster analysis, fewer ignoredErrors entries, and real signatures in the IDE. Pair it with php-stubs/wordpress-stubs, pin both versions in composer.lock, and align the stub version with the WP-CLI version on our runners. Known caveat: the project is small (~30 stars, no dependents), so treat the stub version as a tracked dependency and document the php-stubs/generator fallback. Success metric: PHPStan level increases on WP-CLI-touching packages with no growth in baseline suppressions.
How can I help you explore Laravel packages today?