Class: PHP_CodeSniffer
Source Location: /PHP_CodeSniffer-2.7.1/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 2566]
void chdir(
string
$path)
|
|
CodeSniffer alternative for chdir(). Allows for phar support.
Parameters:
generateDocs [line 1930]
void generateDocs(
string
$standard, [array
$sniffs = array()], [string
$generator = 'Text'])
|
|
Generates documentation for a coding standard.
Parameters:
getAllConfigData [line 2459]
Get all config data in an array.
getConfigData [line 2362]
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 1566]
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 2329]
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 2198]
array getInstalledStandardPaths(
)
|
|
Get a list paths where standards are installed.
getInstalledStandards [line 2237]
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 1949]
PHP_CodeSniffer_Sniff[] getSniffs(
)
|
|
Gets the array of PHP_CodeSniffer_Sniff's.
getTokenSniffs [line 1961]
Gets the array of PHP_CodeSniffer_Sniff's indexed by token type.
initStandard [line 521]
void initStandard(
string|array
$standards, [array
$restrictions = array()], [array
$exclusions = array()])
|
|
Initialise the standard that the run will use.
Parameters:
isCamelCaps [line 1988]
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 2286]
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 2498]
mixed isPharFile(
string
$path)
|
|
Return TRUE, if the path is a phar file.
Parameters:
isUnderscoreName [line 2060]
boolean isUnderscoreName(
string
$string)
|
|
Returns true if the specified string is in the underscore caps format.
Parameters:
populateTokenListeners [line 1443]
void populateTokenListeners(
)
|
|
Populates the array of PHP_CodeSniffer_Sniff's for this file.
prepareForOutput [line 2175]
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 1737]
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 616]
void processFiles(
string|array
$files, [boolean
$local = false])
|
|
Processes the files/directories that PHP_CodeSniffer was constructed with.
Parameters:
processRuleset [line 723]
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 2518]
mixed realpath(
string
$path)
|
|
CodeSniffer alternative for realpath. Allows for phar support.
Parameters:
registerSniffs [line 1367]
void registerSniffs(
array
$files, array
$restrictions, array
$exclusions)
|
|
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 2397]
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 1529]
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 1670]
bool shouldIgnoreFile(
string
$path, string
$basedir)
|
|
Checks filtering rules to see if a file should be ignored.
Parameters:
shouldProcessFile [line 1627]
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 2101]
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:50:42 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.
|
|