Provides operations to inspect, lint, and repair PHPDoc comments across the project.
Description
The class MUST NOT be extended and SHALL coordinate tools like PHP-CS-Fixer and Rector.
'phpdoc'
'Checks and fixes PHPDocs.'
'This command checks and fixes PHPDocs in your PHP files.'
Interfaces
Defines the logger contract consumed by reusable command result helpers.
Constants
Properties
Methods
Creates a new PhpDocCommand instance.
Adds the standard JSON output options to the current command.
Configures the PHPDoc command.
Executes the PHPDoc checks and rectifications.
Determines whether JSON output was requested.
Determines whether pretty JSON output was requested.
Creates the missing document header configuration file if needed.
Logs a failed command result and returns the failure exit code.
Logs an informational command message at notice level.
Logs a successful command result and returns the success exit code.
public
string
CACHE_FILE
=
'.php-cs-fixer.cache'
Description
defines the cache file name for PHP-CS-Fixer results
public
string
CONFIG
=
'.php-cs-fixer.dist.php'
Description
stores the underlying configuration file for PHP-CS-Fixer
public
string
FILENAME
=
'.docheader'
Description
determines the template filename for docheaders
private
ClockInterface
$clock
private
ComposerJsonInterface
$composer
private
FileLocatorInterface
$fileLocator
private
FilesystemInterface
$filesystem
private
LoggerInterface
$logger
private
ProcessBuilderInterface
$processBuilder
private
ProcessQueueInterface
$processQueue
private
Environment
$renderer
Creates a new PhpDocCommand instance.
public
__construct(ProcessBuilderInterface
$processBuilder, ProcessQueueInterface
$processQueue, ComposerJsonInterface
$composer, FileLocatorInterface
$fileLocator, FilesystemInterface
$filesystem, Environment
$renderer, ClockInterface
$clock, LoggerInterface
$logger) : mixed
Parameters
$fileLocator
:
FileLocatorInterface
Description
the locator for template resources
Description
the filesystem component
$renderer
:
Environment
$clock
:
ClockInterface
$logger
:
LoggerInterface
Description
the output-aware logger
Adds the standard JSON output options to the current command.
protected
addJsonOption() : static
Return values
Configures the PHPDoc command.
protected
configure() : void
Description
This method MUST securely configure the expected inputs, such as the --fix option.
Executes the PHPDoc checks and rectifications.
protected
execute(InputInterface
$input, OutputInterface
$output) : int
Description
The method MUST ensure the .docheader template is present. It SHALL then invoke
PHP-CS-Fixer and Rector. If both succeed, it MUST return self::SUCCESS.
Parameters
$input
:
InputInterface
Description
the command input parameters
$output
:
OutputInterface
Description
the system output handler
Return values
Description
the success or failure state
Determines whether JSON output was requested.
protected
isJsonOutput(InputInterface
$input) : bool
Description
The pretty-json flag SHALL imply JSON output.
Parameters
$input
:
InputInterface
Return values
Determines whether pretty JSON output was requested.
protected
isPrettyJsonOutput(InputInterface
$input) : bool
Parameters
$input
:
InputInterface
Return values
Creates the missing document header configuration file if needed.
private
ensureDocHeaderExists() : void
Description
The method MUST query the local filesystem. If the file is missing, it SHOULD copy the tool template into the root folder.
Logs a failed command result and returns the failure exit code.
private
failure(
string
$message, InputInterface
$input[,
array<string, mixed>
$context = []][,
string|null
$file = null][,
int|null
$line = null]) : int
Parameters
$message
:
string
Description
the failure message
$input
:
InputInterface
Description
the originating command input
$context
:
array<string, mixed>
=
[]
Description
optional extra log context
$file
:
string|null
=
null
Description
the related file path when known
$line
:
int|null
=
null
Description
the related line when known
Return values
Logs an informational command message at notice level.
private
notice(
string
$message, InputInterface
$input[,
array<string, mixed>
$context = []]) : void
Parameters
$message
:
string
Description
the notice message
$input
:
InputInterface
Description
the originating command input
$context
:
array<string, mixed>
=
[]
Description
optional extra log context
Logs a successful command result and returns the success exit code.
private
success(
string
$message, InputInterface
$input[,
array<string, mixed>
$context = []][,
string
$logLevel = LogLevel::INFO]) : int
Parameters
$message
:
string
Description
the success message
$input
:
InputInterface
Description
the originating command input
$context
:
array<string, mixed>
=
[]
Description
optional extra log context
$logLevel
:
string
=
LogLevel::INFO
Description
the PSR-3 log level used for the successful result