phpdoc
Checks and fixes PHPDoc comments.
Description
The phpdoc
command coordinates PHPDoc checking and fixing using:
(alias docheader
and php-cs-fixer
)
- 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
cpx --skip-local "fast-forward/dev-tools:$DEV_TOOLS_VERSION" phpdoc
cpx --skip-local "fast-forward/dev-tools:$DEV_TOOLS_VERSION" phpdoc [options]
cpx --skip-local "fast-forward/dev-tools:$DEV_TOOLS_VERSION" phpdoc [options]
vendor/bin/dev-tools phpdoc [options]
Arguments
path...(optional)- Files or directories to check. Quote paths containing spaces. Without paths, each tool uses its configured source paths. Explicit paths are passed to both tools; PHP-CS-Fixer intersects them with its configured Finder, preserving exclusions. Rector receives the paths as positional arguments and retains its configured skips. Missing paths fail before the header or tools are invoked.
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: selected workspace
cache directory, usually
.dev-tools/cache/php-cs-fixer. --cache- Force PHP-CS-Fixer caching on for this run.
--no-cache- Force PHP-CS-Fixer caching off for this run.
--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):
cpx --skip-local "fast-forward/dev-tools:$DEV_TOOLS_VERSION" phpdoc
Fix PHPDocs automatically:
cpx --skip-local "fast-forward/dev-tools:$DEV_TOOLS_VERSION" phpdoc --fix
Check specific directory:
cpx --skip-local "fast-forward/dev-tools:$DEV_TOOLS_VERSION" phpdoc ./src
Check without cache:
cpx --skip-local "fast-forward/dev-tools:$DEV_TOOLS_VERSION" phpdoc --no-cache
Exit Codes
| Code | Meaning |
|---|---|
| 0 | Success. All PHPDocs valid or fixes applied. |
| 1 | Failure. PHPDoc issues found. |
Behavior
- Creates
.docheaderfrom the packaged template when the file is missing. - Uses
.php-cs-fixer.dist.phpandrector.phpthrough local-first fallback. - The Rector phase explicitly runs
FastForward\DevTools\Rector\AddMissingMethodPhpDocRector. - Cache stays enabled by default; omit both flags to keep the command default,
pass
--cacheto force it on, and pass--no-cacheto force it off. - When
--cache-diris omitted, PHP-CS-Fixer keeps its default cache directory. The option only affects PHP-CS-Fixer when caching is enabled. - Progress output is disabled by default; use
--progressto re-enable it in text mode. --jsonand--pretty-jsonforward JSON mode to PHP-CS-Fixer and Rector while disabling their progress rendering.- Uses
--dry-runmode unless--fixis specified.