php-stubs / wp-cli-stubs
用于静态分析的WP-CLI函数和类声明存根。
v2.10.0
2024-02-09 02:10 UTC
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
此软件包为WP-CLI的函数、类和接口提供存根声明。这些存根可以帮助插件和主题开发者利用静态分析工具,如PHPStan,因为WP-CLI不是整洁的OOP代码,所以这些工具无法解析它。
存根直接使用giacocorsiglia/stubs-generator从源代码生成。
需求
- PHP >=7.1
安装
使用Composer将此软件包作为开发依赖项要求。
composer require --dev php-stubs/wp-cli-stubs
或者您可以直接下载wp-cli-stubs.php
。
在PHPStan中的使用
在PHPStan配置文件中包含所有存根。
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