noximo / phpstan-fileoutput
PHPStan 的错误格式化工具,将分析结果导出到 HTML 文件中
0.1.9
2021-11-29 13:53 UTC
Requires
- php: ^7.3
- nette/neon: ^3.1.0
- nette/utils: ^3.1.0
- phpstan/phpstan: >=0.12.7 <=1.2.0
- thecodingmachine/safe: ^1.0.3
- webmozart/path-util: ^2.3.0
README
将PHPStan 的分析结果导出到 HTML 文件中的错误格式化工具
安装
composer require noximo/phpstan-fileoutput
使用方法
编辑或创建您的 phpstan.neon 文件,并注册新的错误格式化工具。前两个参数是必填的。
-
第一个参数指定输出数据的文件路径。
-
第二个参数指定将使用哪个其他格式化工具与 FileOutput 格式化工具一起运行。如果您只想使用 FileOutput 生成的文件,可以将其设置为 null。
services:
errorFormatter.fileoutput: # Can be any name after errorFormatter
class: noximo\FileOutput(./example/phpstan.html, null)
您还可以(并且应该)指定第二个参数来使用其他格式化工具之一,这样控制台输出就不会受到影响。
class: noximo\FileOutput(./example/phpstan.html, @errorFormatter.raw)
在本README编写时,这些格式化工具默认在PHPStan中可用
errorFormatter.checkstyle
,errorFormatter.json
,errorFormatter.prettyJson
,errorFormatter.raw
,errorFormatter.table
查看 PHPStan 仓库 以获取可能的更新。
第三个参数设置自定义输出模板。
class: noximo\FileOutput(./example/phpstan.html, null, ./tests/alternative_table.phtml)
有关实现细节和数据结构,请参阅 table.phtml。
输出
FileOutputer 将生成包含直接链接到出错 PHP 文件的 HTML 文件(假设默认模板)。如果您想利用可点击的链接,请根据以下文章设置您的环境:https://tracy.nette.org/en/open-files-in-ide
注意:当您修复错误时,文件结构和行号可能不再与分析时的行号相对应。您需要重新运行 PHPStan 以重新生成输出文件。错误按行号降序输出,因此您不太可能丢失行。