@@ 32-40 (lines=9) @@ | ||
29 | * |
|
30 | * @return void |
|
31 | */ |
|
32 | public function testFunctionsThatShouldntBeFlagged() |
|
33 | { |
|
34 | $file = $this->sniffFile(self::TEST_FILE, '5.3'); |
|
35 | ||
36 | $this->assertNoViolation($file, 4); |
|
37 | $this->assertNoViolation($file, 5); |
|
38 | $this->assertNoViolation($file, 6); |
|
39 | $this->assertNoViolation($file, 7); |
|
40 | } |
|
41 | ||
42 | ||
43 | /** |
@@ 31-38 (lines=8) @@ | ||
28 | * |
|
29 | * @return void |
|
30 | */ |
|
31 | public function testForbiddenSwitchWithMultipleDefaultBlocks($line) |
|
32 | { |
|
33 | $file = $this->sniffFile(self::TEST_FILE, '5.6'); |
|
34 | $this->assertNoViolation($file, $line); |
|
35 | ||
36 | $file = $this->sniffFile(self::TEST_FILE, '7.0'); |
|
37 | $this->assertError($file, $line, 'Switch statements can not have multiple default blocks since PHP 7.0'); |
|
38 | } |
|
39 | ||
40 | /** |
|
41 | * Data provider. |
@@ 31-38 (lines=8) @@ | ||
28 | * |
|
29 | * @return void |
|
30 | */ |
|
31 | public function testLateStaticBinding($line) |
|
32 | { |
|
33 | $file = $this->sniffFile(self::TEST_FILE, '5.2'); |
|
34 | $this->assertError($file, $line, 'Late static binding is not supported in PHP 5.2 or earlier.'); |
|
35 | ||
36 | $file = $this->sniffFile(self::TEST_FILE, '5.3'); |
|
37 | $this->assertNoViolation($file, $line); |
|
38 | } |
|
39 | ||
40 | /** |
|
41 | * Data provider. |
@@ 28-34 (lines=7) @@ | ||
25 | * |
|
26 | * @return void |
|
27 | */ |
|
28 | public function testValidDirective() |
|
29 | { |
|
30 | $file = $this->sniffFile(self::TEST_FILE); |
|
31 | $this->assertNoViolation($file, 57); |
|
32 | $this->assertNoViolation($file, 58); |
|
33 | $this->assertNoViolation($file, 133); |
|
34 | } |
|
35 | ||
36 | /** |
|
37 | * testDeprecatedForbiddenDirectives |
@@ 28-36 (lines=9) @@ | ||
25 | * |
|
26 | * @return void |
|
27 | */ |
|
28 | public function testFunctionThatShouldntBeFlagged() |
|
29 | { |
|
30 | $file = $this->sniffFile(self::TEST_FILE, '5.1'); |
|
31 | ||
32 | $this->assertNoViolation($file, 2); |
|
33 | $this->assertNoViolation($file, 3); |
|
34 | $this->assertNoViolation($file, 4); |
|
35 | $this->assertNoViolation($file, 5); |
|
36 | } |
|
37 | ||
38 | ||
39 | /** |
@@ 31-38 (lines=8) @@ | ||
28 | * |
|
29 | * @return void |
|
30 | */ |
|
31 | public function testEmptyNonVariable($line) |
|
32 | { |
|
33 | $file = $this->sniffFile(self::TEST_FILE, '5.4'); |
|
34 | $this->assertError($file, $line, 'Only variables can be passed to empty() prior to PHP 5.5.'); |
|
35 | ||
36 | $file = $this->sniffFile(self::TEST_FILE, '5.5'); |
|
37 | $this->assertNoViolation($file, $line); |
|
38 | } |
|
39 | ||
40 | /** |
|
41 | * Data provider. |
@@ 27-34 (lines=8) @@ | ||
24 | * |
|
25 | * @return void |
|
26 | */ |
|
27 | public function testDirMagicConstant() |
|
28 | { |
|
29 | $file = $this->sniffFile(self::TEST_FILE, '5.2'); |
|
30 | $this->assertError($file, 3, "__DIR__ magic constant is not present in PHP version 5.2 or earlier"); |
|
31 | ||
32 | $file = $this->sniffFile(self::TEST_FILE, '5.3'); |
|
33 | $this->assertNoViolation($file, 3); |
|
34 | } |
|
35 | ||
36 | /** |
|
37 | * Test insteadof |
|
@@ 62-69 (lines=8) @@ | ||
59 | * |
|
60 | * @return void |
|
61 | */ |
|
62 | public function testNamespaceKeyword() |
|
63 | { |
|
64 | $file = $this->sniffFile(self::TEST_FILE, '5.2'); |
|
65 | $this->assertError($file, 20, "\"namespace\" keyword is not present in PHP version 5.2 or earlier"); |
|
66 | ||
67 | $file = $this->sniffFile(self::TEST_FILE, '5.3'); |
|
68 | $this->assertNoViolation($file, 20); |
|
69 | } |
|
70 | ||
71 | /** |
|
72 | * testNamespaceConstant |
|
@@ 78-85 (lines=8) @@ | ||
75 | * |
|
76 | * @return void |
|
77 | */ |
|
78 | public function testNamespaceConstant() |
|
79 | { |
|
80 | $file = $this->sniffFile(self::TEST_FILE, '5.2'); |
|
81 | $this->assertError($file, 22, "__NAMESPACE__ magic constant is not present in PHP version 5.2 or earlier"); |
|
82 | ||
83 | $file = $this->sniffFile(self::TEST_FILE, '5.3'); |
|
84 | $this->assertNoViolation($file, 22); |
|
85 | } |
|
86 | ||
87 | /** |
|
88 | * Test trait keyword |
|
@@ 94-101 (lines=8) @@ | ||
91 | * |
|
92 | * @return void |
|
93 | */ |
|
94 | public function testTraitKeyword() |
|
95 | { |
|
96 | $file = $this->sniffFile(self::TEST_FILE, '5.3'); |
|
97 | $this->assertError($file, 24, "\"trait\" keyword is not present in PHP version 5.3 or earlier"); |
|
98 | ||
99 | $file = $this->sniffFile(self::TEST_FILE, '5.4'); |
|
100 | $this->assertNoViolation($file, 24); |
|
101 | } |
|
102 | ||
103 | /** |
|
104 | * Test trait magic constant |
|
@@ 110-117 (lines=8) @@ | ||
107 | * |
|
108 | * @return void |
|
109 | */ |
|
110 | public function testTraitConstant() |
|
111 | { |
|
112 | $file = $this->sniffFile(self::TEST_FILE, '5.3'); |
|
113 | $this->assertError($file, 26, "__TRAIT__ magic constant is not present in PHP version 5.3 or earlier"); |
|
114 | ||
115 | $file = $this->sniffFile(self::TEST_FILE, '5.4'); |
|
116 | $this->assertNoViolation($file, 26); |
|
117 | } |
|
118 | ||
119 | /** |
|
120 | * Test the use keyword |
|
@@ 126-133 (lines=8) @@ | ||
123 | * |
|
124 | * @return void |
|
125 | */ |
|
126 | public function testUse() |
|
127 | { |
|
128 | $file = $this->sniffFile(self::TEST_FILE, '5.2'); |
|
129 | $this->assertError($file, 14, "\"use\" keyword (for traits/namespaces/anonymous functions) is not present in PHP version 5.2 or earlier"); |
|
130 | ||
131 | $file = $this->sniffFile(self::TEST_FILE, '5.3'); |
|
132 | $this->assertNoViolation($file, 14); |
|
133 | } |
|
134 | ||
135 | /** |
|
136 | * Test yield |
|
@@ 142-149 (lines=8) @@ | ||
139 | * |
|
140 | * @return void |
|
141 | */ |
|
142 | public function testYield() |
|
143 | { |
|
144 | $file = $this->sniffFile(self::TEST_FILE, '5.4'); |
|
145 | $this->assertError($file, 33, "\"yield\" keyword (for generators) is not present in PHP version 5.4 or earlier"); |
|
146 | ||
147 | $file = $this->sniffFile(self::TEST_FILE, '5.5'); |
|
148 | $this->assertNoViolation($file, 33); |
|
149 | } |
|
150 | ||
151 | /** |
|
152 | * testFinally |
|
@@ 158-165 (lines=8) @@ | ||
155 | * |
|
156 | * @return void |
|
157 | */ |
|
158 | public function testFinally() |
|
159 | { |
|
160 | $file = $this->sniffFile(self::TEST_FILE, '5.4'); |
|
161 | $this->assertError($file, 9, "\"finally\" keyword (in exception handling) is not present in PHP version 5.4 or earlier"); |
|
162 | ||
163 | $file = $this->sniffFile(self::TEST_FILE, '5.5'); |
|
164 | $this->assertNoViolation($file, 9); |
|
165 | } |
|
166 | ||
167 | /** |
|
168 | * testNowdoc |
|
@@ 227-234 (lines=8) @@ | ||
224 | * |
|
225 | * @return void |
|
226 | */ |
|
227 | public function testGoto() |
|
228 | { |
|
229 | $file = $this->sniffFile(self::TEST_FILE, '5.2'); |
|
230 | $this->assertError($file, 52, "\"goto\" keyword is not present in PHP version 5.2 or earlier"); |
|
231 | ||
232 | $file = $this->sniffFile(self::TEST_FILE, '5.3'); |
|
233 | $this->assertNoViolation($file, 52); |
|
234 | } |
|
235 | ||
236 | /** |
|
237 | * testHaltCompiler |
@@ 42-49 (lines=8) @@ | ||
39 | * |
|
40 | * @return void |
|
41 | */ |
|
42 | public function testGroupUseDeclaration($line) |
|
43 | { |
|
44 | $file = $this->sniffFile(self::TEST_FILE, '5.6'); |
|
45 | $this->assertError($file, $line, 'Group use declarations are not allowed in PHP 5.6 or earlier'); |
|
46 | ||
47 | $file = $this->sniffFile(self::TEST_FILE, '7.0'); |
|
48 | $this->assertNoViolation($file, $line); |
|
49 | } |
|
50 | ||
51 | /** |
|
52 | * Data provider. |
@@ 29-36 (lines=8) @@ | ||
26 | * |
|
27 | * @return void |
|
28 | */ |
|
29 | public function testNamespaceSeparator() |
|
30 | { |
|
31 | $file = $this->sniffFile(self::TEST_FILE, '5.2'); |
|
32 | $this->assertError($file, 3, 'the \ operator (for namespaces) is not present in PHP version 5.2 or earlier'); |
|
33 | ||
34 | $file = $this->sniffFile(self::TEST_FILE, '5.3'); |
|
35 | $this->assertNoViolation($file, 3); |
|
36 | } |
|
37 | ||
38 | /** |
|
39 | * testPow |
|
@@ 45-52 (lines=8) @@ | ||
42 | * |
|
43 | * @return void |
|
44 | */ |
|
45 | public function testPow() |
|
46 | { |
|
47 | $file = $this->sniffFile(self::TEST_FILE, '5.5'); |
|
48 | $this->assertError($file, 5, "power operator (**) is not present in PHP version 5.5 or earlier"); |
|
49 | ||
50 | $file = $this->sniffFile(self::TEST_FILE, '5.6'); |
|
51 | $this->assertNoViolation($file, 5); |
|
52 | } |
|
53 | ||
54 | /** |
|
55 | * testPowEquals |
|
@@ 61-68 (lines=8) @@ | ||
58 | * |
|
59 | * @return void |
|
60 | */ |
|
61 | public function testPowEquals() |
|
62 | { |
|
63 | $file = $this->sniffFile(self::TEST_FILE, '5.5'); |
|
64 | $this->assertError($file, 6, "power assignment operator (**=) is not present in PHP version 5.5 or earlier"); |
|
65 | ||
66 | $file = $this->sniffFile(self::TEST_FILE, '5.6'); |
|
67 | $this->assertNoViolation($file, 6); |
|
68 | } |
|
69 | ||
70 | /** |
|
71 | * testSpaceship |
|
@@ 77-84 (lines=8) @@ | ||
74 | * |
|
75 | * @return void |
|
76 | */ |
|
77 | public function testSpaceship() |
|
78 | { |
|
79 | $file = $this->sniffFile(self::TEST_FILE, '5.6'); |
|
80 | $this->assertError($file, 12, "spaceship operator (<=>) is not present in PHP version 5.6 or earlier"); |
|
81 | ||
82 | $file = $this->sniffFile(self::TEST_FILE, '7.0'); |
|
83 | $this->assertNoViolation($file, 12); |
|
84 | } |
|
85 | ||
86 | /** |
|
87 | * Coalescing operator |
|
@@ 111-118 (lines=8) @@ | ||
108 | * |
|
109 | * @return void |
|
110 | */ |
|
111 | public function testEllipsis() |
|
112 | { |
|
113 | $file = $this->sniffFile(self::TEST_FILE, '5.5'); |
|
114 | $this->assertError($file, 14, "variadic functions using ... is not present in PHP version 5.5 or earlier"); |
|
115 | ||
116 | $file = $this->sniffFile(self::TEST_FILE, '5.6'); |
|
117 | $this->assertNoViolation($file, 14); |
|
118 | } |
|
119 | } |
|
120 |
@@ 31-38 (lines=8) @@ | ||
28 | * |
|
29 | * @return void |
|
30 | */ |
|
31 | public function testConstantArraysUsingDefine($line) |
|
32 | { |
|
33 | $file = $this->sniffFile(self::TEST_FILE, '7.0'); |
|
34 | $this->assertNoViolation($file, $line); |
|
35 | ||
36 | $file = $this->sniffFile(self::TEST_FILE, '5.6'); |
|
37 | $this->assertError($file, $line, 'Constant arrays using define are not allowed in PHP 5.6 or earlier'); |
|
38 | } |
|
39 | ||
40 | /** |
|
41 | * Data provider dataConstantArraysUsingDefine. |
@@ 27-34 (lines=8) @@ | ||
24 | * |
|
25 | * @return void |
|
26 | */ |
|
27 | public function testArrayDereferencing() |
|
28 | { |
|
29 | $file = $this->sniffFile(self::TEST_FILE, '5.3'); |
|
30 | $this->assertError($file, 3, 'Function array dereferencing is not present in PHP version 5.3 or earlier'); |
|
31 | ||
32 | $file = $this->sniffFile(self::TEST_FILE, '5.4'); |
|
33 | $this->assertNoViolation($file, 3); |
|
34 | } |
|
35 | ||
36 | ||
37 | /** |
@@ 33-42 (lines=10) @@ | ||
30 | * |
|
31 | * @return void |
|
32 | */ |
|
33 | public function testParameterShadowSuperGlobal($superglobal, $line) |
|
34 | { |
|
35 | ||
36 | $file = $this->sniffFile(self::TEST_FILE, '5.3'); |
|
37 | $this->assertNoViolation($file, $line); |
|
38 | ||
39 | ||
40 | $file = $this->sniffFile(self::TEST_FILE, '5.4'); |
|
41 | $this->assertError($file, $line, "Parameter shadowing super global ({$superglobal}) causes fatal error since PHP 5.4"); |
|
42 | } |
|
43 | ||
44 | /** |
|
45 | * dataParameterShadowSuperGlobals |