Completed
Pull Request — master (#149)
by Juliette
02:28
created

dataDeprecatedNewReference()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 7
rs 9.4285
cc 1
eloc 4
nc 1
nop 0
1
<?php
2
/**
3
 * Deprecated new reference sniff test file
4
 *
5
 * @package PHPCompatibility
6
 */
7
8
9
/**
10
 * Deprecated new reference sniff tests
11
 *
12
 * @uses BaseSniffTest
13
 * @package PHPCompatibility
14
 * @author Jansen Price <[email protected]>
15
 */
16
class DeprecatedNewReferenceSniffTest 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/deprecated_new_reference.php';
19
20
    /**
21
     * testDeprecatedNewReference
22
     *
23
     * @dataProvider dataDeprecatedNewReference
24
     *
25
     * @param int $line The line number.
26
     *
27
     * @return void
28
     */
29
    public function testDeprecatedNewReference($line)
30
    {
31
        $file = $this->sniffFile(self::TEST_FILE, '5.2');
32
        $this->assertNoViolation($file, $line);
33
34
        $file = $this->sniffFile(self::TEST_FILE, '5.3');
35
        $this->assertWarning($file, $line, 'Assigning the return value of new by reference is deprecated in PHP 5.3');
36
37
        $file = $this->sniffFile(self::TEST_FILE, '7.0');
38
        $this->assertError($file, $line, 'Assigning the return value of new by reference is deprecated in PHP 5.3 and forbidden in PHP 7.0');
39
40
    }
41
42
    /**
43
     * Data provider.
44
     *
45
     * @see testDeprecatedNewReference()
46
     *
47
     * @return array
48
     */
49
    public function dataDeprecatedNewReference()
50
    {
51
        return array(
52
            array(9),
53
            array(10),
54
        );
55
    }
56
57
    /**
58
     * testNoReference
59
     *
60
     * @return void
61
     */
62
    public function testNoReference()
63
    {
64
        $file = $this->sniffFile(self::TEST_FILE, '7.0');
65
        $this->assertNoViolation($file, 8);
66
    }
67
68
}
69