classes/phing/tasks/ext/PhpCodeSnifferTask.php

A PHP code sniffer task. Checking the style of one or more PHP source files.

author
Dirk Thomas
package
phing.tasks.ext
version
$Id: PhpCodeSnifferTask.php 1257 2011-08-08 12:29:41Z mrook $

\PhpCodeSnifferTask

A PHP code sniffer task. Checking the style of one or more PHP source files.

Use {@link Project#createTask} to register a new Task.

Extends from
\Task
author
Dirk Thomas
copyright
2001,2002 THYRELL. All rights reserved
package
phing.tasks.ext
version
$Id: PhpCodeSnifferTask.php 1257 2011-08-08 12:29:41Z mrook $

Properties

Propertyprotected  $allowedFileExtensions= 'array'
Default valuearrayDetails
Type
Propertyprotected  $configData= 'array'
Default valuearrayDetails
Type
Propertyprotected\PhingFile  $docFile= 'null'

Holds the outfile for the documentation

Default valuenullDetails
Type
\PhingFile
Propertyprotectedstring  $docGenerator= ''

Holds the type of the doc generator

Details
Type
string
Propertyprotected  $file= ''
Details
Type
Propertyprotected  $filesets= 'array'
Default valuearrayDetails
Type
Propertyprotected  $format= 'default'
Default valuedefaultDetails
Type
Propertyprotected  $formatters= 'array'
Default valuearrayDetails
Type
Propertyprivate  $haltonerror= 'false'
Default valuefalseDetails
Type
Propertyprivate  $haltonwarning= 'false'
Default valuefalseDetails
Type
Propertyprotected  $ignorePatterns= 'false'
Default valuefalseDetails
Type
Propertyprotected  $noSubdirectories= 'false'
Default valuefalseDetails
Type
Propertyprotected  $reportWidth= '80'
Default value80Details
Type
Propertyprotected  $showSniffs= 'false'
Default valuefalseDetails
Type
Propertyprotected  $showSources= 'false'
Default valuefalseDetails
Type
Propertyprotected  $showWarnings= 'true'
Default valuetrueDetails
Type
Propertyprivate  $skipVersionCheck= 'false'
Default valuefalseDetails
Type
Propertyprotected  $sniffs= 'array'
Default valuearrayDetails
Type
Propertyprotected  $standard= 'Generic'
Default valueGenericDetails
Type
Propertyprotected  $tabWidth= '0'
Default value0Details
Type
Propertyprotected  $verbosity= '0'
Default value0Details
Type

Methods

methodpublic  createConfig( ) : \Parameter
Creates a config parameter for this task
Returns
Type Description
\Parameter
methodpublic  createFileSet( ) : \FileSet
Nested creator, creates a FileSet for this task
Returns
Type Description
\FileSet
methodpublic  createFormatter( ) : \CodeSniffer_FormatterElement
Create object for nested formatter element.
Returns
Type Description
\CodeSniffer_FormatterElement
methodpublic  init( ) : void
Load the necessary environment for running PHP_CodeSniffer.
methodpublic  main( ) :
Executes PHP code sniffer against PhingFile or a FileSet
methodprotected  outputCustomFormat( array $report ) :
Outputs the results with a custom format
Parameters
Name Type Description
$report array Packaged list of all errors in each file
methodprotected  outputCustomFormatMessages( array $messages, string $type ) :
Outputs the messages of a specific type for one file
Parameters
Name Type Description
$messages array
$type string
methodprotected  printErrorReport( \PHP_CodeSniffer $phpcs ) : int
Prints the error report.
Parameters
Name Type Description
$phpcs \PHP_CodeSniffer The PHP_CodeSniffer object containing the errors.
Returns
Type Description
int
methodpublic  setAllowedFileExtensions( array $extensions ) :
Sets the allowed file extensions when using directories instead of specific files
Parameters
Name Type Description
$extensions array
methodpublic  setDocFile( \PhingFile $file ) : void
Sets the outfile for the documentation
Parameters
Name Type Description
$file \PhingFile The outfile for the doc
methodpublic  setDocGenerator( string $generator ) : void
Sets the type of the doc generator
Parameters
Name Type Description
$generator string HTML or Text
methodpublic  setFile( \PhingFile $file ) :
File to be performed syntax check on
Parameters
Name Type Description
$file \PhingFile
methodpublic  setFormat( string $format ) :
Sets the output format
Parameters
Name Type Description
$format string
methodpublic  setHaltonerror( boolean $value ) :
Sets the haltonerror flag
Parameters
Name Type Description
$value boolean
methodpublic  setHaltonwarning( boolean $value ) :
Sets the haltonwarning flag
Parameters
Name Type Description
$value boolean
methodpublic  setIgnorePatterns(  $patterns ) :
Sets the ignore patterns to skip files when using directories instead of specific files
Parameters
Name Type Description
$patterns
methodpublic  setNoSubdirectories( boolean $subdirectories ) :
Sets the flag if subdirectories should be skipped
Parameters
Name Type Description
$subdirectories boolean
methodpublic  setReportWidth( int $width ) : void
Sets the width of the report
Parameters
Name Type Description
$width int How wide the screen reports should be.
methodpublic  setShowSniffs( boolean $show ) :
Sets the flag if the used sniffs should be listed
Parameters
Name Type Description
$show boolean
methodpublic  setShowSources( boolean $show ) : void
Sets the flag if sources should be shown
Parameters
Name Type Description
$show boolean Whether to show sources or not
methodpublic  setShowWarnings( boolean $show ) :
Sets the flag if warnings should be shown
Parameters
Name Type Description
$show boolean
methodpublic  setSkipVersionCheck( boolean $value ) :
Sets the skipversioncheck flag
Parameters
Name Type Description
$value boolean
methodpublic  setSniffs( string $sniffs ) :
Sets the sniffs which the standard should be restricted to
Parameters
Name Type Description
$sniffs string
methodpublic  setStandard( string $standard ) : void
Sets the coding standard to test for
Parameters
Name Type Description
$standard string The coding standard
methodpublic  setTabWidth( int $width ) :
Sets the tab width to replace tabs with spaces
Parameters
Name Type Description
$width int
methodpublic  setVerbosity( int $level ) :
Sets the verbosity level
Parameters
Name Type Description
$level int

\PhpCodeSnifferTask_FormatterElement

Base class for those classes that can appear inside the build file as stand alone data types.

This class handles the common description attribute and provides a default implementation for reference handling and checking for circular references that is appropriate for types that can not be nested inside elements of the same type (i.e. patternset but not path)

Extends from
\DataType
author
Andreas Aderhold
author
Hans Lellelid
package
phing.tasks.ext
version
$Revision: 526 $

Properties

Propertyprotectedstring  $outfile= ''

Output file.

Details
Type
string
Propertyprotectedstring  $type= ''

Type of output to generate

Details
Type
string
Propertyprotectedbool  $useFile= 'true'

Output to file?

Default valuetrueDetails
Type
bool

Methods

methodpublic  getOutfile( ) :
methodpublic  getType( ) :
methodpublic  getUseFile( ) :
methodpublic  parsingComplete( ) :
Validate config.
methodpublic  setOutfile(  $outfile ) :
Parameters
Name Type Description
$outfile
methodpublic  setType(  $type ) :
Parameters
Name Type Description
$type
methodpublic  setUseFile(  $useFile ) :
Parameters
Name Type Description
$useFile
Documentation was generated by DocBlox 0.13.1.