C.51 PHPCPDTask
Prev | Appendix C. Optional tasks | Next

## C.51 PHPCPDTask

This task runs phpcpd, a Copy/Paste Detector (CPD) for PHP Code. You need an installed version of this software to use this task.

Table C.70: Attributes

Name | Type | Description | Default | Required
--- | --- | --- | --- | ---
`file` | `String` | Path to source file or path | n/a | Only when there are no nested `fileset` elements
`minTokens` | `Integer` | Sets the minimum number of identical tokens (default: 70) | 70 | No
`minLines` | `Integer` | Sets the minimum number of identical lines (default: 5) | 5 | No
`format` | `String` | The format for the report when no nested formatter is used. | default | No

### C.51.1 Examples

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

Checking for copy/paste code in one particular source file. Sending Default-Report to STDOUT.

    <phpcpd file="path/to/source">
       <formatter type="pmd" outfile="reports/pmd-cpd.xml"/>
     </phpcpd>

Checking for copy/paste code in files of the given path.

    <phpcpd>
       <fileset dir="${builddir}" id="filestocpd">
         <include name="apps/**/*.php" />
         <include name="lib/de/**/*.php" />
         <include name="lib/task/**/*.php" />
         <include name="lib/services/**/*.php" />
         <include name="lib/form/**/*.php" />
         <include name="lib/model/**/*.php" />
       </fileset>
       <formatter type="pmd" outfile="reports/pmd-cpd.xml"/>
     </phpcpd>

### C.51.2 Supported Nested Tags

- `fileset`

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

- `formatter`

  The results of the copy/paste scan can be printed in different formats. Output will always be sent to a file, unless you set the `usefile` attribute to `false`.

  Table C.71: Attributes

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

Prev | Up | Next
C.50 PhpCodeSnifferTask | Home | C.52 PHPLocTask