🔥码云GVP开源项目 12k star Uniapp+ElementUI 功能强大 支持多语言、二开方便! 广告
# C.71 PHPCPDTask This task runs [phpcpd](http://github.com/sebastianbergmann/phpcpd/), a Copy/Paste Detector (CPD) for PHP Code. You need an installed version of this software to use this task. **NB:** if you have installed the PHPCPD PHAR, make sure you set the `pharlocation` attribute! Table C.93:聽Attributes NameTypeDescriptionDefaultRequired`file``String`Path to source file or pathn/aOnly when there are *no* nested `fileset` elements`minTokens``Integer`Sets the minimum number of identical tokens (default: 70)70No`minLines``Integer`Sets the minimum number of identical lines (default: 5)5No`format``String`The format for the report when no nested formatter is used.defaultNo`fuzzy``Boolean`If fuzzy is set to true, the task will perform a fuzzy match.falseNo`pharlocation``String`Location of the PHPCPD PHAR package.n/aNo C.71.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.71.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.94:聽Attributes NameTypeDescriptionDefaultRequired`type``String`The output format. Accepts the same values as the `format` attribute (`default`, `pmd`).n/aYes`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/aYes