Class: File
Source Location: /PHP_CodeSniffer-3.1.1/src/Files/File.php
Represents a piece of content being checked during the run.
Author(s):
Copyright:
- 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600)
|
|
|
Child classes:
|
Inherited Variables
|
Inherited Methods
|
Class Details
Class Variables
$activeListener = ''
[line 182]
The class name of the sniff currently processing the file.
$config = null
[line 41]
The config data for the run.
$configCache = array()
[line 198]
A cache of often used config settings to improve performance. Storing them here saves 10k+ calls to __get() in the Config class.
$content = ''
[line 34]
The absolute path to the file associated with this object.
$eolChar = ''
[line 62]
The EOL character this file uses.
$errorCount = 0
[line 133]
The total number of errors raised.
$errors = array()
[line 110]
The errors raised from sniffs.
$fixableCount = 0
[line 147]
The total number of errors and warnings that can be fixed.
$fixedCount = 0
[line 154]
The total number of errors and warnings that were fixed.
$fixer = null
[line 69]
The Fixer object to control fixing errors.
$fromCache = false
[line 86]
Was the file loaded from cache? If TRUE, the file was loaded from a local cache. If FALSE, the file was tokenized and processed fully.
$ignored = false
[line 55]
If TRUE, the entire file is being ignored.
$ignoredCodes = array()
[line 168]
An array of message codes that are being ignored.
$ignoredListeners = array()
[line 161]
An array of sniffs that are being ignored.
$listeners = array()
[line 175]
An array of sniffs listening to this file's processing.
$listenerTimes = array()
[line 189]
An array of sniffs being processed and how long they took.
$metrics = array()
[line 126]
The metrics recorded by sniffs.
$numTokens = 0
[line 95]
The number of tokens in this file. Stored here to save calling count() everywhere.
$path = ''
[line 27]
The absolute path to the file associated with this object.
$ruleset = null
[line 48]
The ruleset used for the run.
$tokenizer = null
[line 76]
The tokenizer being used for this file.
$tokens = array()
[line 102]
The tokens stack map.
$warningCount = 0
[line 140]
The total number of warnings raised.
$warnings = array()
[line 118]
The warnings raised from sniffs.
Method Detail
__construct (Constructor) [line 210]
void __construct(
string
$path, Ruleset
$ruleset, Config
$config)
|
|
Constructs a file.
Overridden in child classes as:
- LocalFile::__construct()
- Creates a LocalFile object and sets the content.
- DummyFile::__construct()
- Creates a DummyFile object and sets the content.
Parameters:
addError [line 595]
boolean addError(
string
$error, int
$stackPtr, string
$code, [array
$data = array()], [int
$severity = 0], [boolean
$fixable = false])
|
|
Records an error against a specific token in the file.
Parameters:
addErrorOnLine [line 662]
boolean addErrorOnLine(
string
$error, int
$line, string
$code, [array
$data = array()], [int
$severity = 0])
|
|
Records an error against a specific line in the file.
Parameters:
addFixableError [line 712]
boolean addFixableError(
string
$error, int
$stackPtr, string
$code, [array
$data = array()], [int
$severity = 0])
|
|
Records a fixable error against a specific token in the file. Returns true if the error was recorded and should be fixed.
Parameters:
addFixableWarning [line 743]
boolean addFixableWarning(
string
$warning, int
$stackPtr, string
$code, [array
$data = array()], [int
$severity = 0])
|
|
Records a fixable warning against a specific token in the file. Returns true if the warning was recorded and should be fixed.
Parameters:
addMessage [line 775]
boolean addMessage(
boolean
$error, string
$message, int
$line, int
$column, string
$code, array
$data, int
$severity, boolean
$fixable)
|
|
Adds an error to the error stack.
Parameters:
addWarning [line 629]
boolean addWarning(
string
$warning, int
$stackPtr, string
$code, [array
$data = array()], [int
$severity = 0], [boolean
$fixable = false])
|
|
Records a warning against a specific token in the file.
Parameters:
addWarningOnLine [line 686]
boolean addWarningOnLine(
string
$warning, int
$line, string
$code, [array
$data = array()], [int
$severity = 0])
|
|
Records a warning against a specific token in the file.
Parameters:
cleanUp [line 569]
Remove vars stored in this file that are no longer required.
disableCaching [line 280]
Disables caching of this file.
findEndOfStatement [line 1966]
int findEndOfStatement(
int
$start, [int|array
$ignore = null])
|
|
Returns the position of the last non-whitespace token in a statement.
Parameters:
findExtendedClassName [line 2172]
string|false findExtendedClassName(
int
$stackPtr)
|
|
Returns the name of the class that the specified class extends. (works for classes, anonymous classes and interfaces) Returns FALSE on error or if there is no extended class name.
Parameters:
findFirstOnLine [line 2051]
int findFirstOnLine(
int|array
$types, int
$start, [bool
$exclude = false], [string
$value = null])
|
|
Returns the position of the first token on a line, matching given type. Returns false if no token can be found.
Parameters:
findImplementedInterfaceNames [line 2224]
array|false findImplementedInterfaceNames(
int
$stackPtr)
|
|
Returns the names of the interfaces that the specified class implements. Returns FALSE on error or if there are no implemented interface names.
Parameters:
findNext [line 1852]
int|bool findNext(
int|array
$types, int
$start, [int
$end = null], [bool
$exclude = false], [string
$value = null], [bool
$local = false])
|
|
Returns the position of the next specified token(s). If a value is specified, the next token of the specified type(s) containing the specified value will be returned. Returns false if no token can be found.
Parameters:
findPrevious [line 1771]
int|bool findPrevious(
int|array
$types, int
$start, [int
$end = null], [bool
$exclude = false], [string
$value = null], [bool
$local = false])
|
|
Returns the position of the previous specified token(s). If a value is specified, the previous token of the specified type(s) containing the specified value will be returned. Returns false if no token can be found.
Parameters:
findStartOfStatement [line 1901]
int findStartOfStatement(
int
$start, [int|array
$ignore = null])
|
|
Returns the position of the first non-whitespace token in a statement.
Parameters:
getClassProperties [line 1545]
array getClassProperties(
int
$stackPtr)
|
|
Returns the visibility and implementation properties of a class. The format of the array is: array(
'is_abstract' => false, // true if the abstract keyword was found.
'is_final' => false, // true if the final keyword was found.
);
Parameters:
getCondition [line 2138]
int getCondition(
int
$stackPtr, int
$type)
|
|
Return the position of the condition for the passed token. Returns FALSE if the token does not have the condition.
Parameters:
getDeclarationName [line 1116]
string|null getDeclarationName(
int
$stackPtr)
|
|
Returns the declaration names for classes, interfaces, traits, and functions.
Parameters:
getErrorCount [line 989]
Returns the number of errors raised.
getErrors [line 1061]
Returns the errors raised from processing this file.
getFilename [line 1097]
Returns the absolute filename of this file.
getFixableCount [line 1025]
Returns the number of fixable errors/warnings raised.
getFixedCount [line 1037]
Returns the number of fixed errors/warnings.
getIgnoredLines [line 1049]
Returns the list of ignored lines.
getMemberProperties [line 1446]
array getMemberProperties(
int
$stackPtr)
|
|
Returns the visibility and implementation properties of the class member variable found at the specified position in the stack. The format of the array is: array(
'scope' => 'public', // public protected or protected
'is_static' => false, // true if the static keyword was found.
);
Parameters:
getMethodParameters [line 1180]
array getMethodParameters(
int
$stackPtr)
|
|
Returns the method parameters for the specified function token. Each parameter is in the following format: 0 => array(
'name' => '$var', // The variable name.
'token' => integer, // The stack pointer to the variable name.
'content' => string, // The full content of the variable definition.
'pass_by_reference' => boolean, // Is the variable passed by reference?
'variable_length' => boolean, // Is the param of variable length through use of `...` ?
'type_hint' => string, // The type hint for the variable.
'nullable_type' => boolean, // Is the variable using a nullable type?
)
Parameters with default values have an additional array index of 'default' with the value of the default as a string.
Parameters:
getMethodProperties [line 1349]
array getMethodProperties(
int
$stackPtr)
|
|
Returns the visibility and implementation properties of a method. The format of the array is: array(
'scope' => 'public', // public protected or protected
'scope_specified' => true, // true is scope keyword was found.
'is_abstract' => false, // true if the abstract keyword was found.
'is_final' => false, // true if the final keyword was found.
'is_static' => false, // true if the static keyword was found.
);
Parameters:
getMetrics [line 1085]
Returns the metrics found while processing this file.
getSuccessCount [line 1013]
Returns the number of successes recorded.
getTokens [line 557]
Returns the token stack for this file.
getTokensAsString [line 1728]
string getTokensAsString(
int
$start, int
$length)
|
|
Returns the content of the tokens from the specified start position in the token stack for the specified length.
Parameters:
getWarningCount [line 1001]
Returns the number of warnings raised.
getWarnings [line 1073]
Returns the warnings raised from processing this file.
hasCondition [line 2101]
boolean hasCondition(
int
$stackPtr, int|array
$types)
|
|
Determine if the passed token has a condition of one of the passed types.
Parameters:
isReference [line 1596]
boolean isReference(
int
$stackPtr)
|
|
Determine if the passed token is a reference operator. Returns true if the specified token position represents a reference. Returns false if the token represents a bitwise operator.
Parameters:
parse [line 497]
Tokenizes the file and prepares it for the test run.
process [line 292]
Starts the stack traversal and tells listeners when tokens are found.
Overridden in child classes as:
- LocalFile::process()
- Processes the file.
recordMetric [line 967]
boolean recordMetric(
int
$stackPtr, string
$metric, string
$value)
|
|
Adds an warning to the warning stack.
Parameters:
reloadContent [line 269]
Reloads the content of the file. By default, we have no idea where our content comes from, so we can't do anything.
Overridden in child classes as:
- LocalFile::reloadContent()
- Loads the latest version of the file's content from the file system.
setContent [line 246]
void setContent(
string
$content)
|
|
Set the content of the file. Setting the content also calculates the EOL char being used.
Parameters:
Documentation generated on Mon, 11 Mar 2019 15:27:27 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.
|
|