C.53 PHPMDTask
Prev | Appendix C. Optional tasks | Next

## C.53 PHPMDTask

This task runs phpmd, a Project Mess Detector (PMD) for PHP Code. You need an installed version of this software to use this task.

Table C.73: Attributes

Name | Type | Description | Default | Required
--- | --- | --- | --- | ---
`file` | `String` | Path to source file or path | n/a | Only when there are no nested `fileset` elements
`rulesets` | `String` | Sets the rulesets used for analyzing the source code | codesize, unusedcode | No
`minimumPriority` | `Integer` | The minimum priority for rules to load. | 5 | No
`allowedFileExtensions` | `String` | Comma-separated list of valid file extensions (without dot) for analyzed files. | php | No
`ignorePatterns` | `String` | Comma-separated list of directory patterns to ignore. | `.git`, `.svn`, `CVS`, `.bzr`, `.hg` | No
`format` | `String` | The format for the report when no nested formatter is used. | text | No

### C.53.1 Example

    <phpmd file="path/to/source.php"/>

Checking syntax of one particular source file. Sending Text-Report to STDOUT.

    <phpmd file="path/to/source">
       <formatter type="html" outfile="reports/pmd.html"/>
     </phpmd>

Checking syntax of source files in the given path.

    <phpmd>
       <fileset dir="${builddir}">
         <include name="apps/**/*.php" />
         <include name="lib/de/**/*.php" />
       </fileset>
       <formatter type="xml" outfile="reports/pmd.xml"/>
     </phpmd>

Checking syntax of source files in the fileset pathes.

### C.53.2 Supported Nested Tags

- `fileset`

  This nested tag is required when the `file` attribute is not set.

- `formatter`

  The results of the analysis can be printed in different formats. Output will always be sent to STDOUT, unless you set the `usefile` attribute to `true` and set an filename in the `outfile` attribute.

  Table C.74: Attributes

  Name | Type | Description | Default | Required
  --- | --- | --- | --- | ---
  `type` | `String` | The output format. Accepts the same values as the `format` attribute (`xml`, `html`, `text`). | n/a | Yes
  `usefile` | `Boolean` | Boolean that determines whether output should be sent to a file. | `true` | No
  `outfile` | `String` | Path to write output file to. | n/a | Yes

Prev | Up | Next
C.52 PHPLocTask | Home | C.54 PhpDependTask