Download the PHP package niels-de-blaauw/php-doc-check without Composer
On this page you can find all versions of the php package niels-de-blaauw/php-doc-check. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download niels-de-blaauw/php-doc-check
More information about niels-de-blaauw/php-doc-check
Files in niels-de-blaauw/php-doc-check
Package php-doc-check
Short Description Command line tool that identifies code that needs documentation.
License MIT
Informations about the package php-doc-check
php-doc-check
PHP Doc Check is an automated command line tool to determine which functions and methods could use some more documentation.
By default this script:
- Emits a warning if there is no docblock for non trivial functions (score > 4)
- Emits an error if there is no docblock for complex functions (score > 6)
You can gradually improve documenation on projects by starting with relatively high limits and slowly moving these limits down.
Metrics
- Cognitive Complexity
<default>
is used to find functions that are complex to read and understand. - Cyclomatic Complexity is used to find complex functions with a more traditionl algorithm.
Installation
Composer
For now you have to install the beta version.
composer require --dev niels-de-blaauw/php-doc-check:^0.2.0@dev
Phive
phive install php-doc-check
Usage
Example first use: vendor/bin/php-doc-check --exclude vendor ./
Examples
This is fine without docblocks (trivial method)
This could use some explanation
FAQ
Q: Why dont you want if there is no comment at all, regardless of complexity?
A: You can set this software to warn for all functions that are undocumented by
setting --complexity-error-threshold 1
. However, if you want to force
documentation, you probably want to look into a tool like php CodeSniffer
in combination with documentation standards.
Q: Why isn't there a warning/error about complex functions and refactoring, regardless if they have a DocBlock?
A: You should refactor very complex functions. However, adding DocBlocks for complex function is often easier and safer. This tool only checks the availability of this type of documentation. Other tools, like php Mess Detector, can help you limit complexity.
Issues
Issues are in the GitHub tracker: https://github.com/NielsdeBlaauw/php-doc-check/issues
All versions of php-doc-check with dependencies
wp-cli/php-cli-tools Version ^0.11.11
ulrichsg/getopt-php Version ^4.0
phpdocumentor/reflection-docblock Version ^4.3|^5.0