1 | <?php |
||
16 | class NewKeywordsSniffTest extends BaseSniffTest |
||
|
|||
17 | { |
||
18 | /** |
||
19 | * Test allow_url_include |
||
20 | * |
||
21 | * @return void |
||
22 | */ |
||
23 | public function testDirMagicConstant() |
||
29 | |||
30 | /** |
||
31 | * Test insteadof |
||
32 | * |
||
33 | * @requires PHP 5.4 |
||
34 | * @return void |
||
35 | */ |
||
36 | public function testInsteadOf() |
||
37 | { |
||
38 | $file = $this->sniffFile('sniff-examples/new_keywords.php', '5.3'); |
||
39 | |||
40 | $this->assertError($file, 15, "\"insteadof\" keyword (for traits) is not present in PHP version 5.3 or earlier"); |
||
41 | } |
||
42 | |||
43 | /** |
||
44 | * Test namespace keyword |
||
45 | * |
||
46 | * @return void |
||
47 | */ |
||
48 | public function testNamespaceKeyword() |
||
54 | |||
55 | /** |
||
56 | * testNamespaceConstant |
||
57 | * |
||
58 | * @return void |
||
59 | */ |
||
60 | public function testNamespaceConstant() |
||
66 | |||
67 | /** |
||
68 | * Test trait keyword |
||
69 | * |
||
70 | * @requires PHP 5.4 |
||
71 | * @return void |
||
72 | */ |
||
73 | public function testTraitKeyword() |
||
74 | { |
||
75 | $file = $this->sniffFile('sniff-examples/new_keywords.php', '5.3'); |
||
76 | |||
77 | $this->assertError($file, 24, "\"trait\" keyword is not present in PHP version 5.3 or earlier"); |
||
78 | } |
||
79 | |||
80 | /** |
||
81 | * Test trait magic constant |
||
82 | * |
||
83 | * @requires PHP 5.4 |
||
84 | * @return void |
||
85 | */ |
||
86 | public function testTraitConstant() |
||
87 | { |
||
88 | $file = $this->sniffFile('sniff-examples/new_keywords.php', '5.3'); |
||
89 | |||
90 | $this->assertError($file, 26, "__TRAIT__ magic constant is not present in PHP version 5.3 or earlier"); |
||
91 | } |
||
92 | |||
93 | /** |
||
94 | * Test the use keyword |
||
95 | * |
||
96 | * @return void |
||
97 | */ |
||
98 | public function testUse() |
||
104 | |||
105 | /** |
||
106 | * Test yield |
||
107 | * |
||
108 | * @requires PHP 5.5 |
||
109 | * @return void |
||
110 | */ |
||
111 | public function testYield() |
||
112 | { |
||
113 | $file = $this->sniffFile('sniff-examples/new_keywords.php', '5.4'); |
||
114 | |||
115 | $this->assertError($file, 33, "\"yield\" keyword (for generators) is not present in PHP version 5.4 or earlier"); |
||
116 | } |
||
117 | |||
118 | /** |
||
119 | * testFinally |
||
120 | * |
||
121 | * @requires PHP 5.5 |
||
122 | * @return void |
||
123 | */ |
||
124 | public function testFinally() |
||
125 | { |
||
126 | $file = $this->sniffFile('sniff-examples/new_keywords.php', '5.4'); |
||
127 | |||
128 | $this->assertError($file, 9, "\"finally\" keyword (in exception handling) is not present in PHP version 5.4 or earlier"); |
||
129 | } |
||
130 | |||
131 | /** |
||
132 | * testNowdoc |
||
133 | * |
||
134 | * @requires PHP 5.3 |
||
135 | * @return void |
||
136 | */ |
||
137 | public function testNowdoc() |
||
144 | |||
145 | /** |
||
146 | * testConst |
||
147 | * |
||
148 | * @requires PHP 5.3 if used outside class context |
||
149 | * @return void |
||
150 | */ |
||
151 | public function testConst() |
||
159 | |||
160 | /** |
||
161 | * testHaltCompiler |
||
162 | * |
||
163 | * Usage of `__halt_compiler()` cannot be tested on its own token as the compiler will be halted... |
||
164 | * So testing that any violations created *after* the compiler is halted will not be reported. |
||
165 | * |
||
166 | * @requires PHP 5.1 |
||
167 | * @return void |
||
168 | */ |
||
169 | public function testHaltCompiler() |
||
175 | } |
||
176 |
You can fix this by adding a namespace to your class:
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.