phpdoc

Checks and fixes PHPDoc comments.

Description

The phpdoc command coordinates PHPDoc checking and fixing using:

  • PHP-CS-Fixer - fixes PHPDoc formatting
  • Rector with AddMissingMethodPhpDocRector - adds missing method PHPDoc

It also creates the .docheader template from repository metadata when missing.

Usage

composer phpdoc
composer phpdoc [options]
composer dev-tools phpdoc -- [options]
vendor/bin/dev-tools phpdoc [options]

Arguments

path (optional)
Path to the file or directory to check. Default: . .

Options

--fix, -f
Automatically fix PHPDoc issues. Without this option, runs in dry-run mode.
--cache-dir (optional)
Path to the cache directory for PHP-CS-Fixer. Default: .dev-tools/cache/php-cs-fixer .
--progress
Enable progress output from PHP-CS-Fixer and the Rector phase.
--json
Emit a structured machine-readable payload instead of the normal terminal output.
--pretty-json
Emit the same structured payload with indentation for terminal inspection.

Examples

Check PHPDocs (dry-run):

composer phpdoc

Fix PHPDocs automatically:

composer phpdoc --fix

Check specific directory:

composer phpdoc ./src

Exit Codes

Code Meaning
0 Success. All PHPDocs valid or fixes applied.
1 Failure. PHPDoc issues found.

Behavior

  • Creates .docheader from the packaged template when the file is missing.
  • Uses .php-cs-fixer.dist.php and rector.php through local-first fallback.
  • The Rector phase explicitly runs FastForward\DevTools\Rector\AddMissingMethodPhpDocRector .
  • Progress output is disabled by default; use --progress to re-enable it in text mode.
  • --json and --pretty-json forward JSON mode to PHP-CS-Fixer and Rector while disabling their progress rendering.
  • Uses --dry-run mode unless --fix is specified.