Class: PHP_CodeSniffer
Source Location: /PHP_CodeSniffer-2.6.0/CodeSniffer.php
PHP_CodeSniffer tokenizes PHP code and detects violations of a defined set of coding standards.
Author(s):
Version:
- Release: @package_version@
Copyright:
- 2006-2014 Squiz Pty Ltd (ABN 77 084 670 600)
|
|
|
Inherited Variables
|
Inherited Methods
|
Class Details
Class Variables
$allowedFileExtensions = array()
[line 171]
An array of extensions for files we will check.
$allowedTypes = array(
'array',
'boolean',
'float',
'integer',
'mixed',
'object',
'string',
'resource',
'callable',
)
[line 195]
An array of variable types for param/var we will check.
$cli = null
[line 109]
The CLI object controlling the run.
$defaultFileExtensions = array(
'php' => 'PHP',
'inc' => 'PHP',
'js' => 'JS',
'css' => 'CSS',
)
[line 183]
An array of default extensions and associated tokenizers. If no extensions are set, these will be used as the defaults. If extensions are set, these will be used when the correct tokenizer can not be determined, such as when checking a passed filename instead of files in a directory.
$file = ''
[line 90]
The file or directory that is currently being processed.
$ignorePatterns = array()
[line 164]
An array of patterns to use for skipping files.
$listeners = array()
[line 123]
An array of sniff objects that are being used to check files.
$reporting = null
[line 116]
The Reporting object controlling report generation.
$ruleset = array()
[line 157]
An array of rules from the ruleset.xml file. It may be empty, indicating that the ruleset does not override any of the default sniff settings.
$rulesetDirs = array()
[line 102]
The directories that the processed rulesets are in. This is declared static because it is also used in the autoloader to look for sniffs outside the PHPCS install. This way, standards designed to be installed inside PHPCS can also be used from outside the PHPCS Standards directory.
$sniffCodes = array()
[line 140]
A mapping of sniff codes to fully qualified class names. The key is the sniff code and the value is the fully qualified name of the sniff class.
$sniffs = array()
[line 130]
An array of sniffs that are being used to check files.
Method Detail
__construct (Constructor) [line 227]
PHP_CodeSniffer __construct(
[int
$verbosity = 0], [int
$tabWidth = 0], [string
$encoding = 'iso-8859-1'], [bool
$interactive = false])
|
|
Constructs a PHP_CodeSniffer object.
Parameters:
autoload [line 280]
void autoload(
string
$className)
|
|
Autoload static method for loading classes and interfaces.
Parameters:
chdir [line 2522]
void chdir(
string
$path)
|
|
CodeSniffer alternative for chdir(). Allows for phar support.
Parameters:
generateDocs [line 1890]
void generateDocs(
string
$standard, [array
$sniffs = array()], [string
$generator = 'Text'])
|
|
Generates documentation for a coding standard.
Parameters:
getAllConfigData [line 2415]
Get all config data in an array.
getConfigData [line 2318]
string|null getConfigData(
string
$key)
|
|
Get a single config value. Config data is stored in the data dir, in a file called CodeSniffer.conf. It is a simple PHP array.
Parameters:
getFilesToProcess [line 1526]
array getFilesToProcess(
string
$paths, [boolean
$local = false])
|
|
Get a list of files that will be processed. If passed directories, this method will find all files within them. The method will also perform file extension and ignore pattern filtering.
Parameters:
getIgnorePatterns [line 459]
array getIgnorePatterns(
[string
$listener = null])
|
|
Gets the array of ignore patterns. Optionally takes a listener to get ignore patterns specified for that sniff only.
Parameters:
getInstalledStandardPath [line 2285]
string|null getInstalledStandardPath(
string
$standard)
|
|
Return the path of an installed coding standard. Coding standards are directories located in the CodeSniffer/Standards directory. Valid coding standards include a ruleset.xml file.
Parameters:
getInstalledStandardPaths [line 2154]
array getInstalledStandardPaths(
)
|
|
Get a list paths where standards are installed.
getInstalledStandards [line 2193]
array getInstalledStandards(
[boolean
$includeGeneric = false], [string
$standardsDir = ''])
|
|
Get a list of all coding standards installed. Coding standards are directories located in the CodeSniffer/Standards directory. Valid coding standards include a Sniffs subdirectory.
Parameters:
getSniffs [line 1909]
PHP_CodeSniffer_Sniff[] getSniffs(
)
|
|
Gets the array of PHP_CodeSniffer_Sniff's.
getTokenSniffs [line 1921]
Gets the array of PHP_CodeSniffer_Sniff's indexed by token type.
initStandard [line 520]
void initStandard(
string|array
$standards, [array
$restrictions = array()])
|
|
Initialise the standard that the run will use.
Parameters:
isCamelCaps [line 1948]
boolean isCamelCaps(
string
$string, [boolean
$classFormat = false], [boolean
$public = true], [boolean
$strict = true])
|
|
Returns true if the specified string is in the camel caps format.
Parameters:
isInstalledStandard [line 2242]
boolean isInstalledStandard(
string
$standard)
|
|
Determine if a standard is installed. Coding standards are directories located in the CodeSniffer/Standards directory. Valid coding standards include a ruleset.xml file.
Parameters:
isPharFile [line 2454]
mixed isPharFile(
string
$path)
|
|
Return TRUE, if the path is a phar file.
Parameters:
isUnderscoreName [line 2020]
boolean isUnderscoreName(
string
$string)
|
|
Returns true if the specified string is in the underscore caps format.
Parameters:
populateTokenListeners [line 1403]
void populateTokenListeners(
)
|
|
Populates the array of PHP_CodeSniffer_Sniff's for this file.
prepareForOutput [line 2131]
string prepareForOutput(
string
$content)
|
|
Prepares token content for output to screen. Replaces invisible characters so they are visible. On non-Windows OSes it will also colour the invisible characters.
Parameters:
process [line 502]
void process(
string|array
$files, string|array
$standards, [array
$restrictions = array()], [boolean
$local = false])
|
|
Start a PHP_CodeSniffer run.
Parameters:
processFile [line 1697]
Run the code sniffs over a single given file. Processes the file and runs the PHP_CodeSniffer sniffs to verify that it conforms with the standard. Returns the processed file object, or NULL if no file was processed due to error.
Parameters:
processFiles [line 592]
void processFiles(
string|array
$files, [boolean
$local = false])
|
|
Processes the files/directories that PHP_CodeSniffer was constructed with.
Parameters:
processRuleset [line 699]
array processRuleset(
string
$rulesetPath, [int
$depth = 0])
|
|
Processes a single ruleset and returns a list of the sniffs it represents. Rules founds within the ruleset are processed immediately, but sniff classes are not registered by this method.
Parameters:
realpath [line 2474]
mixed realpath(
string
$path)
|
|
CodeSniffer alternative for realpath. Allows for phar support.
Parameters:
registerSniffs [line 1335]
void registerSniffs(
array
$files, array
$restrictions)
|
|
Loads and stores sniffs objects used for sniffing files.
Parameters:
setAllowedFileExtensions [line 403]
void setAllowedFileExtensions(
array
$extensions)
|
|
Sets an array of file extensions that we will allow checking of. If the extension is one of the defaults, a specific tokenizer will be used. Otherwise, the PHP tokenizer will be used for all extensions passed.
Parameters:
setCli [line 481]
void setCli(
object
$cli)
|
|
Sets the internal CLI object.
Parameters:
setConfigData [line 2353]
boolean setConfigData(
string
$key, string|null
$value, [boolean
$temp = false])
|
|
Set a single config value. Config data is stored in the data dir, in a file called CodeSniffer.conf. It is a simple PHP array.
Parameters:
setEncoding [line 366]
void setEncoding(
string
$encoding)
|
|
Sets the encoding.
Parameters:
setIgnorePatterns [line 441]
void setIgnorePatterns(
array
$patterns)
|
|
Sets an array of ignore patterns that we use to skip files and folders. Patterns are not case sensitive.
Parameters:
setInteractive [line 383]
void setInteractive(
bool
$interactive)
|
|
Sets the interactive flag.
Parameters:
setSniffProperty [line 1489]
void setSniffProperty(
string
$listenerClass, string
$name, string
$value)
|
|
Set a single property for a sniff.
Parameters:
setTabWidth [line 347]
void setTabWidth(
int
$tabWidth)
|
|
Sets the tab width.
Parameters:
setVerbosity [line 329]
void setVerbosity(
int
$verbosity)
|
|
Sets the verbosity level.
Parameters:
shouldIgnoreFile [line 1630]
bool shouldIgnoreFile(
string
$path, string
$basedir)
|
|
Checks filtering rules to see if a file should be ignored.
Parameters:
shouldProcessFile [line 1587]
bool shouldProcessFile(
string
$path, string
$basedir)
|
|
Checks filtering rules to see if a file should be checked. Checks both file extension filters and path ignore filters.
Parameters:
suggestType [line 2061]
string suggestType(
string
$varType)
|
|
Returns a valid variable type for param/var tag. If type is not one of the standard type, it must be a custom type. Returns the correct type name suggestion if type name is invalid.
Parameters:
Documentation generated on Mon, 11 Mar 2019 14:56:08 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.
|
|