2017 © Pedro Peláez
 

library php-docs-standards

PHPUnit tests for documentation standards of PHP functions and methods.

image

johnbillion/php-docs-standards

PHPUnit tests for documentation standards of PHP functions and methods.

  • PHP
  • 2 Dependents
  • 0 Suggesters
  • 3 Forks
  • 4 Open issues
  • 10 Versions
  • 7 % Grown

The README.md

License Build Status, (*1)

PHP Documentation Standards Tests

This abstract PHPUnit test case tests the standards and correctness of the inline documentation of your PHP functions and methods., (*2)

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., (*3)

Installation

Requirements:, (*4)

  • PHP 7 or 8
  • PHPUnit 7 or higher

Add the package to your project's dev dependencies using Composer:, (*5)

composer require johnbillion/php-docs-standards --dev

In your unit test bootstrap file, include the Composer autoloader. This will look something like this:, (*6)

require dirname( dirname( __DIR__ ) ) . '/vendor/autoload.php';

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., (*7)

The functions and classes must be loaded (or available for autoloading) in the current request., (*8)

<?php

class TestMyDocsStandards extends \Johnbillion\DocsStandards\TestCase {

    /**
     * Return an array of function names that will be run through the test suite.
     *
     * @return array Function names to test.
     */
    protected function getTestFunctions() {
        return array(
            'my_function_1',
            'my_function_2',
        );
    }

    /**
     * Return an array of class names whose methods will be run through the test suite.
     *
     * @return array Class names to test.
     */
    protected function getTestClasses() {
        return array(
            'My_Class_1',
            'My_Class_2',
        );
    }

}

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., (*9)

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., (*10)

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., (*11)

The Versions

29/08 2017

dev-master

9999999-dev

PHPUnit tests for documentation standards of PHP functions and methods.

  Sources   Download

GPL-2.0+

The Requires

 

The Development Requires

29/08 2017

1.2

1.2.0.0

PHPUnit tests for documentation standards of PHP functions and methods.

  Sources   Download

GPL-2.0+

The Requires

 

The Development Requires

05/06 2017

dev-develop

dev-develop

PHPUnit tests for documentation standards of PHP functions and methods.

  Sources   Download

GPL-2.0+

The Requires

 

The Development Requires

05/06 2017

1.1.1

1.1.1.0

PHPUnit tests for documentation standards of PHP functions and methods.

  Sources   Download

GPL-2.0+

The Requires

 

The Development Requires

21/03 2017

1.1.0

1.1.0.0

PHPUnit tests for documentation standards of PHP functions and methods.

  Sources   Download

GPL-2.0+

The Requires

 

The Development Requires

18/07 2016

1.0.2

1.0.2.0

PHPUnit tests for documentation standards of PHP functions and methods.

  Sources   Download

GPL-2.0+

The Requires

 

The Development Requires

17/07 2016

1.0.1

1.0.1.0

PHPUnit tests for documentation standards of PHP functions and methods.

  Sources   Download

GPL-2.0+

The Requires

 

The Development Requires

16/07 2016

1.0.0

1.0.0.0

PHPUnit tests for documentation standards of PHP functions and methods.

  Sources   Download

GPL-2.0+

The Requires

 

The Development Requires

15/07 2016

0.1.1

0.1.1.0

Documentation standards for WordPress functions, classes, and methods.

  Sources   Download

The Requires

 

21/12 2015

0.1.0

0.1.0.0

Documentation standards for WordPress functions, classes, and methods.

  Sources   Download

The Development Requires