PHP Class PHP_CodeSniffer_Fixer, PHP_CodeSniffer

Provides helper functions that act upon a token array and modify the file content.
Afficher le fichier Open project: squizlabs/php_codesniffer Class Usage Examples

Méthodes publiques

Свойство Type Description
$enabled boolean Sniffs should check this value to ensure they are not doing extra processing to prepare for a fix when fixing is not required.
$loops integer The number of times we have looped over a file.

Méthodes publiques

Méthode Description
addContent ( integer $stackPtr, string $content ) : boolean Adds content to the end of a token's current content.
addContentBefore ( integer $stackPtr, string $content ) : boolean Adds content to the start of a token's current content.
addNewline ( integer $stackPtr ) : boolean Adds a newline to end of a token's content.
addNewlineBefore ( integer $stackPtr ) : boolean Adds a newline to the start of a token's content.
beginChangeset ( ) : void Start recording actions for a changeset.
endChangeset ( ) : boolean Stop recording actions for a changeset, and apply logged changes.
fixFile ( ) : boolean Attempt to fix the file by processing it until no fixes are made.
generateDiff ( string $filePath = null, boolean $colors = true ) : string Generates a text diff of the original file and the new content.
getContents ( ) : string Get the current content of the file, as a string.
getFixCount ( ) : integer Get a count of fixes that have been performed on the file.
getTokenContent ( integer $stackPtr ) : string Get the current fixed content of a token.
replaceToken ( integer $stackPtr, string $content ) : boolean Replace the entire contents of a token.
revertToken ( integer $stackPtr ) : boolean Reverts the previous fix made to a token.
rollbackChangeset ( ) : void Stop recording actions for a changeset, and discard logged changes.
startFile ( PHP_CodeSniffer_File $phpcsFile ) : void Starts fixing a new file.
substrToken ( integer $stackPtr, integer $start, integer $length = null ) : boolean Replace the content of a token with a part of its current content.

Method Details

addContent() public méthode

Adds content to the end of a token's current content.
public addContent ( integer $stackPtr, string $content ) : boolean
$stackPtr integer The position of the token in the token stack.
$content string The content to add.
Résultat boolean If the change was accepted.

addContentBefore() public méthode

Adds content to the start of a token's current content.
public addContentBefore ( integer $stackPtr, string $content ) : boolean
$stackPtr integer The position of the token in the token stack.
$content string The content to add.
Résultat boolean If the change was accepted.

addNewline() public méthode

Adds a newline to end of a token's content.
public addNewline ( integer $stackPtr ) : boolean
$stackPtr integer The position of the token in the token stack.
Résultat boolean If the change was accepted.

addNewlineBefore() public méthode

Adds a newline to the start of a token's content.
public addNewlineBefore ( integer $stackPtr ) : boolean
$stackPtr integer The position of the token in the token stack.
Résultat boolean If the change was accepted.

beginChangeset() public méthode

Start recording actions for a changeset.
public beginChangeset ( ) : void
Résultat void

endChangeset() public méthode

Stop recording actions for a changeset, and apply logged changes.
public endChangeset ( ) : boolean
Résultat boolean

fixFile() public méthode

Attempt to fix the file by processing it until no fixes are made.
public fixFile ( ) : boolean
Résultat boolean

generateDiff() public méthode

Generates a text diff of the original file and the new content.
public generateDiff ( string $filePath = null, boolean $colors = true ) : string
$filePath string Optional file path to diff the file against. If not specified, the original version of the file will be used.
$colors boolean Print colored output or not.
Résultat string

getContents() public méthode

Get the current content of the file, as a string.
public getContents ( ) : string
Résultat string

getFixCount() public méthode

This value is reset every time a new file is started, or an existing file is restarted.
public getFixCount ( ) : integer
Résultat integer

getTokenContent() public méthode

This function takes changesets into account so should be used instead of directly accessing the token array.
public getTokenContent ( integer $stackPtr ) : string
$stackPtr integer The position of the token in the token stack.
Résultat string

replaceToken() public méthode

Replace the entire contents of a token.
public replaceToken ( integer $stackPtr, string $content ) : boolean
$stackPtr integer The position of the token in the token stack.
$content string The new content of the token.
Résultat boolean If the change was accepted.

revertToken() public méthode

Reverts the previous fix made to a token.
public revertToken ( integer $stackPtr ) : boolean
$stackPtr integer The position of the token in the token stack.
Résultat boolean If a change was reverted.

rollbackChangeset() public méthode

Stop recording actions for a changeset, and discard logged changes.
public rollbackChangeset ( ) : void
Résultat void

startFile() public méthode

Starts fixing a new file.
public startFile ( PHP_CodeSniffer_File $phpcsFile ) : void
$phpcsFile PHP_CodeSniffer_File The file being fixed.
Résultat void

substrToken() public méthode

Replace the content of a token with a part of its current content.
public substrToken ( integer $stackPtr, integer $start, integer $length = null ) : boolean
$stackPtr integer The position of the token in the token stack.
$start integer The first character to keep.
$length integer The number of chacters to keep. If NULL, the content of the token from $start to the end of the content is kept.
Résultat boolean If the change was accepted.

Property Details

$enabled public_oe property

Sniffs should check this value to ensure they are not doing extra processing to prepare for a fix when fixing is not required.
public bool $enabled
Résultat boolean

$loops public_oe property

The number of times we have looped over a file.
public int $loops
Résultat integer