PHP Classes

File: README.md

Recommend this page to a friend!
  Classes of Lars Moelleken   PHP Doctor   README.md   Download  
File: README.md
Role: Documentation
Content type: text/markdown
Description: Documentation
Class: PHP Doctor
Scan PHP to find missing or wrong PHPDoc comments
Author: By
Last change:
Date: 4 years ago
Size: 4,728 bytes
 

Contents

Class file image Download

Build Status Codacy Badge Latest Stable Version License Donate to this project using Paypal Donate to this project using Patreon

? *PHPDoc*tor

Check PHP files or directories for missing types.

If you already use PHPStan for your type checks but sometimes someone in the team still commit non typed code, then PHPDoctor is for you.

Install via "phar" (recommended)

https://github.com/voku/PHPDoctor/releases

Install via "composer require"

composer require-dev voku/phpdoctor

Quick Start

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"]

Demo

Parse a string:

$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']

Ignore errors

You can use `<phpdoctor-ignore-this-line/>` in @param or @return phpdocs to ignore the errors directly in your code.

/
 * @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;
}

Building the PHAR file

phive install --force-accept-unsigned humbug/box
php tools/box compile --debug

Support

For support and donations please visit Github | Issues | PayPal | Patreon.

For status updates and release announcements please visit Releases | Twitter | Patreon.

For professional support please contact me.

Thanks

  • Thanks to GitHub (Microsoft) for hosting the code and a good infrastructure including Issues-Managment, etc.
  • Thanks to IntelliJ as they make the best IDEs for PHP and they gave me an open source license for PhpStorm!
  • Thanks to Travis CI for being the most awesome, easiest continous integration tool out there!
  • Thanks to StyleCI for the simple but powerfull code style check.
  • Thanks to PHPStan && Psalm for really great Static analysis tools and for discover bugs in the code!