inpsyde/wp-stubs
Composer 安装命令:
composer create-project inpsyde/wp-stubs
包简介
WordPress Stubs
README 文档
README
This repo contains auto-generated WordPress stubs to be used with static analysis tools.
FAQ
- Why this instead of "< insert exiting project here >"?
This project's purpose is:
- having multiple versions of WP in the same branch/version
- not having stubs for globals, but having stubs for constants
- having a super-simple "override" method. By declaring stubs in the
fixtures.phpfile, it is possible to override the WordPress declaration for functions, classes, and interfaces. That way, it is easy to fix incorrect DocBlocks in WordPress and use "advanced" doc block supported by static analyzers (think of array shape, type aliases, conditional return types …)
How this works
Every day, a GitHub Actions workflow calls the wp.org API to find new WordPress versions.
If it finds new versions, it generates and saves stubs for them (using https://github.com/php-stubs/generator) while also updating the "latest" stub.
How to use
The primary usage is for static analysis tools, for example, Psalm:
Method 1: Get all WordPress versions
Steps:
- Require this project (
inpsyde/wp-stubs) in your Composer's"require-dev"property - Create a
psalm.xmlconfig file (see docs) - In the Psalm configuration, add these lines:
<stubs> <file name="vendor/inpsyde/wp-stubs/stubs/latest.php"/> </stubs>
You can replace latest.php with a specific WP version. See the available versions in the /stubs directory.
Note: In that folder, a two-digit version number like 5.9 does not necessarily mean WordPress version 5.9, but the latest in the 5.9.* series. So if you use Composer to require WordPress and have a requirement like 5.9.*, using the stubs/5.9.php stubs file will match the currently installed version.
The "stubs" folder contains stubs of many versions so that you can choose, but it would also be possible to have a CI script that loads different versions to test against different stubs.
However, the package size might get huge, and if not excluded from IDE's analysis, it might affect the IDE performance.
Method 2: Get a specific version
Pre-requisite:
In your composer.json, declare a repository like this:
{ "repositories": [ { "type": "composer", "url": "https://raw.githubusercontent.com/inpsyde/wp-stubs/main", "only": [ "inpsyde/wp-stubs-versions" ] } ] } Note for Inpsyde developers: The Inpsyde organization in Private Packagist mirrors the above repository, so for Inpsyde's private repositories, this is likely not needed considering Private Packagist will probably be already added to the repo's
composer.json.
Steps:
- Require the "versioned" project in your Composer's
"require-dev"property e.g.{ "require": { "inpsyde/wp-stubs-versions": "dev-latest" } }. (Note how the package name has-versionsappended) - Create a
psalm.xmlconfig file ( see docs) - In the Psalm configuration, add these lines:
<stubs> <file name="vendor/inpsyde/wp-stubs-versions/latest.php"/> </stubs>
Using this approach, the latest version will be the only version Composer downloads.
Minimum requirements
The code that generates the stubs requires PHP 8.0+. However, when consuming the package, there are no minimum requirements besides being able to run WordPress.
Copyright and License
Good news, this library is free for everyone! Since it's released under the MIT License you can use it free of charge on your personal or commercial website.
inpsyde/wp-stubs 适用场景与选型建议
inpsyde/wp-stubs 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 61.62k 次下载、GitHub Stars 达 22, 最近一次更新时间为 2026 年 01 月 04 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 inpsyde/wp-stubs 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 inpsyde/wp-stubs 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 61.62k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 22
- 点击次数: 14
- 依赖项目数: 5
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2026-01-04