PHP Класс PHP_CodeSniffer_CLI, PHP_CodeSniffer

Автор: Greg Sherwood ([email protected])
Показать файл Открыть проект Примеры использования класса

Открытые свойства

Свойство Тип Описание
$dieOnUnknownArg boolean If FALSE, arguments that are not command line options or file/directory paths will be ignored and execution will continue.
$errorSeverity boolean The minimum severity level errors must have to be displayed.
$warningSeverity boolean The minimum severity level warnings must have to be displayed.

Защищенные свойства (Protected)

Свойство Тип Описание
$values array An array of all values specified on the command line.

Открытые методы

Метод Описание
checkRequirements ( ) : array Exits if the minimum requirements of PHP_CodSniffer are not met.
explainStandard ( string $standard ) : void Prints a report showing the sniffs contained in a standard.
getCommandLineValues ( ) : array Gets the processed command line values.
getDefaults ( ) : array Get a list of default values for all possible command line arguments.
printConfigData ( array $data ) : void Prints out the gathered config data.
printErrorReport ( PHP_CodeSniffer $phpcs, array $reports, boolean $showSources, string $reportFile, integer $reportWidth ) : integer 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 ( array $values = [] ) : integer Runs PHP_CodeSniffer over files and directories.
processLongArgument ( string $arg, integer $pos ) : void Processes a long (--example) command line argument.
processShortArgument ( string $arg, integer $pos ) : void Processes a short (-e) command line argument.
processUnknownArgument ( string $arg, integer $pos ) : void Processes an unknown command line argument.
runphpcbf ( ) : array Run the PHPCBF script.
runphpcs ( ) : array Run the PHPCS script.
setCommandLineValues ( array $args ) : void Set the command line values.
validateStandard ( array $standards ) : array Convert the passed standards into valid standards.

Приватные методы

Метод Описание
_validateReportWidth ( integer $width ) : integer Set report width based on terminal width.

Описание методов

checkRequirements() публичный Метод

Exits if the minimum requirements of PHP_CodSniffer are not met.
public checkRequirements ( ) : array
Результат array

explainStandard() публичный Метод

Prints a report showing the sniffs contained in a standard.
public explainStandard ( string $standard ) : void
$standard string The standard to validate.
Результат void

getCommandLineValues() публичный Метод

If the values have not yet been set, the values will be sourced from the command line arguments.
public getCommandLineValues ( ) : array
Результат array

getDefaults() публичный Метод

Get a list of default values for all possible command line arguments.
public getDefaults ( ) : array
Результат array

printConfigData() публичный Метод

Prints out the gathered config data.
public printConfigData ( array $data ) : void
$data array The config data to print.
Результат void

printErrorReport() публичный Метод

Note that this function may actually print multiple reports as the user may have specified a number of output formats.
public printErrorReport ( PHP_CodeSniffer $phpcs, array $reports, boolean $showSources, string $reportFile, integer $reportWidth ) : integer
$phpcs PHP_CodeSniffer The PHP_CodeSniffer object containing the errors.
$reports array A list of reports to print.
$showSources boolean TRUE if report should show error sources (not used by all reports).
$reportFile string A default file to log report output to.
$reportWidth integer How wide the screen reports should be.
Результат integer The number of error and warning messages shown.

printInstalledStandards() публичный Метод

Prints out a list of installed coding standards.
public printInstalledStandards ( ) : void
Результат void

printPHPCBFUsage() публичный Метод

Prints out the usage information for PHPCBF.
public printPHPCBFUsage ( ) : void
Результат void

printPHPCSUsage() публичный Метод

Prints out the usage information for PHPCS.
public printPHPCSUsage ( ) : void
Результат void

printUsage() публичный Метод

Prints out the usage information for this script.
public printUsage ( ) : void
Результат void

process() публичный Метод

Runs PHP_CodeSniffer over files and directories.
См. также: getCommandLineValues()
public process ( array $values = [] ) : integer
$values array An array of values determined from CLI args.
Результат integer The number of error and warning messages shown.

processLongArgument() публичный Метод

Processes a long (--example) command line argument.
public processLongArgument ( string $arg, integer $pos ) : void
$arg string The command line argument.
$pos integer The position of the argument on the command line.
Результат void

processShortArgument() публичный Метод

Processes a short (-e) command line argument.
public processShortArgument ( string $arg, integer $pos ) : void
$arg string The command line argument.
$pos integer The position of the argument on the command line.
Результат void

processUnknownArgument() публичный Метод

Assumes all unknown arguments are files and folders to check.
public processUnknownArgument ( string $arg, integer $pos ) : void
$arg string The command line argument.
$pos integer The position of the argument on the command line.
Результат void

runphpcbf() публичный Метод

Run the PHPCBF script.
public runphpcbf ( ) : array
Результат array

runphpcs() публичный Метод

Run the PHPCS script.
public runphpcs ( ) : array
Результат array

setCommandLineValues() публичный Метод

Set the command line values.
public setCommandLineValues ( array $args ) : void
$args array An array of command line arguments to process.
Результат void

validateStandard() публичный Метод

Checks things like default values and case.
public validateStandard ( array $standards ) : array
$standards array The standards to validate.
Результат array

Описание свойств

$dieOnUnknownArg публичное свойство

If FALSE, arguments that are not command line options or file/directory paths will be ignored and execution will continue.
public bool $dieOnUnknownArg
Результат boolean

$errorSeverity публичное свойство

The minimum severity level errors must have to be displayed.
public bool $errorSeverity
Результат boolean

$values защищенное свойство

An array of all values specified on the command line.
protected array $values
Результат array

$warningSeverity публичное свойство

The minimum severity level warnings must have to be displayed.
public bool $warningSeverity
Результат boolean