voku / phpdoctor
检查缺失或错误的phpdoc注释。
0.6.5
2022-10-31 11:55 UTC
Requires
- php: >=7.2
- symfony/console: ~3.4 || ~4.1 || ~5.0 || ~6.0
- voku/simple-php-code-parser: ~0.19.0
Requires (Dev)
- phpunit/phpunit: ~6.0 || ~7.0 || ~9.0
This package is auto-updated.
Last update: 2024-08-31 00:35:43 UTC
README
🏥 PHPDoctor
检查PHP文件或目录中缺失的类型。
如果你已经使用 PHPStan 进行类型检查,但团队中有时仍有成员提交未类型化的代码,那么PHPDoctor就是为你准备的。
通过"phar"安装(推荐)
https://github.com/voku/PHPDoctor/releases
通过"composer require"安装
composer require-dev voku/phpdoctor
快速入门
Usage:
analyse [options] [--] <path...>
Arguments:
path The path to analyse
Options:
--autoload-file[=AUTOLOAD-FILE] The path to your autoloader. [default: ""]
--access[=ACCESS] Check for "public|protected|private" methods. [default: "public|protected|private"]
--skip-ambiguous-types-as-error[=SKIP-AMBIGUOUS-TYPES-AS-ERROR] Skip check for ambiguous types. (false or true) [default: "false"]
--skip-deprecated-functions[=SKIP-DEPRECATED-FUNCTIONS] Skip check for deprecated functions / methods. (false or true) [default: "false"]
--skip-functions-with-leading-underscore[=SKIP-FUNCTIONS-WITH-LEADING-UNDERSCORE] Skip check for functions / methods with leading underscore. (false or true) [default: "false"]
--skip-parse-errors[=SKIP-PARSE-ERRORS] Skip parse errors in the output. (false or true) [default: "true"]
--path-exclude-regex[=PATH-EXCLUDE-REGEX] Skip some paths via regex e.g. "#/vendor/|/other/.*/path/#i" [default: "#/vendor/|/tests/#i"]
演示
解析字符串
$code = ' <?php declare(strict_types = 1); class HelloWorld { /** * @param mixed $date */ public function sayHello($date): void { echo \'Hello, \' . $date->format(\'j. n. Y\'); } }'; $phpdocErrors = PhpCodeChecker::checkFromString($code); // [8]: missing parameter type for HelloWorld->sayHello() | parameter:date']
忽略错误
你可以在@param或@return phpdocs中使用<phpdoctor-ignore-this-line/>
来忽略代码中的错误。
/** * @param mixed $lall <p>this is mixed but it is ok, because ...</p> <phpdoctor-ignore-this-line/> * * @return array <phpdoctor-ignore-this-line/> */ function foo_ignore($lall) { return $lall; }
构建PHAR文件
准备: https://github.com/phar-io/phive
phive install humbug/box php tools/box compile --debug
支持
有关支持和捐赠,请访问 Github | 问题 | PayPal | Patreon。
有关状态更新和发布公告,请访问 发布 | Twitter | Patreon。
有关专业支持,请联系 我。