Completed
Branch feature/scrutinizer-run-tests (072b5a)
by Juliette
10:12
created

ForbiddenFunctionParametersWithSameNameSniffTest   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 18
Duplicated Lines 100 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 1
c 1
b 0
f 0
lcom 1
cbo 1
dl 18
loc 18
rs 10

How to fix   Duplicated Code   

Duplicated Code

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
2
/**
3
 * Functions can not have multiple parameters with the same name since PHP 7.0 test file
4
 *
5
 * @package PHPCompatibility
6
 */
7
8
9
/**
10
 * Functions can not have multiple parameters with the same name since PHP 7.0 sniff test
11
 *
12
 * @uses BaseSniffTest
13
 * @package PHPCompatibility
14
 * @author Wim Godden <[email protected]>
15
 */
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