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

Class: PHP_CodeSniffer

Source Location: /PHP_CodeSniffer-0.1.0/CodeSniffer.php

Class Overview


PHP_CodeSniffer provides functionality to verify that code conforms to certain standards.


Author(s):

  • Squiz Pty Ltd

Methods


Inherited Variables

Inherited Methods


Class Details

[line 57]
PHP_CodeSniffer provides functionality to verify that code conforms to certain standards.

Standards are specified by classes that implement the PHP_CodeSniffer_Sniff interface. A sniff registers what token types it wishes to listen for, then PHP_CodeSniffer encounters that token, the sniff is invoked and passed information about where the token was found in the stack, and the token stack itself.

Sniff files and their containing class must be prefixed with Sniff, and have an extension of .php.

Multiple PHP_CodeSniffer operations can be performed by re-calling the process function with different parameters.

  • Author: Squiz Pty Ltd


[ Top ]


Method Detail

__construct (Constructor)   [line 114]

PHP_CodeSniffer __construct( [boolean $verbose = false])

Constructs a PHP_CodeSniffer object.

Parameters:

boolean   $verbose   —  Show progress during the script.

[ Top ]

getFiles   [line 573]

array(PHP_CodeSniffer_File) getFiles( )

Returns the PHP_CodeSniffer file objects.
  • Access: public

[ Top ]

getInstalledStandards   [line 836]

array getInstalledStandards( )

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.


[ Top ]

isCamelCaps   [line 775]

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.
  • Access: public

Parameters:

string   $string   —  The string the verify.
boolean   $classFormat   —  If true, check to see if the string is in the class format. Class format strings must start with a capital letter and contain no underscores.
boolean   $public   —  If true, the first character in the string must be an a-z character. If false, the character must be an underscore. This argument is only applicable if $classFormat is false.
boolean   $strict   —  If true, the string must not have two captial letters next to each other. If false, a relaxed camel caps policy is used to allow for acronyms.

[ Top ]

isInstalledStandard   [line 870]

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 Sniffs subdirectory.


Parameters:

string   $standard   —  The name of the coding standard.

[ Top ]

printErrorReport   [line 403]

void printErrorReport( [boolean $showWarnings = true])

Prints all errors and warnings for each file processed.

Errors and warnings are displayed together, grouped by file.

  • Access: public

Parameters:

boolean   $showWarnings   —  Show warnings as well as errors.

[ Top ]

printErrorReportSummary   [line 492]

void printErrorReportSummary( [boolean $showWarnings = true])

Prints a summary of errors and warnings for each file processed.

If verbose output is enabled, results are shown for all files, even if they have no errors or warnings. If verbose output is disabled, we only show files that have at least one warning or error.

  • Access: public

Parameters:

boolean   $showWarnings   —  Show warnings as well as errors.

[ Top ]

process   [line 135]

void process( string|array $files, string $standard, [array $sniffs = array()])

Processes the files/directories that PHP_CodeSniffer was constructed with.
  • Throws: PHP_CodeSniffer_Exception If files or standard are invalid.
  • Access: public

Parameters:

string|array   $files   —  The files and directories to process. For directories, each sub directory will also be traversed for source files.
string   $standard   —  The set of code sniffs we are testing against.
array   $sniffs   —  The sniff names to restrict the allowed listeners to.

[ Top ]

resolveSimpleToken   [line 666]

array resolveSimpleToken( string $token)

Converts simple tokens into a format that conforms to complex tokens produced by token_get_all().

Simple tokens are tokens that are not in array form when produced from token_get_all().

  • Return: The new token in array format.
  • Access: public

Parameters:

string   $token   —  The simple token to convert.

[ Top ]

resolveTstringToken   [line 623]

array resolveTstringToken( array $token)

Converts T_STRING tokens into more usable token names.

The token should be produced using the token_get_all() function. Currently, not all T_STRING tokens are converted.

  • Return: The new token.
  • Access: public

Parameters:

string|array   $token   —  The T_STRING token to convert as constructed by token_get_all().

[ Top ]

standardiseToken   [line 591]

array standardiseToken( string|array $token)

Takes a token produced from
and produces a more uniform token.

Note that this method also resolves T_STRING tokens into more descrete types, therefore there is no need to call resolveTstringToken()

  • Return: The new token.
  • Access: public

Parameters:

string|array   $token   —  The token to convert.

[ Top ]


Documentation generated on Mon, 11 Mar 2019 14:44:37 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.