Completed
Push — php70 ( 83abde )
by Wim
04:27
created

testTrue()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 3
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 5
rs 9.4285
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
     * testThrow
191
     *
192
     * @return void
193
     */
194
    public function testThrow()
195
    {
196
        $this->assertError($this->_sniffFile, 21, "'throw' is a reserved keyword introduced in PHP version 5.0 and cannot be invoked as a function");
197
    }
198
199
    /**
200
     * testTrait
201
     *
202
     * @return void
203
     */
204
    public function testTrait()
205
    {
206
        $this->assertError($this->_sniffFile, 22, "'trait' is a reserved keyword introduced in PHP version 5.4 and cannot be invoked as a function");
207
    }
208
209
    /**
210
     * testTry
211
     *
212
     * @return void
213
     */
214
    public function testTry()
215
    {
216
        $this->assertError($this->_sniffFile, 23, "'try' is a reserved keyword introduced in PHP version 5.0 and cannot be invoked as a function");
217
    }
218
219
    /**
220
     * testBool
221
     *
222
     * @return void
223
     */
224
    public function testBool()
225
    {
226
        $this->assertError($this->_sniffFile, 32, "'bool' is a reserved keyword introduced in PHP version 7.0 and cannot be invoked as a function");
227
    }
228
229
    /**
230
     * testInt
231
     *
232
     * @return void
233
     */
234
    public function testInt()
235
    {
236
        $this->assertError($this->_sniffFile, 33, "'int' is a reserved keyword introduced in PHP version 7.0 and cannot be invoked as a function");
237
    }
238
    
239
    /**
240
     * testFloat
241
     *
242
     * @return void
243
     */
244
    public function testFloat()
245
    {
246
        $this->assertError($this->_sniffFile, 34, "'float' is a reserved keyword introduced in PHP version 7.0 and cannot be invoked as a function");
247
    }
248
    
249
    /**
250
     * testString
251
     *
252
     * @return void
253
     */
254
    public function testString()
255
    {
256
        $this->assertError($this->_sniffFile, 35, "'string' is a reserved keyword introduced in PHP version 7.0 and cannot be invoked as a function");
257
    }
258
    
259
    /**
260
     * testNull
261
     *
262
     * @return void
263
     */
264
    public function testNull()
265
    {
266
        $this->assertError($this->_sniffFile, 36, "'null' is a reserved keyword introduced in PHP version 7.0 and cannot be invoked as a function");
267
        $this->assertError($this->_sniffFile, 37, "'null' is a reserved keyword introduced in PHP version 7.0 and cannot be invoked as a function");
268
    }
269
    
270
    /**
271
     * testTrue
272
     *
273
     * @return void
274
     */
275
    public function testTrue()
276
    {
277
        $this->assertError($this->_sniffFile, 38, "'true' is a reserved keyword introduced in PHP version 7.0 and cannot be invoked as a function");
278
        $this->assertError($this->_sniffFile, 39, "'true' is a reserved keyword introduced in PHP version 7.0 and cannot be invoked as a function");
279
    }
280
    
281
    /**
282
     * testFalse
283
     *
284
     * @return void
285
     */
286
    public function testFalse()
287
    {
288
        $this->assertError($this->_sniffFile, 40, "'false' is a reserved keyword introduced in PHP version 7.0 and cannot be invoked as a function");
289
        $this->assertError($this->_sniffFile, 41, "'false' is a reserved keyword introduced in PHP version 7.0 and cannot be invoked as a function");
290
    }
291
    
292
    /**
293
     * testResource
294
     *
295
     * @return void
296
     */
297
    public function testResource()
298
    {
299
        $this->assertError($this->_sniffFile, 42, "'resource' is a reserved keyword introduced in PHP version 7.0 and cannot be invoked as a function");
300
    }
301
    
302
    /**
303
     * testObject
304
     *
305
     * @return void
306
     */
307
    public function testObject()
308
    {
309
        $this->assertError($this->_sniffFile, 43, "'object' is a reserved keyword introduced in PHP version 7.0 and cannot be invoked as a function");
310
    }
311
    
312
    /**
313
     * testMixed
314
     *
315
     * @return void
316
     */
317
    public function testMixed()
318
    {
319
        $this->assertError($this->_sniffFile, 44, "'mixed' is a reserved keyword introduced in PHP version 7.0 and cannot be invoked as a function");
320
    }
321
322
    /**
323
     * testNumberic
324
     *
325
     * @return void
326
     */
327
    public function testNumeric()
328
    {
329
        $this->assertError($this->_sniffFile, 45, "'numeric' is a reserved keyword introduced in PHP version 7.0 and cannot be invoked as a function");
330
    }
331
    
332
    /**
333
     * Verify that checking for a specific version works
334
     *
335
     * @return void
336
     */
337
    public function testGotoInPreviousVersion()
338
    {
339
        $this->_sniffFile = $this->sniffFile('sniff-examples/forbidden_names_function_invocation.php', '5.2');
340
341
        $this->assertNoViolation($this->_sniffFile, 12);
342
    }
343
}
344