php-stubs / wp-cli-stubs
WP-CLI function and class declaration stubs for static analysis.
Installs: 888 630
Dependents: 42
Suggesters: 0
Security: 0
Stars: 23
Watchers: 4
Forks: 2
Open Issues: 3
Requires
- php-stubs/wordpress-stubs: ^4.7 || ^5.0 || ^6.0
Requires (Dev)
- php: ~7.3 || ~8.0
- php-stubs/generator: ^0.8.0
Suggests
- symfony/polyfill-php73: Symfony polyfill backporting some PHP 7.3+ features to lower PHP versions
- szepeviktor/phpstan-wordpress: WordPress extensions for PHPStan
README
This package provides stub declarations for WP-CLI functions, classes and interfaces. These stubs can help plugin and theme developers leverage static analysis tools like PHPStan, which are unable to parse WP-CLI as it is not clean OOP code.
Stubs are generated directly from the source using giacocorsiglia/stubs-generator.
Requirements
- PHP >=7.1
Installation
Require this package as a development dependency with Composer.
composer require --dev php-stubs/wp-cli-stubs
Alternatively you may download wp-cli-stubs.php
directly.
Usage in PHPStan
Include all stubs in PHPStan configuration file.
parameters: scanFiles: - %rootDir%/../../php-stubs/wordpress-stubs/wordpress-stubs.php - %rootDir%/../../php-stubs/wp-cli-stubs/wp-cli-stubs.php - %rootDir%/../../php-stubs/wp-cli-stubs/wp-cli-commands-stubs.php - %rootDir%/../../php-stubs/wp-cli-stubs/wp-cli-i18n-stubs.php - %rootDir%/../../php-stubs/wp-cli-stubs/wp-cli-tools.php