Download the PHP package johnbillion/php-docs-standards without Composer
On this page you can find all versions of the php package johnbillion/php-docs-standards. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download johnbillion/php-docs-standards
More information about johnbillion/php-docs-standards
Files in johnbillion/php-docs-standards
Package php-docs-standards
Short Description PHPUnit tests for documentation standards of PHP functions and methods.
License GPL-2.0+
Informations about the package php-docs-standards
PHP Documentation Standards Tests
This abstract PHPUnit test case tests the standards and correctness of the inline documentation of your PHP functions and methods.
What's tested?
- The docblock should not be missing.
- The docblock description should not be empty.
- The number of
@param
docs should match the actual number of parameters. - The
@param
description for each parameter should not be empty. - The
@param
name for each parameter should be correct. - The
@param
type hint for each parameter should be correct. - The
@param
description for optional parameters should state that it is optional. - The
@param
description for required parameters should not state that it is optional. - The
@param
description for each parameter should state its default value, where appropriate.
Class-level docblocks are not tested.
Installation
Requirements:
- PHP 7 or 8
- PHPUnit 7 or higher
Add the package to your project's dev dependencies using Composer:
In your unit test bootstrap file, include the Composer autoloader. This will look something like this:
Usage
Add a new test class to your test suite that extends the docs standards test case. The two abstract methods that need to
be implemented are getTestFunctions()
and getTestClasses()
. These methods return an array of function names and
class names, respectively, which are to be run through the test suite to test their documentation standards.
The functions and classes must be loaded (or available for autoloading) in the current request.
Why is this a unit test instead of a sniffer?
This was originally built to help the WordPress documentation team improve the documentation standards, and at the time the fastest way for me to implement it was as a unit test. It could also be a sniffer, if someone wanted to convert it.
License: GPLv2 or later
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.