Completed
Push — master ( 21e375...72728a )
by Wim
02:21
created

testThrow()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
c 0
b 0
f 0
nc 1
nop 0
dl 0
loc 4
rs 10
1
<?php
2
/**
3
 * Forbidden names as function invocations sniff test file
4
 *
5
 * @package PHPCompatibility
6
 */
7
8
9
/**
10
 * Forbidden names as function invocations sniff test file
11
 *
12
 * @uses BaseSniffTest
13
 * @package PHPCompatibility
14
 * @author Jansen Price <[email protected]>
15
 */
16
class ForbiddenNamesAsInvokedFunctionsSniffTest extends BaseSniffTest
17
{
18
    /**
19
     * Sniffed file
20
     *
21
     * @var PHP_CodeSniffer_File
22
     */
23
    protected $_sniffFile;
24
25
    /**
26
     * setUp
27
     *
28
     * @return void
29
     */
30
    public function setUp()
31
    {
32
        parent::setUp();
33
34
        $this->_sniffFile = $this->sniffFile('sniff-examples/forbidden_names_function_invocation.php');
35
    }
36
37
    /**
38
     * TestAbstract
39
     *
40
     * @return void
41
     */
42
    public function testAbstract()
43
    {
44
        $this->assertError($this->_sniffFile, 6, "'abstract' is a reserved keyword introduced in PHP version 5.0 and cannot be invoked as a function");
45
    }
46
47
    /**
48
     * testCallable
49
     *
50
     * @return void
51
     */
52
    public function testCallable()
53
    {
54
        $this->assertError($this->_sniffFile, 7, "'callable' is a reserved keyword introduced in PHP version 5.4 and cannot be invoked as a function");
55
    }
56
57
    /**
58
     * testCatch
59
     *
60
     * @return void
61
     */
62
    public function testCatch()
63
    {
64
        $this->assertError($this->_sniffFile, 8, "'catch' is a reserved keyword introduced in PHP version 5.0 and cannot be invoked as a function");
65
    }
66
67
    /**
68
     * testClone
69
     *
70
     * @return void
71
     */
72
    public function testClone()
73
    {
74
        $this->assertError($this->_sniffFile, 9, "'clone' is a reserved keyword introduced in PHP version 5.0 and cannot be invoked as a function");
75
    }
76
77
    /**
78
     * testFinal
79
     *
80
     * @return void
81
     */
82
    public function testFinal()
83
    {
84
        $this->assertError($this->_sniffFile, 10, "'final' is a reserved keyword introduced in PHP version 5.0 and cannot be invoked as a function");
85
    }
86
87
    /**
88
     * testFinally
89
     *
90
     * TODO: Test 'finally' (PHP 5.5)
91
     *
92
     * @return void
93
     */
94
    public function testFinally()
95
    {
96
        $this->assertError($this->_sniffFile, 11, "'finally' is a reserved keyword introduced in PHP version 5.5 and cannot be invoked as a function");
97
    }
98
99
    /**
100
     * testGoto
101
     *
102
     * @return void
103
     */
104
    public function testGoto()
105
    {
106
        $this->assertError($this->_sniffFile, 12, "'goto' is a reserved keyword introduced in PHP version 5.3 and cannot be invoked as a function");
107
    }
108
109
    /**
110
     * testImplements
111
     *
112
     * @return void
113
     */
114
    public function testImplements()
115
    {
116
        $this->assertError($this->_sniffFile, 13, "'implements' is a reserved keyword introduced in PHP version 5.0 and cannot be invoked as a function");
117
    }
118
119
    /**
120
     * testInterface
121
     *
122
     * @return void
123
     */
124
    public function testInterface()
125
    {
126
        $this->assertError($this->_sniffFile, 14, "'interface' is a reserved keyword introduced in PHP version 5.0 and cannot be invoked as a function");
127
    }
128
129
    /**
130
     * testInstanceOf
131
     *
132
     * @return void
133
     */
134
    public function testInstanceOf()
135
    {
136
        $this->assertError($this->_sniffFile, 15, "'instanceof' is a reserved keyword introduced in PHP version 5.0 and cannot be invoked as a function");
137
    }
138
139
    /**
140
     * testInsteadOf
141
     *
142
     * @return void
143
     */
144
    public function testInsteadOf()
145
    {
146
        $this->assertError($this->_sniffFile, 16, "'insteadof' is a reserved keyword introduced in PHP version 5.4 and cannot be invoked as a function");
147
    }
148
149
    /**
150
     * testNamespace
151
     *
152
     * @return void
153
     */
154
    public function testNamespace()
155
    {
156
        $this->assertError($this->_sniffFile, 17, "'namespace' is a reserved keyword introduced in PHP version 5.3 and cannot be invoked as a function");
157
    }
158
159
    /**
160
     * testPrivate
161
     *
162
     * @return void
163
     */
164
    public function testPrivate()
165
    {
166
        $this->assertError($this->_sniffFile, 18, "'private' is a reserved keyword introduced in PHP version 5.0 and cannot be invoked as a function");
167
    }
168
169
    /**
170
     * testProteced
171
     *
172
     * @return void
173
     */
174
    public function testProteced()
175
    {
176
        $this->assertError($this->_sniffFile, 19, "'protected' is a reserved keyword introduced in PHP version 5.0 and cannot be invoked as a function");
177
    }
178
179
    /**
180
     * testPublic
181
     *
182
     * @return void
183
     */
184
    public function testPublic()
185
    {
186
        $this->assertError($this->_sniffFile, 20, "'public' is a reserved keyword introduced in PHP version 5.0 and cannot be invoked as a function");
187
    }
188
189
    /**
190
     * testTrait
191
     *
192
     * @return void
193
     */
194
    public function testTrait()
195
    {
196
        $this->assertError($this->_sniffFile, 22, "'trait' is a reserved keyword introduced in PHP version 5.4 and cannot be invoked as a function");
197
    }
198
199
    /**
200
     * testTry
201
     *
202
     * @return void
203
     */
204
    public function testTry()
205
    {
206
        $this->assertError($this->_sniffFile, 23, "'try' is a reserved keyword introduced in PHP version 5.0 and cannot be invoked as a function");
207
    }
208
209
    /**
210
     * testBool
211
     *
212
     * @return void
213
     */
214
    public function testBool()
215
    {
216
        $this->assertError($this->_sniffFile, 32, "'bool' is a reserved keyword introduced in PHP version 7.0 and cannot be invoked as a function");
217
    }
218
219
    /**
220
     * testInt
221
     *
222
     * @return void
223
     */
224
    public function testInt()
225
    {
226
        $this->assertError($this->_sniffFile, 33, "'int' is a reserved keyword introduced in PHP version 7.0 and cannot be invoked as a function");
227
    }
228
    
229
    /**
230
     * testFloat
231
     *
232
     * @return void
233
     */
234
    public function testFloat()
235
    {
236
        $this->assertError($this->_sniffFile, 34, "'float' is a reserved keyword introduced in PHP version 7.0 and cannot be invoked as a function");
237
    }
238
    
239
    /**
240
     * testString
241
     *
242
     * @return void
243
     */
244
    public function testString()
245
    {
246
        $this->assertError($this->_sniffFile, 35, "'string' is a reserved keyword introduced in PHP version 7.0 and cannot be invoked as a function");
247
    }
248
    
249
    /**
250
     * testNull
251
     *
252
     * @return void
253
     */
254
    public function testNull()
255
    {
256
        $this->assertError($this->_sniffFile, 36, "'null' is a reserved keyword introduced in PHP version 7.0 and cannot be invoked as a function");
257
        $this->assertError($this->_sniffFile, 37, "'null' is a reserved keyword introduced in PHP version 7.0 and cannot be invoked as a function");
258
    }
259
    
260
    /**
261
     * testTrue
262
     *
263
     * @return void
264
     */
265
    public function testTrue()
266
    {
267
        $this->assertError($this->_sniffFile, 38, "'true' is a reserved keyword introduced in PHP version 7.0 and cannot be invoked as a function");
268
        $this->assertError($this->_sniffFile, 39, "'true' is a reserved keyword introduced in PHP version 7.0 and cannot be invoked as a function");
269
    }
270
    
271
    /**
272
     * testFalse
273
     *
274
     * @return void
275
     */
276
    public function testFalse()
277
    {
278
        $this->assertError($this->_sniffFile, 40, "'false' is a reserved keyword introduced in PHP version 7.0 and cannot be invoked as a function");
279
        $this->assertError($this->_sniffFile, 41, "'false' is a reserved keyword introduced in PHP version 7.0 and cannot be invoked as a function");
280
    }
281
    
282
    /**
283
     * testResource
284
     *
285
     * @return void
286
     */
287
    public function testResource()
288
    {
289
        $this->assertError($this->_sniffFile, 42, "'resource' is a reserved keyword introduced in PHP version 7.0 and cannot be invoked as a function");
290
    }
291
    
292
    /**
293
     * testObject
294
     *
295
     * @return void
296
     */
297
    public function testObject()
298
    {
299
        $this->assertError($this->_sniffFile, 43, "'object' is a reserved keyword introduced in PHP version 7.0 and cannot be invoked as a function");
300
    }
301
    
302
    /**
303
     * testMixed
304
     *
305
     * @return void
306
     */
307
    public function testMixed()
308
    {
309
        $this->assertError($this->_sniffFile, 44, "'mixed' is a reserved keyword introduced in PHP version 7.0 and cannot be invoked as a function");
310
    }
311
312
    /**
313
     * testNumberic
314
     *
315
     * @return void
316
     */
317
    public function testNumeric()
318
    {
319
        $this->assertError($this->_sniffFile, 45, "'numeric' is a reserved keyword introduced in PHP version 7.0 and cannot be invoked as a function");
320
    }
321
    
322
    /**
323
     * Verify that checking for a specific version works
324
     *
325
     * @return void
326
     */
327
    public function testGotoInPreviousVersion()
328
    {
329
        $this->_sniffFile = $this->sniffFile('sniff-examples/forbidden_names_function_invocation.php', '5.2');
330
331
        $this->assertNoViolation($this->_sniffFile, 12);
332
    }
333
}
334