Documentation

Config
in package

Stores the configuration used to run PHPCS and PHPCBF.

Table of Contents

STABILITY  = 'stable'
Package stability; either stable, beta or alpha.
VERSION  = '3.6.1'
The current version.
$annotations  : bool
$basepath  : string
$bootstrap  : array<string|int, string>
$cache  : bool
$cacheFile  : bool
$colors  : bool
$dieOnUnknownArg  : bool
Whether or not to kill the process when an unknown command line arg is found.
$encoding  : string
$errorSeverity  : int
$exclude  : array<string|int, string>
$explain  : bool
$extensions  : array<string, string>
$files  : array<string|int, string>
$filter  : string
$generator  : string
$ignored  : array<string|int, string>
$interactive  : bool
$local  : bool
$parallel  : bool
$quiet  : bool
$recordErrors  : bool
$reportFile  : string
$reports  : array<string, string|null>
$reportWidth  : int
$showProgress  : bool
$showSources  : bool
$sniffs  : array<string|int, string>
$standards  : array<string|int, string>
$stdin  : bool
$stdinContent  : string
$stdinPath  : string
$suffix  : string
$tabWidth  : int
$unknown  : array<string|int, string>
$verbosity  : int
$warningSeverity  : int
$cliArgs  : array<string|int, string>
The current command line arguments we are processing.
$configData  : array<string, string>
Config file data that has been loaded for the run.
$configDataFile  : string
The full path to the config data file that has been loaded.
$executablePaths  : array<string, string>
Automatically discovered executable utility paths.
$overriddenDefaults  : array<string, true>
Command line values that the user has supplied directly.
$settings  : array<string, mixed>
An array of settings that PHPCS and PHPCBF accept.
__construct()  : void
Creates a Config object and populates it with command line values.
__get()  : mixed
Get the value of an inaccessible property.
__isset()  : bool
Check if the value of an inaccessible property is set.
__set()  : void
Set the value of an inaccessible property.
__unset()  : void
Unset the value of an inaccessible property.
getAllConfigData()  : array<string, string>
Get all config data.
getConfigData()  : string|null
Get a single config value.
getExecutablePath()  : string|null
Get the path to an executable utility.
getSettings()  : array<string, mixed>
Get the array of all config settings.
printConfigData()  : void
Prints out the gathered config data.
printPHPCBFUsage()  : void
Prints out the usage information for PHPCBF.
printPHPCSUsage()  : void
Prints out the usage information for PHPCS.
printShortUsage()  : string|void
Prints out the short usage information for this script.
printUsage()  : void
Prints out the usage information for this script.
processFilePath()  : void
Processes a file path and add it to the file list.
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.
restoreDefaults()  : void
Restore default values for all possible command line arguments.
setCommandLineValues()  : void
Set the command line values.
setConfigData()  : bool
Set a single config value.
setSettings()  : void
Set the array of all config settings.

Constants

STABILITY

Package stability; either stable, beta or alpha.

public string STABILITY = 'stable'

VERSION

The current version.

public string VERSION = '3.6.1'

Properties

$annotations

public bool $annotations

Process phpcs: annotations.

$basepath

public string $basepath

A file system location to strip from the paths of files shown in reports.

$bootstrap

public array<string|int, string> $bootstrap

One of more files to include before the run begins.

$cache

public bool $cache

Enable the use of the file cache.

$cacheFile

public bool $cacheFile

A file where the cache data should be written

$colors

public bool $colors

Display colours in output.

$dieOnUnknownArg

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

public bool $dieOnUnknownArg

If FALSE, arguments that are not command line options or file/directory paths will be ignored and execution will continue. These values will be stored in $this->unknown.

$encoding

public string $encoding

The encoding of the files being checked.

$errorSeverity

public int $errorSeverity

The minimum severity an error must have to be displayed.

$exclude

public array<string|int, string> $exclude

The sniffs that should be excluded from checking. If empty, all sniffs in the supplied standards will be used.

$explain

public bool $explain

Explain the coding standards.

$extensions

public array<string, string> $extensions

File extensions that should be checked, and what tokenizer to use. E.g., array('inc' => 'PHP');

$files

public array<string|int, string> $files

The files and directories to check.

$filter

public string $filter

The filter to use for the run.

$generator

public string $generator

The documentation generator to use.

$ignored

public array<string|int, string> $ignored

Regular expressions used to ignore files and folders during checking.

$interactive

public bool $interactive

Enable interactive checking mode.

$local

public bool $local

Process local files in directories only (no recursion).

$parallel

public bool $parallel

Check files in parallel.

$quiet

public bool $quiet

Quiet mode; disables progress and verbose output.

$recordErrors

public bool $recordErrors

Record the content of error messages as well as error counts.

$reportFile

public string $reportFile

A file where the report output should be written.

$reports

public array<string, string|null> $reports

The reports to use for printing output after the run. The format of the array is: array( 'reportName1' => 'outputFile', 'reportName2' => null, ); If the array value is NULL, the report will be written to the screen.

$reportWidth

public int $reportWidth

The maximum number of columns that reports should use for output. Set to "auto" for have this value changed to the width of the terminal.

$showProgress

public bool $showProgress

Show basic progress information while running.

$showSources

public bool $showSources

Show sniff source codes in report output.

$sniffs

public array<string|int, string> $sniffs

The sniffs that should be used for checking. If empty, all sniffs in the supplied standards will be used.

$standards

public array<string|int, string> $standards

The standards being used for checking.

$stdin

public bool $stdin

Read content from STDIN instead of supplied files.

$stdinContent

public string $stdinContent

Content passed directly to PHPCS on STDIN.

$stdinPath

public string $stdinPath

The path to use for content passed on STDIN.

$suffix

public string $suffix

A suffix to add to fixed files.

$tabWidth

public int $tabWidth

How many spaces each tab is worth.

$unknown

public array<string|int, string> $unknown

Any arguments gathered on the command line that are unknown to us. E.g., using phpcs -c will give array('c');

$verbosity

public int $verbosity

How verbose the output should be. 0: no unnecessary output 1: basic output for files being checked 2: ruleset and file parsing output 3: sniff execution output

$warningSeverity

public int $warningSeverity

The minimum severity a warning must have to be displayed.

$cliArgs

The current command line arguments we are processing.

private array<string|int, string> $cliArgs = []

$configData

Config file data that has been loaded for the run.

private static array<string, string> $configData = null

$configDataFile

The full path to the config data file that has been loaded.

private static string $configDataFile = null

$executablePaths

Automatically discovered executable utility paths.

private static array<string, string> $executablePaths = []

$overriddenDefaults

Command line values that the user has supplied directly.

private static array<string, true> $overriddenDefaults = []

$settings

An array of settings that PHPCS and PHPCBF accept.

private array<string, mixed> $settings = ['files' => null, 'standards' => null, 'verbosity' => null, 'interactive' => null, 'parallel' => null, 'cache' => null, 'cacheFile' => null, 'colors' => null, 'explain' => null, 'local' => null, 'showSources' => null, 'showProgress' => null, 'quiet' => null, 'annotations' => null, 'tabWidth' => null, 'encoding' => null, 'extensions' => null, 'sniffs' => null, 'exclude' => null, 'ignored' => null, 'reportFile' => null, 'generator' => null, 'filter' => null, 'bootstrap' => null, 'reports' => null, 'basepath' => null, 'reportWidth' => null, 'errorSeverity' => null, 'warningSeverity' => null, 'recordErrors' => null, 'suffix' => null, 'stdin' => null, 'stdinContent' => null, 'stdinPath' => null, 'unknown' => null]

This array is not meant to be accessed directly. Instead, use the settings as if they are class member vars so the __get() and __set() magic methods can be used to validate the values. For example, to set the verbosity level to level 2, use $this->verbosity = 2; instead of accessing this property directly.

Each of these settings is described in the class comment property list.

Methods

__construct()

Creates a Config object and populates it with command line values.

public __construct([array<string|int, mixed> $cliArgs = [] ][, bool $dieOnUnknownArg = true ]) : void
Parameters
$cliArgs : array<string|int, mixed> = []

An array of values gathered from CLI args.

$dieOnUnknownArg : bool = true

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

Return values
void

__get()

Get the value of an inaccessible property.

public __get(string $name) : mixed
Parameters
$name : string

The name of the property.

Tags
throws
RuntimeException

If the setting name is invalid.

Return values
mixed

__isset()

Check if the value of an inaccessible property is set.

public __isset(string $name) : bool
Parameters
$name : string

The name of the property.

Return values
bool

__set()

Set the value of an inaccessible property.

public __set(string $name, mixed $value) : void
Parameters
$name : string

The name of the property.

$value : mixed

The value of the property.

Tags
throws
RuntimeException

If the setting name is invalid.

Return values
void

__unset()

Unset the value of an inaccessible property.

public __unset(string $name) : void
Parameters
$name : string

The name of the property.

Return values
void

getAllConfigData()

Get all config data.

public static getAllConfigData() : array<string, string>
Tags
see
getConfigData()
throws
DeepExitException

If the config file could not be read.

Return values
array<string, string>

getConfigData()

Get a single config value.

public static getConfigData(string $key) : string|null
Parameters
$key : string

The name of the config value.

Tags
see
setConfigData()
see
getAllConfigData()
Return values
string|null

getExecutablePath()

Get the path to an executable utility.

public static getExecutablePath(string $name) : string|null
Parameters
$name : string

The name of the executable utility.

Tags
see
getConfigData()
Return values
string|null

getSettings()

Get the array of all config settings.

public getSettings() : array<string, mixed>
Return values
array<string, 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

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

printShortUsage()

Prints out the short usage information for this script.

public printShortUsage([bool $return = false ]) : string|void
Parameters
$return : bool = false

If TRUE, the usage string is returned instead of output to screen.

Return values
string|void

printUsage()

Prints out the usage information for this script.

public printUsage() : void
Return values
void

processFilePath()

Processes a file path and add it to the file list.

public processFilePath(string $path) : void
Parameters
$path : string

The path to the file to add.

Tags
throws
DeepExitException
Return values
void

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.

Tags
throws
DeepExitException
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.

Tags
throws
DeepExitException
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.

Tags
throws
DeepExitException
Return values
void

restoreDefaults()

Restore default values for all possible command line arguments.

public restoreDefaults() : void
Return values
void

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 set.

Return values
void

setConfigData()

Set a single config value.

public static setConfigData(string $key, string|null $value[, bool $temp = false ]) : bool
Parameters
$key : string

The name of the config value.

$value : string|null

The value to set. If null, the config entry is deleted, reverting it to the default value.

$temp : bool = false

Set this config data temporarily for this script run. This will not write the config data to the config file.

Tags
see
getConfigData()
throws
DeepExitException

If the config file can not be written.

Return values
bool

setSettings()

Set the array of all config settings.

public setSettings(array<string, mixed> $settings) : void
Parameters
$settings : array<string, mixed>

The array of config settings.

Return values
void

Search results