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 |
||
16 | class ForbiddenFunctionParametersWithSameNameSniffTest extends BaseSniffTest |
||
17 | { |
||
18 | /** |
||
19 | * testSettingTestVersion |
||
20 | * |
||
21 | * @group forbiddenFunctionParamsSameName |
||
22 | * |
||
23 | * @return void |
||
24 | */ |
||
25 | public function testSettingTestVersion() |
||
26 | { |
||
27 | $file = $this->sniffFile('sniff-examples/forbidden_function_parameters_with_same_name.php', '5.6'); |
||
28 | $this->assertNoViolation($file, 3); |
||
29 | |||
30 | $file = $this->sniffFile('sniff-examples/forbidden_function_parameters_with_same_name.php', '7.0'); |
||
31 | $this->assertError($file, 3, 'Functions can not have multiple parameters with the same name since PHP 7.0'); |
||
32 | } |
||
33 | } |
||
34 | |||
35 |