Completed
Pull Request — master (#229)
by Juliette
03:02
created

dataArrayDereferencing()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 6

Duplication

Lines 8
Ratio 100 %

Importance

Changes 0
Metric Value
dl 8
loc 8
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 6
nc 1
nop 0
1
<?php
2
/**
3
 * New function array dereferencing sniff test file
4
 *
5
 * @package PHPCompatibility
6
 */
7
8
9
/**
10
 * New function array dereferencing sniff tests
11
 *
12
 * @uses BaseSniffTest
13
 * @package PHPCompatibility
14
 * @author Wim Godden <[email protected]>
15
 */
16
class NewFunctionArrayDereferencingSniffTest extends BaseSniffTest
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
17
{
18
    const TEST_FILE = 'sniff-examples/new_function_array_dereferencing.php';
19
20
    /**
21
     * testArrayDereferencing
22
     *
23
     * @group functionArrayDereferencing
24
     *
25
     * @dataProvider dataArrayDereferencing
26
     *
27
     * @param int $line Line number with valid code.
28
     *
29
     * @return void
30
     */
31 View Code Duplication
    public function testArrayDereferencing($line)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
32
    {
33
        $file = $this->sniffFile(self::TEST_FILE, '5.3');
34
        $this->assertError($file, $line, 'Function array dereferencing is not present in PHP version 5.3 or earlier');
35
36
        $file = $this->sniffFile(self::TEST_FILE, '5.4');
37
        $this->assertNoViolation($file, $line);
38
    }
39
40
    /**
41
     * dataArrayDereferencing
42
     *
43
     * @see testArrayDereferencing()
44
     *
45
     * @return array
46
     */
47 View Code Duplication
    public function dataArrayDereferencing() {
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
48
        return array(
49
            array(3),
50
            array(14),
51
            array(15),
52
            array(16),
53
        );
54
    }
55
56
57
    /**
58
     * testNoViolation
59
     *
60
     * @group functionArrayDereferencing
61
     *
62
     * @dataProvider dataNoViolation
63
     *
64
     * @param int $line Line number with valid code.
65
     *
66
     * @return void
67
     */
68
    public function testNoViolation($line)
69
    {
70
        $file = $this->sniffFile(self::TEST_FILE, '5.2');
71
        $this->assertNoViolation($file, $line);
72
    }
73
74
    /**
75
     * dataNoViolation
76
     *
77
     * @see testNoViolation()
78
     *
79
     * @return array
80
     */
81 View Code Duplication
    public function dataNoViolation() {
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
82
        return array(
83
            array(5),
84
            array(8),
85
            array(9),
86
            array(10),
87
            array(11),
88
            array(19),
89
        );
90
    }
91
}
92