apidoc
[ class tree: apidoc ] [ index: apidoc ] [ all elements ]

Class: Fixer

Source Location: /PHP_CodeSniffer-3.1.1/src/Fixer.php

Class Overview


A helper class for fixing errors.


Author(s):

Copyright:

  • 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600)

Variables

Methods


Inherited Variables

Inherited Methods


Class Details

[line 18]
A helper class for fixing errors.

Provides helper functions that act upon a token array and modify the file content.



[ Top ]


Class Variables

$enabled =  false

[line 30]

Is the fixer enabled and fixing a file?

Sniffs should check this value to ensure they are not doing extra processing to prepare for a fix when fixing is not required.

  • Access: public

Type:   boolean


[ Top ]

$loops =  0

[line 37]

The number of times we have looped over a file.
  • Access: public

Type:   integer


[ Top ]



Method Detail

addContent   [line 704]

bool addContent( int $stackPtr, string $content)

Adds content to the end of a token's current content.
  • Return: If the change was accepted.
  • Access: public

Parameters:

int   $stackPtr   —  The position of the token in the token stack.
string   $content   —  The content to add.

[ Top ]

addContentBefore   [line 720]

bool addContentBefore( int $stackPtr, string $content)

Adds content to the start of a token's current content.
  • Return: If the change was accepted.
  • Access: public

Parameters:

int   $stackPtr   —  The position of the token in the token stack.
string   $content   —  The content to add.

[ Top ]

addNewline   [line 673]

bool addNewline( int $stackPtr)

Adds a newline to end of a token's content.
  • Return: If the change was accepted.
  • Access: public

Parameters:

int   $stackPtr   —  The position of the token in the token stack.

[ Top ]

addNewlineBefore   [line 688]

bool addNewlineBefore( int $stackPtr)

Adds a newline to the start of a token's content.
  • Return: If the change was accepted.
  • Access: public

Parameters:

int   $stackPtr   —  The position of the token in the token stack.

[ Top ]

beginChangeset   [line 352]

void beginChangeset( )

Start recording actions for a changeset.
  • Access: public

[ Top ]

endChangeset   [line 379]

boolean endChangeset( )

Stop recording actions for a changeset, and apply logged changes.
  • Access: public

[ Top ]

fixFile   [line 140]

boolean fixFile( )

Attempt to fix the file by processing it until no fixes are made.
  • Access: public

[ Top ]

generateDiff   [line 232]

string generateDiff( [string $filePath = null], [boolean $colors = true])

Generates a text diff of the original file and the new content.
  • Access: public

Parameters:

string   $filePath   —  Optional file path to diff the file against. If not specified, the original version of the file will be used.
boolean   $colors   —  Print colored output or not.

[ Top ]

getContents   [line 316]

string getContents( )

Get the current content of the file, as a string.
  • Access: public

[ Top ]

getFixCount   [line 304]

int getFixCount( )

Get a count of fixes that have been performed on the file.

This value is reset every time a new file is started, or an existing file is restarted.

  • Access: public

[ Top ]

getTokenContent   [line 334]

string getTokenContent( int $stackPtr)

Get the current fixed content of a token.

This function takes changesets into account so should be used instead of directly accessing the token array.

  • Access: public

Parameters:

int   $stackPtr   —  The position of the token in the token stack.

[ Top ]

replaceToken   [line 464]

bool replaceToken( int $stackPtr, string $content)

Replace the entire contents of a token.
  • Return: If the change was accepted.
  • Access: public

Parameters:

int   $stackPtr   —  The position of the token in the token stack.
string   $content   —  The new content of the token.

[ Top ]

revertToken   [line 593]

bool revertToken( int $stackPtr)

Reverts the previous fix made to a token.
  • Return: If a change was reverted.
  • Access: public

Parameters:

int   $stackPtr   —  The position of the token in the token stack.

[ Top ]

rollbackChangeset   [line 426]

void rollbackChangeset( )

Stop recording actions for a changeset, and discard logged changes.
  • Access: public

[ Top ]

startFile   [line 116]

void startFile( File $phpcsFile)

Starts fixing a new file.
  • Access: public

Parameters:

\PHP_CodeSniffer\Files\File   $phpcsFile   —  The file being fixed.

[ Top ]

substrToken   [line 651]

bool substrToken( int $stackPtr, int $start, [int $length = null])

Replace the content of a token with a part of its current content.
  • Return: If the change was accepted.
  • Access: public

Parameters:

int   $stackPtr   —  The position of the token in the token stack.
int   $start   —  The first character to keep.
int   $length   —  The number of chacters to keep. If NULL, the content of the token from $start to the end of the content is kept.

[ Top ]


Documentation generated on Mon, 11 Mar 2019 15:27:29 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.