Documentation

PHP_CodeSniffer_CLI
in package

A class to process command line phpcs scripts.

Tags
category

PHP

author

Greg Sherwood gsherwood@squiz.net

copyright

2006-2014 Squiz Pty Ltd (ABN 77 084 670 600)

license

https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence

version

Release: @package_version@

link
http://pear.php.net/package/PHP_CodeSniffer

Table of Contents

$dieOnUnknownArg  : bool
Whether or not to kill the process when an unknown command line arg is found.
$errorSeverity  : bool
The minimum severity level errors must have to be displayed.
$warningSeverity  : bool
The minimum severity level warnings must have to be displayed.
$values  : array<string|int, mixed>
An array of all values specified on the command line.
$_cliArgs  : array<string|int, mixed>
An array of the current command line arguments we are processing.
checkRequirements()  : array<string|int, mixed>
Exits if the minimum requirements of PHP_CodSniffer are not met.
explainStandard()  : void
Prints a report showing the sniffs contained in a standard.
getCommandLineValues()  : array<string|int, mixed>
Gets the processed command line values.
getDefaults()  : array<string|int, mixed>
Get a list of default values for all possible command line arguments.
printConfigData()  : void
Prints out the gathered config data.
printErrorReport()  : int
Prints the error report for the run.
printInstalledStandards()  : void
Prints out a list of installed coding standards.
printPHPCBFUsage()  : void
Prints out the usage information for PHPCBF.
printPHPCSUsage()  : void
Prints out the usage information for PHPCS.
printUsage()  : void
Prints out the usage information for this script.
process()  : int
Runs PHP_CodeSniffer over files and directories.
processLongArgument()  : void
Processes a long (--example) command line argument.
processShortArgument()  : void
Processes a short (-e) command line argument.
processUnknownArgument()  : void
Processes an unknown command line argument.
runphpcbf()  : array<string|int, mixed>
Run the PHPCBF script.
runphpcs()  : array<string|int, mixed>
Run the PHPCS script.
setCommandLineValues()  : void
Set the command line values.
validateStandard()  : array<string|int, mixed>
Convert the passed standards into valid standards.
_validateReportWidth()  : int
Set report width based on terminal width.

Properties

$dieOnUnknownArg

Whether or not to kill the process when an unknown command line arg is found.

public bool $dieOnUnknownArg = rue

If FALSE, arguments that are not command line options or file/directory paths will be ignored and execution will continue.

$errorSeverity

The minimum severity level errors must have to be displayed.

public bool $errorSeverity = 0

$warningSeverity

The minimum severity level warnings must have to be displayed.

public bool $warningSeverity = 0

$values

An array of all values specified on the command line.

protected array<string|int, mixed> $values = array()

$_cliArgs

An array of the current command line arguments we are processing.

private array<string|int, mixed> $_cliArgs = array()

Methods

checkRequirements()

Exits if the minimum requirements of PHP_CodSniffer are not met.

public checkRequirements() : array<string|int, mixed>
Return values
array<string|int, mixed>

explainStandard()

Prints a report showing the sniffs contained in a standard.

public explainStandard(string $standard) : void
Parameters
$standard : string

The standard to validate.

Return values
void

getCommandLineValues()

Gets the processed command line values.

public getCommandLineValues() : array<string|int, mixed>

If the values have not yet been set, the values will be sourced from the command line arguments.

Return values
array<string|int, mixed>

getDefaults()

Get a list of default values for all possible command line arguments.

public getDefaults() : array<string|int, mixed>
Return values
array<string|int, mixed>

printConfigData()

Prints out the gathered config data.

public printConfigData(array<string|int, mixed> $data) : void
Parameters
$data : array<string|int, mixed>

The config data to print.

Return values
void

printErrorReport()

Prints the error report for the run.

public printErrorReport(PHP_CodeSniffer $phpcs, array<string|int, mixed> $reports, bool $showSources, string $reportFile, int $reportWidth) : int

Note that this function may actually print multiple reports as the user may have specified a number of output formats.

Parameters
$phpcs : PHP_CodeSniffer

The PHP_CodeSniffer object containing the errors.

$reports : array<string|int, mixed>

A list of reports to print.

$showSources : bool

TRUE if report should show error sources (not used by all reports).

$reportFile : string

A default file to log report output to.

$reportWidth : int

How wide the screen reports should be.

Return values
int

The number of error and warning messages shown.

printInstalledStandards()

Prints out a list of installed coding standards.

public printInstalledStandards() : void
Return values
void

printPHPCBFUsage()

Prints out the usage information for PHPCBF.

public printPHPCBFUsage() : void
Return values
void

printPHPCSUsage()

Prints out the usage information for PHPCS.

public printPHPCSUsage() : void
Return values
void

printUsage()

Prints out the usage information for this script.

public printUsage() : void
Return values
void

process()

Runs PHP_CodeSniffer over files and directories.

public process([array<string|int, mixed> $values = array() ]) : int
Parameters
$values : array<string|int, mixed> = array()

An array of values determined from CLI args.

Tags
see
getCommandLineValues()
Return values
int

The number of error and warning messages shown.

processLongArgument()

Processes a long (--example) command line argument.

public processLongArgument(string $arg, int $pos) : void
Parameters
$arg : string

The command line argument.

$pos : int

The position of the argument on the command line.

Return values
void

processShortArgument()

Processes a short (-e) command line argument.

public processShortArgument(string $arg, int $pos) : void
Parameters
$arg : string

The command line argument.

$pos : int

The position of the argument on the command line.

Return values
void

processUnknownArgument()

Processes an unknown command line argument.

public processUnknownArgument(string $arg, int $pos) : void

Assumes all unknown arguments are files and folders to check.

Parameters
$arg : string

The command line argument.

$pos : int

The position of the argument on the command line.

Return values
void

runphpcbf()

Run the PHPCBF script.

public runphpcbf() : array<string|int, mixed>
Return values
array<string|int, mixed>

runphpcs()

Run the PHPCS script.

public runphpcs() : array<string|int, mixed>
Return values
array<string|int, mixed>

setCommandLineValues()

Set the command line values.

public setCommandLineValues(array<string|int, mixed> $args) : void
Parameters
$args : array<string|int, mixed>

An array of command line arguments to process.

Return values
void

validateStandard()

Convert the passed standards into valid standards.

public validateStandard(array<string|int, mixed> $standards) : array<string|int, mixed>

Checks things like default values and case.

Parameters
$standards : array<string|int, mixed>

The standards to validate.

Return values
array<string|int, mixed>

_validateReportWidth()

Set report width based on terminal width.

private _validateReportWidth(int $width) : int
Parameters
$width : int

The width of the report. If "auto" then will be replaced by the terminal width.

Return values
int

Search results