odan/docblock-checker

此包已被弃用,不再维护。作者建议使用https://github.com/squizlabs/PHP_CodeSniffer包代替。

一个用于检查您的PHP类和方法是否使用docblocks的简单工具。

1.3.0 2019-04-14 12:51 UTC

This package is auto-updated.

Last update: 2020-05-09 22:08:21 UTC


README

检查目录中的PHP文件是否正确使用了DocBlocks

Latest Version on Packagist Build Status Code Coverage Scrutinizer Code Quality Total Downloads

安装

Composer:

composer require odan/docblock-checker --dev

功能

  • 检查参数和返回类型
  • 支持7.1的null类型
  • 排除模式
  • 能够检查单个文件
  • JSON输出(可选)

用法

Linux

$ vendor/bin/docblock-checker {params}

Windows

> vendor\bin\docblock-checker {params}

参数

快捷键 名称 描述
-h --help 显示帮助信息。
-d --directory=DIRECTORY 要扫描的目录。[默认: "./"]
-f --file=filename 要扫描的单个文件。
-x --exclude=EXCLUDE 要排除的文件和目录。您可以使用排除模式,例如tests/*
none --skip-classes 不要检查类上的docblocks。
none --skip-methods 不要检查方法上的docblocks。
none --skip-signatures 不要将docblocks与方法签名进行比对。
none --format=json json = 输出JSON而不是日志。
-l --files-per-line=FILES-PER-LINE 每行中的文件数。[默认: 50]
-w --fail-on-warnings 如果有任何警告产生,则认为检查失败。
-i --info-only 信息模式,只显示摘要。
-q --quiet 不输出任何信息。
-V --version 显示此应用程序的版本。
none --ansi 强制ANSI输出。
none --no-ansi 禁用ANSI输出。
-n --no-interaction 不提出任何交互式问题。
-v -vv -vvv --verbose 增加消息的详细程度:1为正常输出,2为更详细输出,3为调试。

类似库

您可以使用squizlabs/php_codesniffer以及以下嗅探规则实现相同的效果

<rule ref="Squiz.Commenting.ClassComment">
    <type>warning</type>
</rule>
<rule ref="Squiz.Commenting.ClassComment.TagNotAllowed">
    <type>warning</type>
    <exclude-pattern>*/tests/</exclude-pattern>
</rule>
<rule ref="Squiz.Commenting.ClassComment.Missing">
    <type>warning</type>
</rule>
<rule ref="Squiz.Commenting.FunctionComment.Missing">
    <type>warning</type>
</rule>
<rule ref="Squiz.Commenting.FunctionComment.MissingParamTag">
    <type>warning</type>
</rule>
<rule ref="Squiz.Commenting.FunctionComment.MissingParamComment">
    <type>warning</type>
</rule>
<rule ref="Squiz.Commenting.FunctionComment.ParamCommentNotCapital">
    <type>warning</type>
</rule>

致谢

此库是从block8/php-docblock-checker派生的。

感谢

  • @Block8
  • @dancryer