php-stubs/wp-cli-stubs

用于静态分析的WP-CLI函数和类声明存根。

v2.10.0 2024-02-09 02:10 UTC

This package is auto-updated.

Last update: 2024-08-30 02:50:43 UTC


README

Build Status

此软件包为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