onepix/wordpress-stubs 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

onepix/wordpress-stubs

最新稳定版本:v6.8.1

Composer 安装命令:

composer require --dev onepix/wordpress-stubs

包简介

WordPress function and class declaration stubs for static analysis.

README 文档

README

It provides stub declarations for WordPress core functions, classes, interfaces, globals, hooks. These stubs can help plugin and theme developers leverage static analysis tools like PHPStan.

The stubs are generated from @johnpbloch's package using onepix/wordpress-stubs-generator.

Requirements

  • PHP 8.1+

Installation

Require this package as a development dependency with Composer.

composer require --dev onepix/wordpress-stubs

Alternatively you may download wordpress-stubs.phpstub directly.

Usage with PHPStan

composer require --dev szepeviktor/phpstan-wordpress

The package szepeviktor/phpstan-wordpress depends on phpstan/phpstan and this one. Please do read that package's README and see the example directory over there.

Usage with Psalm

Update your Psalm config to include this section.

<stubs>
    <file name="vendor/onepix/wordpress-stubs/wordpress-stubs.phpstub" />
</stubs>
<hooks>
    <directory name="vendor/onepix/wordpress-stubs/hooks" recursive="true"/>
</hooks>

Furthermore ensure WordPress core is not included in <projectFiles>.

Usage in Intellisense

If your IDE has trouble parsing all of WordPress you may find the stubs useful for enabling code completion and related features. For example there are instructions for usage with VSCode's Intelephense extension.

Versioning

This package is versioned to match the WordPress version from which the stubs are generated.

Generating stubs for a different WordPress version

  1. Run modern PHP version
  2. Clone this repository and cd into it
  3. Update "johnpbloch/wordpress": "x.x.x" in source/composer.json with the desired version
  4. Run composer update
  5. And run ./generate.sh

The wordpress-stubs.phpstub file should now be updated.

统计信息

  • 总下载量: 784
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 6
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 22
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-12-29