Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.
Common duplication problems, and corresponding solutions are:
1 | <?php |
||
10 | class TEnumTypeMemberTypeTest extends TestCase |
||
11 | { |
||
12 | public function testPreserveString() |
||
19 | |||
20 | public function testSetDocumentationNotOk() |
||
35 | |||
36 | View Code Duplication | public function testIsExtensibilityElementOKNoGoodnik() |
|
48 | } |
||
49 |
This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.
If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.
In this case you can add the
@ignore
PhpDoc annotation to the duplicate definition and it will be ignored.