analyse-with-phpstan by phpstan/phpstan
npx skills add https://github.com/phpstan/phpstan --skill analyse-with-phpstan使用位于 https://api.phpstan.org/analyse 的 PHPStan 游乐场 API 分析 PHP 代码。此操作将在 PHP 7.2 至 8.5 版本上运行 PHPStan,并返回每个版本的错误信息。
待分析的代码:$ARGUMENTS
获取要分析的 PHP 代码。如果 $ARGUMENTS 是一个文件路径,则读取文件内容。代码必须以 <?php 开头。
除非用户另有指定,否则使用以下默认值:
"10" (最严格)falsefalse广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
true如果用户要求使用严格规则或前沿功能,则将相应项设置为 true。
通过 POST 提交代码:
curl -s -X POST 'https://api.phpstan.org/analyse' \
-H 'Content-Type: application/json' \
-d '{
"code": "<PHP code, JSON-escaped>",
"level": "<level>",
"strictRules": <true|false>,
"bleedingEdge": <true|false>,
"treatPhpDocTypesAsCertain": <true|false>,
"saveResult": true
}'
代码值必须经过正确的 JSON 转义(转义引号、反斜杠、换行符)。
响应 JSON 包含:
versionedErrors — 对象数组,每个 PHP 版本一个对象,每个对象包含:
phpVersion — 整数编码:例如 80400 = PHP 8.4,70400 = PHP 7.4errors — 错误对象数组,包含 message、line、identifier、tip(可选)、ignorableid — 已保存结果的 UUID将 phpVersion 整数转换为可读字符串:Math.floor(v / 10000) . Math.floor((v % 10000) / 100)。
按以下格式输出结果:
https://phpstan.org/r/<id>
级别: <level> | 严格规则: 是/否 | 前沿功能: 是/否
将具有相同错误(相同的消息、行号和标识符)的连续 PHP 版本分组到范围中。例如,如果 PHP 7.2–8.3 都报告相同的错误,则将它们显示为一个组。
如果所有 PHP 版本报告的错误都相同,则显示一个组:
所有 PHP 版本(无差异):
| 行号 | 错误 | 标识符 |
|---|---|---|
| 10 | Parameter #1 $foo expects string, int given. | argument.type |
如果不同版本之间的错误有差异,则显示单独的组:
PHP 8.0 – 8.5:
| 行号 | 错误 | 标识符 |
|---|---|---|
| 10 | Parameter #1 $foo expects string, int given. | argument.type |
PHP 7.2 – 7.4:
无错误。
如果任何 PHP 版本都没有错误,则说明:在任何 PHP 版本上均未发现错误。
每周安装量
76
代码仓库
GitHub 星标数
13.9K
首次出现
2026年2月24日
安全审计
安装于
opencode67
cursor66
kimi-cli65
gemini-cli65
amp65
github-copilot65
Analyse PHP code using the PHPStan playground API at https://api.phpstan.org/analyse. This runs PHPStan across PHP versions 7.2–8.5 and returns errors for each version.
The code to analyse: $ARGUMENTS
Get the PHP code to analyse. If $ARGUMENTS is a file path, read the file contents. The code must start with <?php.
Unless the user specified otherwise, use these defaults:
"10" (strictest)falsefalsetrueIf the user asked for strict rules or bleeding edge, set those to true.
Submit the code via POST:
curl -s -X POST 'https://api.phpstan.org/analyse' \
-H 'Content-Type: application/json' \
-d '{
"code": "<PHP code, JSON-escaped>",
"level": "<level>",
"strictRules": <true|false>,
"bleedingEdge": <true|false>,
"treatPhpDocTypesAsCertain": <true|false>,
"saveResult": true
}'
The code value must be properly JSON-escaped (escape quotes, backslashes, newlines).
The response JSON contains:
versionedErrors — array of objects, one per PHP version, each with:
phpVersion — integer encoding: e.g. 80400 = PHP 8.4, 70400 = PHP 7.4errors — array of error objects with message, line, identifier, tip (optional), ignorableid — UUID for the saved resultConvert phpVersion integers to readable strings: Math.floor(v / 10000) . Math.floor((v % 10000) / 100).
Output the results in this format:
https://phpstan.org/r/<id>
Level: <level> | Strict rules: yes/no | Bleeding edge: yes/no
Group consecutive PHP versions that have identical errors (same messages, lines, and identifiers) into ranges. For example, if PHP 7.2–8.3 all report the same errors, show them as one group.
If all PHP versions report identical errors, show a single group:
All PHP versions (no differences):
| Line | Error | Identifier |
|---|---|---|
| 10 | Parameter #1 $foo expects string, int given. | argument.type |
If errors differ across versions, show separate groups:
PHP 8.0 – 8.5:
| Line | Error | Identifier |
|---|---|---|
| 10 | Parameter #1 $foo expects string, int given. | argument.type |
PHP 7.2 – 7.4:
No errors.
If there are no errors on any PHP version, say: No errors found on any PHP version.
Weekly Installs
76
Repository
GitHub Stars
13.9K
First Seen
Feb 24, 2026
Security Audits
Gen Agent Trust HubPassSocketWarnSnykFail
Installed on
opencode67
cursor66
kimi-cli65
gemini-cli65
amp65
github-copilot65
Laravel安全最佳实践指南 | 防范CSRF、SQL注入、XSS攻击
1,200 周安装