# 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
jump to top

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

`$allowedFileExtensions= 'array'`
Default value `array` Details

Type

`$configData= 'array'`
Default value `array` Details

Type

`\PhingFile $docFile= 'null'`

Holds the outfile for the documentation

Default value `null` Details

Type
  \PhingFile

`string $docGenerator= ''`

Holds the type of the doc generator

Details

Type
  string

`$file= ''`
Details

Type

`$filesets= 'array'`
Default value `array` Details

Type

`$format= 'default'`
Default value `default` Details

Type

`$formatters= 'array'`
Default value `array` Details

Type

`$haltonerror= 'false'`
Default value `false` Details

Type

`$haltonwarning= 'false'`
Default value `false` Details

Type

`$ignorePatterns= 'false'`
Default value `false` Details

Type

`$noSubdirectories= 'false'`
Default value `false` Details

Type

`$reportWidth= '80'`
Default value `80` Details

Type

`$showSniffs= 'false'`
Default value `false` Details

Type

`$showSources= 'false'`
Default value `false` Details

Type

`$showWarnings= 'true'`
Default value `true` Details

Type

`$skipVersionCheck= 'false'`
Default value `false` Details

Type

`$sniffs= 'array'`
Default value `array` Details

Type

`$standard= 'Generic'`
Default value `Generic` Details

Type

`$tabWidth= '0'`
Default value `0` Details

Type

`$verbosity= '0'`
Default value `0` Details

Type

### Methods

`createConfig( ) : \Parameter`
Creates a config parameter for this task
Returns

Type | Description
--- | ---
\Parameter |

`createFileSet( ) : \FileSet`
Nested creator, creates a FileSet for this task
Returns

Type | Description
--- | ---
\FileSet |

`createFormatter( ) : \CodeSniffer_FormatterElement`
Create object for nested formatter element.
Returns

Type | Description
--- | ---
\CodeSniffer_FormatterElement |

`init( ) : void`
Load the necessary environment for running PHP_CodeSniffer.
`main( ) :`
Executes PHP code sniffer against PhingFile or a FileSet
`outputCustomFormat( array $report ) :`
Outputs the results with a custom format
Parameters

Name | Type | Description
--- | --- | ---
$report | array | Packaged list of all errors in each file

`outputCustomFormatMessages( array $messages, string $type ) :`
Outputs the messages of a specific type for one file
Parameters

Name | Type | Description
--- | --- | ---
$messages | array |
$type | string |

`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 |

`setAllowedFileExtensions( array $extensions ) :`
Sets the allowed file extensions when using directories instead of specific files
Parameters

Name | Type | Description
--- | --- | ---
$extensions | array |

`setDocFile( \PhingFile $file ) : void`
Sets the outfile for the documentation
Parameters

Name | Type | Description
--- | --- | ---
$file | \PhingFile | The outfile for the doc

`setDocGenerator( string $generator ) : void`
Sets the type of the doc generator
Parameters

Name | Type | Description
--- | --- | ---
$generator | string | HTML or Text

`setFile( \PhingFile $file ) :`
File to be performed syntax check on
Parameters

Name | Type | Description
--- | --- | ---
$file | \PhingFile |

`setFormat( string $format ) :`
Sets the output format
Parameters

Name | Type | Description
--- | --- | ---
$format | string |

`setHaltonerror( boolean $value ) :`
Sets the haltonerror flag
Parameters

Name | Type | Description
--- | --- | ---
$value | boolean |

`setHaltonwarning( boolean $value ) :`
Sets the haltonwarning flag
Parameters

Name | Type | Description
--- | --- | ---
$value | boolean |

`setIgnorePatterns( $patterns ) :`
Sets the ignore patterns to skip files when using directories instead of specific files
Parameters

Name | Type | Description
--- | --- | ---
$patterns |  |

`setNoSubdirectories( boolean $subdirectories ) :`
Sets the flag if subdirectories should be skipped
Parameters

Name | Type | Description
--- | --- | ---
$subdirectories | boolean |

`setReportWidth( int $width ) : void`
Sets the width of the report
Parameters

Name | Type | Description
--- | --- | ---
$width | int | How wide the screen reports should be.

`setShowSniffs( boolean $show ) :`
Sets the flag if the used sniffs should be listed
Parameters

Name | Type | Description
--- | --- | ---
$show | boolean |

`setShowSources( boolean $show ) : void`
Sets the flag if sources should be shown
Parameters

Name | Type | Description
--- | --- | ---
$show | boolean | Whether to show sources or not

`setShowWarnings( boolean $show ) :`
Sets the flag if warnings should be shown
Parameters

Name | Type | Description
--- | --- | ---
$show | boolean |

`setSkipVersionCheck( boolean $value ) :`
Sets the skipversioncheck flag
Parameters

Name | Type | Description
--- | --- | ---
$value | boolean |

`setSniffs( string $sniffs ) :`
Sets the sniffs which the standard should be restricted to
Parameters

Name | Type | Description
--- | --- | ---
$sniffs | string |

`setStandard( string $standard ) : void`
Sets the coding standard to test for
Parameters

Name | Type | Description
--- | --- | ---
$standard | string | The coding standard

`setTabWidth( int $width ) :`
Sets the tab width to replace tabs with spaces
Parameters

Name | Type | Description
--- | --- | ---
$width | int |

`setVerbosity( int $level ) :`
Sets the verbosity level
Parameters

Name | Type | Description
--- | --- | ---
$level | int |

## \PhpCodeSnifferTask_FormatterElement
jump to top

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

`string $outfile= ''`

Output file.

Details

Type
  string

`string $type= ''`

Type of output to generate

Details

Type
  string

`bool $useFile= 'true'`

Output to file?

Default value `true` Details

Type
  bool

### Methods

`getOutfile( ) :`
`getType( ) :`
`getUseFile( ) :`
`parsingComplete( ) :`
Validate config.
`setOutfile( $outfile ) :`
Parameters

Name | Type | Description
--- | --- | ---
$outfile |  |

`setType( $type ) :`
Parameters

Name | Type | Description
--- | --- | ---
$type |  |

`setUseFile( $useFile ) :`
Parameters

Name | Type | Description
--- | --- | ---
$useFile |  |

Documentation was generated by DocBlox 0.13.1.