@@ -4,10 +4,10 @@ |
||
4 | 4 | function myFunction() {} |
5 | 5 | |
6 | 6 | /* testReturnFunction */ |
7 | -function myFunction(array ...$arrays): array |
|
7 | +function myFunction( array ...$arrays ): array |
|
8 | 8 | { |
9 | - return array_map(/* testNestedClosure */function(array $array): int { |
|
10 | - return array_sum($array); |
|
9 | + return array_map(/* testNestedClosure */function( array $array ): int { |
|
10 | + return array_sum( $array ); |
|
11 | 11 | }, $arrays); |
12 | 12 | } |
13 | 13 |
@@ -36,12 +36,12 @@ discard block |
||
36 | 36 | public function setUp() |
37 | 37 | { |
38 | 38 | $config = new Config(); |
39 | - $config->standards = ['Generic']; |
|
39 | + $config->standards = [ 'Generic' ]; |
|
40 | 40 | |
41 | - $ruleset = new Ruleset($config); |
|
41 | + $ruleset = new Ruleset( $config ); |
|
42 | 42 | |
43 | - $pathToTestFile = dirname(__FILE__).'/'.basename(__FILE__, '.php').'.inc'; |
|
44 | - $this->phpcsFile = new DummyFile(file_get_contents($pathToTestFile), $ruleset, $config); |
|
43 | + $pathToTestFile = dirname( __FILE__ ) . '/' . basename( __FILE__, '.php' ) . '.inc'; |
|
44 | + $this->phpcsFile = new DummyFile( file_get_contents( $pathToTestFile ), $ruleset, $config ); |
|
45 | 45 | $this->phpcsFile->process(); |
46 | 46 | |
47 | 47 | }//end setUp() |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | */ |
55 | 55 | public function tearDown() |
56 | 56 | { |
57 | - unset($this->phpcsFile); |
|
57 | + unset( $this->phpcsFile ); |
|
58 | 58 | |
59 | 59 | }//end tearDown() |
60 | 60 | |
@@ -66,8 +66,8 @@ discard block |
||
66 | 66 | */ |
67 | 67 | public function testPassByReference() |
68 | 68 | { |
69 | - $expected = []; |
|
70 | - $expected[0] = [ |
|
69 | + $expected = [ ]; |
|
70 | + $expected[ 0 ] = [ |
|
71 | 71 | 'name' => '$var', |
72 | 72 | 'content' => '&$var', |
73 | 73 | 'pass_by_reference' => true, |
@@ -76,7 +76,7 @@ discard block |
||
76 | 76 | 'nullable_type' => false, |
77 | 77 | ]; |
78 | 78 | |
79 | - $start = ($this->phpcsFile->numTokens - 1); |
|
79 | + $start = ( $this->phpcsFile->numTokens - 1 ); |
|
80 | 80 | $function = $this->phpcsFile->findPrevious( |
81 | 81 | T_COMMENT, |
82 | 82 | $start, |
@@ -85,10 +85,10 @@ discard block |
||
85 | 85 | '/* testPassByReference */' |
86 | 86 | ); |
87 | 87 | |
88 | - $found = $this->phpcsFile->getMethodParameters(($function + 2)); |
|
89 | - unset($found[0]['token']); |
|
90 | - unset($found[0]['type_hint_token']); |
|
91 | - $this->assertSame($expected, $found); |
|
88 | + $found = $this->phpcsFile->getMethodParameters( ( $function + 2 ) ); |
|
89 | + unset( $found[ 0 ][ 'token' ] ); |
|
90 | + unset( $found[ 0 ][ 'type_hint_token' ] ); |
|
91 | + $this->assertSame( $expected, $found ); |
|
92 | 92 | |
93 | 93 | }//end testPassByReference() |
94 | 94 | |
@@ -100,8 +100,8 @@ discard block |
||
100 | 100 | */ |
101 | 101 | public function testArrayHint() |
102 | 102 | { |
103 | - $expected = []; |
|
104 | - $expected[0] = [ |
|
103 | + $expected = [ ]; |
|
104 | + $expected[ 0 ] = [ |
|
105 | 105 | 'name' => '$var', |
106 | 106 | 'content' => 'array $var', |
107 | 107 | 'pass_by_reference' => false, |
@@ -110,7 +110,7 @@ discard block |
||
110 | 110 | 'nullable_type' => false, |
111 | 111 | ]; |
112 | 112 | |
113 | - $start = ($this->phpcsFile->numTokens - 1); |
|
113 | + $start = ( $this->phpcsFile->numTokens - 1 ); |
|
114 | 114 | $function = $this->phpcsFile->findPrevious( |
115 | 115 | T_COMMENT, |
116 | 116 | $start, |
@@ -119,10 +119,10 @@ discard block |
||
119 | 119 | '/* testArrayHint */' |
120 | 120 | ); |
121 | 121 | |
122 | - $found = $this->phpcsFile->getMethodParameters(($function + 2)); |
|
123 | - unset($found[0]['token']); |
|
124 | - unset($found[0]['type_hint_token']); |
|
125 | - $this->assertSame($expected, $found); |
|
122 | + $found = $this->phpcsFile->getMethodParameters( ( $function + 2 ) ); |
|
123 | + unset( $found[ 0 ][ 'token' ] ); |
|
124 | + unset( $found[ 0 ][ 'type_hint_token' ] ); |
|
125 | + $this->assertSame( $expected, $found ); |
|
126 | 126 | |
127 | 127 | }//end testArrayHint() |
128 | 128 | |
@@ -134,8 +134,8 @@ discard block |
||
134 | 134 | */ |
135 | 135 | public function testTypeHint() |
136 | 136 | { |
137 | - $expected = []; |
|
138 | - $expected[0] = [ |
|
137 | + $expected = [ ]; |
|
138 | + $expected[ 0 ] = [ |
|
139 | 139 | 'name' => '$var1', |
140 | 140 | 'content' => 'foo $var1', |
141 | 141 | 'pass_by_reference' => false, |
@@ -144,7 +144,7 @@ discard block |
||
144 | 144 | 'nullable_type' => false, |
145 | 145 | ]; |
146 | 146 | |
147 | - $expected[1] = [ |
|
147 | + $expected[ 1 ] = [ |
|
148 | 148 | 'name' => '$var2', |
149 | 149 | 'content' => 'bar $var2', |
150 | 150 | 'pass_by_reference' => false, |
@@ -153,7 +153,7 @@ discard block |
||
153 | 153 | 'nullable_type' => false, |
154 | 154 | ]; |
155 | 155 | |
156 | - $start = ($this->phpcsFile->numTokens - 1); |
|
156 | + $start = ( $this->phpcsFile->numTokens - 1 ); |
|
157 | 157 | $function = $this->phpcsFile->findPrevious( |
158 | 158 | T_COMMENT, |
159 | 159 | $start, |
@@ -162,12 +162,12 @@ discard block |
||
162 | 162 | '/* testTypeHint */' |
163 | 163 | ); |
164 | 164 | |
165 | - $found = $this->phpcsFile->getMethodParameters(($function + 2)); |
|
166 | - unset($found[0]['token']); |
|
167 | - unset($found[1]['token']); |
|
168 | - unset($found[0]['type_hint_token']); |
|
169 | - unset($found[1]['type_hint_token']); |
|
170 | - $this->assertSame($expected, $found); |
|
165 | + $found = $this->phpcsFile->getMethodParameters( ( $function + 2 ) ); |
|
166 | + unset( $found[ 0 ][ 'token' ] ); |
|
167 | + unset( $found[ 1 ][ 'token' ] ); |
|
168 | + unset( $found[ 0 ][ 'type_hint_token' ] ); |
|
169 | + unset( $found[ 1 ][ 'type_hint_token' ] ); |
|
170 | + $this->assertSame( $expected, $found ); |
|
171 | 171 | |
172 | 172 | }//end testTypeHint() |
173 | 173 | |
@@ -179,8 +179,8 @@ discard block |
||
179 | 179 | */ |
180 | 180 | public function testSelfTypeHint() |
181 | 181 | { |
182 | - $expected = []; |
|
183 | - $expected[0] = [ |
|
182 | + $expected = [ ]; |
|
183 | + $expected[ 0 ] = [ |
|
184 | 184 | 'name' => '$var', |
185 | 185 | 'content' => 'self $var', |
186 | 186 | 'pass_by_reference' => false, |
@@ -189,7 +189,7 @@ discard block |
||
189 | 189 | 'nullable_type' => false, |
190 | 190 | ]; |
191 | 191 | |
192 | - $start = ($this->phpcsFile->numTokens - 1); |
|
192 | + $start = ( $this->phpcsFile->numTokens - 1 ); |
|
193 | 193 | $function = $this->phpcsFile->findPrevious( |
194 | 194 | T_COMMENT, |
195 | 195 | $start, |
@@ -198,10 +198,10 @@ discard block |
||
198 | 198 | '/* testSelfTypeHint */' |
199 | 199 | ); |
200 | 200 | |
201 | - $found = $this->phpcsFile->getMethodParameters(($function + 2)); |
|
202 | - unset($found[0]['token']); |
|
203 | - unset($found[0]['type_hint_token']); |
|
204 | - $this->assertSame($expected, $found); |
|
201 | + $found = $this->phpcsFile->getMethodParameters( ( $function + 2 ) ); |
|
202 | + unset( $found[ 0 ][ 'token' ] ); |
|
203 | + unset( $found[ 0 ][ 'type_hint_token' ] ); |
|
204 | + $this->assertSame( $expected, $found ); |
|
205 | 205 | |
206 | 206 | }//end testSelfTypeHint() |
207 | 207 | |
@@ -213,8 +213,8 @@ discard block |
||
213 | 213 | */ |
214 | 214 | public function testNullableTypeHint() |
215 | 215 | { |
216 | - $expected = []; |
|
217 | - $expected[0] = [ |
|
216 | + $expected = [ ]; |
|
217 | + $expected[ 0 ] = [ |
|
218 | 218 | 'name' => '$var1', |
219 | 219 | 'content' => '?int $var1', |
220 | 220 | 'pass_by_reference' => false, |
@@ -223,7 +223,7 @@ discard block |
||
223 | 223 | 'nullable_type' => true, |
224 | 224 | ]; |
225 | 225 | |
226 | - $expected[1] = [ |
|
226 | + $expected[ 1 ] = [ |
|
227 | 227 | 'name' => '$var2', |
228 | 228 | 'content' => '?\bar $var2', |
229 | 229 | 'pass_by_reference' => false, |
@@ -232,7 +232,7 @@ discard block |
||
232 | 232 | 'nullable_type' => true, |
233 | 233 | ]; |
234 | 234 | |
235 | - $start = ($this->phpcsFile->numTokens - 1); |
|
235 | + $start = ( $this->phpcsFile->numTokens - 1 ); |
|
236 | 236 | $function = $this->phpcsFile->findPrevious( |
237 | 237 | T_COMMENT, |
238 | 238 | $start, |
@@ -241,12 +241,12 @@ discard block |
||
241 | 241 | '/* testNullableTypeHint */' |
242 | 242 | ); |
243 | 243 | |
244 | - $found = $this->phpcsFile->getMethodParameters(($function + 2)); |
|
245 | - unset($found[0]['token']); |
|
246 | - unset($found[1]['token']); |
|
247 | - unset($found[0]['type_hint_token']); |
|
248 | - unset($found[1]['type_hint_token']); |
|
249 | - $this->assertSame($expected, $found); |
|
244 | + $found = $this->phpcsFile->getMethodParameters( ( $function + 2 ) ); |
|
245 | + unset( $found[ 0 ][ 'token' ] ); |
|
246 | + unset( $found[ 1 ][ 'token' ] ); |
|
247 | + unset( $found[ 0 ][ 'type_hint_token' ] ); |
|
248 | + unset( $found[ 1 ][ 'type_hint_token' ] ); |
|
249 | + $this->assertSame( $expected, $found ); |
|
250 | 250 | |
251 | 251 | }//end testNullableTypeHint() |
252 | 252 | |
@@ -258,8 +258,8 @@ discard block |
||
258 | 258 | */ |
259 | 259 | public function testVariable() |
260 | 260 | { |
261 | - $expected = []; |
|
262 | - $expected[0] = [ |
|
261 | + $expected = [ ]; |
|
262 | + $expected[ 0 ] = [ |
|
263 | 263 | 'name' => '$var', |
264 | 264 | 'content' => '$var', |
265 | 265 | 'pass_by_reference' => false, |
@@ -268,7 +268,7 @@ discard block |
||
268 | 268 | 'nullable_type' => false, |
269 | 269 | ]; |
270 | 270 | |
271 | - $start = ($this->phpcsFile->numTokens - 1); |
|
271 | + $start = ( $this->phpcsFile->numTokens - 1 ); |
|
272 | 272 | $function = $this->phpcsFile->findPrevious( |
273 | 273 | T_COMMENT, |
274 | 274 | $start, |
@@ -277,10 +277,10 @@ discard block |
||
277 | 277 | '/* testVariable */' |
278 | 278 | ); |
279 | 279 | |
280 | - $found = $this->phpcsFile->getMethodParameters(($function + 2)); |
|
281 | - unset($found[0]['token']); |
|
282 | - unset($found[0]['type_hint_token']); |
|
283 | - $this->assertSame($expected, $found); |
|
280 | + $found = $this->phpcsFile->getMethodParameters( ( $function + 2 ) ); |
|
281 | + unset( $found[ 0 ][ 'token' ] ); |
|
282 | + unset( $found[ 0 ][ 'type_hint_token' ] ); |
|
283 | + $this->assertSame( $expected, $found ); |
|
284 | 284 | |
285 | 285 | }//end testVariable() |
286 | 286 | |
@@ -292,8 +292,8 @@ discard block |
||
292 | 292 | */ |
293 | 293 | public function testSingleDefaultValue() |
294 | 294 | { |
295 | - $expected = []; |
|
296 | - $expected[0] = [ |
|
295 | + $expected = [ ]; |
|
296 | + $expected[ 0 ] = [ |
|
297 | 297 | 'name' => '$var1', |
298 | 298 | 'content' => '$var1=self::CONSTANT', |
299 | 299 | 'default' => 'self::CONSTANT', |
@@ -303,7 +303,7 @@ discard block |
||
303 | 303 | 'nullable_type' => false, |
304 | 304 | ]; |
305 | 305 | |
306 | - $start = ($this->phpcsFile->numTokens - 1); |
|
306 | + $start = ( $this->phpcsFile->numTokens - 1 ); |
|
307 | 307 | $function = $this->phpcsFile->findPrevious( |
308 | 308 | T_COMMENT, |
309 | 309 | $start, |
@@ -312,10 +312,10 @@ discard block |
||
312 | 312 | '/* testSingleDefaultValue */' |
313 | 313 | ); |
314 | 314 | |
315 | - $found = $this->phpcsFile->getMethodParameters(($function + 2)); |
|
316 | - unset($found[0]['token']); |
|
317 | - unset($found[0]['type_hint_token']); |
|
318 | - $this->assertSame($expected, $found); |
|
315 | + $found = $this->phpcsFile->getMethodParameters( ( $function + 2 ) ); |
|
316 | + unset( $found[ 0 ][ 'token' ] ); |
|
317 | + unset( $found[ 0 ][ 'type_hint_token' ] ); |
|
318 | + $this->assertSame( $expected, $found ); |
|
319 | 319 | |
320 | 320 | }//end testSingleDefaultValue() |
321 | 321 | |
@@ -327,8 +327,8 @@ discard block |
||
327 | 327 | */ |
328 | 328 | public function testDefaultValues() |
329 | 329 | { |
330 | - $expected = []; |
|
331 | - $expected[0] = [ |
|
330 | + $expected = [ ]; |
|
331 | + $expected[ 0 ] = [ |
|
332 | 332 | 'name' => '$var1', |
333 | 333 | 'content' => '$var1=1', |
334 | 334 | 'default' => '1', |
@@ -337,7 +337,7 @@ discard block |
||
337 | 337 | 'type_hint' => '', |
338 | 338 | 'nullable_type' => false, |
339 | 339 | ]; |
340 | - $expected[1] = [ |
|
340 | + $expected[ 1 ] = [ |
|
341 | 341 | 'name' => '$var2', |
342 | 342 | 'content' => "\$var2='value'", |
343 | 343 | 'default' => "'value'", |
@@ -347,7 +347,7 @@ discard block |
||
347 | 347 | 'nullable_type' => false, |
348 | 348 | ]; |
349 | 349 | |
350 | - $start = ($this->phpcsFile->numTokens - 1); |
|
350 | + $start = ( $this->phpcsFile->numTokens - 1 ); |
|
351 | 351 | $function = $this->phpcsFile->findPrevious( |
352 | 352 | T_COMMENT, |
353 | 353 | $start, |
@@ -356,12 +356,12 @@ discard block |
||
356 | 356 | '/* testDefaultValues */' |
357 | 357 | ); |
358 | 358 | |
359 | - $found = $this->phpcsFile->getMethodParameters(($function + 2)); |
|
360 | - unset($found[0]['token']); |
|
361 | - unset($found[1]['token']); |
|
362 | - unset($found[0]['type_hint_token']); |
|
363 | - unset($found[1]['type_hint_token']); |
|
364 | - $this->assertSame($expected, $found); |
|
359 | + $found = $this->phpcsFile->getMethodParameters( ( $function + 2 ) ); |
|
360 | + unset( $found[ 0 ][ 'token' ] ); |
|
361 | + unset( $found[ 1 ][ 'token' ] ); |
|
362 | + unset( $found[ 0 ][ 'type_hint_token' ] ); |
|
363 | + unset( $found[ 1 ][ 'type_hint_token' ] ); |
|
364 | + $this->assertSame( $expected, $found ); |
|
365 | 365 | |
366 | 366 | }//end testDefaultValues() |
367 | 367 | |
@@ -373,8 +373,8 @@ discard block |
||
373 | 373 | */ |
374 | 374 | public function testBitwiseAndConstantExpressionDefaultValue() |
375 | 375 | { |
376 | - $expected = []; |
|
377 | - $expected[0] = [ |
|
376 | + $expected = [ ]; |
|
377 | + $expected[ 0 ] = [ |
|
378 | 378 | 'name' => '$a', |
379 | 379 | 'content' => '$a = 10 & 20', |
380 | 380 | 'default' => '10 & 20', |
@@ -384,7 +384,7 @@ discard block |
||
384 | 384 | 'nullable_type' => false, |
385 | 385 | ]; |
386 | 386 | |
387 | - $start = ($this->phpcsFile->numTokens - 1); |
|
387 | + $start = ( $this->phpcsFile->numTokens - 1 ); |
|
388 | 388 | $function = $this->phpcsFile->findPrevious( |
389 | 389 | T_COMMENT, |
390 | 390 | $start, |
@@ -393,10 +393,10 @@ discard block |
||
393 | 393 | '/* testBitwiseAndConstantExpressionDefaultValue */' |
394 | 394 | ); |
395 | 395 | |
396 | - $found = $this->phpcsFile->getMethodParameters(($function + 2)); |
|
397 | - unset($found[0]['token']); |
|
398 | - unset($found[0]['type_hint_token']); |
|
399 | - $this->assertSame($expected, $found); |
|
396 | + $found = $this->phpcsFile->getMethodParameters( ( $function + 2 ) ); |
|
397 | + unset( $found[ 0 ][ 'token' ] ); |
|
398 | + unset( $found[ 0 ][ 'type_hint_token' ] ); |
|
399 | + $this->assertSame( $expected, $found ); |
|
400 | 400 | |
401 | 401 | }//end testBitwiseAndConstantExpressionDefaultValue() |
402 | 402 |
@@ -36,12 +36,12 @@ discard block |
||
36 | 36 | public function setUp() |
37 | 37 | { |
38 | 38 | $config = new Config(); |
39 | - $config->standards = ['Generic']; |
|
39 | + $config->standards = [ 'Generic' ]; |
|
40 | 40 | |
41 | - $ruleset = new Ruleset($config); |
|
41 | + $ruleset = new Ruleset( $config ); |
|
42 | 42 | |
43 | - $pathToTestFile = dirname(__FILE__).'/'.basename(__FILE__, '.php').'.inc'; |
|
44 | - $this->phpcsFile = new DummyFile(file_get_contents($pathToTestFile), $ruleset, $config); |
|
43 | + $pathToTestFile = dirname( __FILE__ ) . '/' . basename( __FILE__, '.php' ) . '.inc'; |
|
44 | + $this->phpcsFile = new DummyFile( file_get_contents( $pathToTestFile ), $ruleset, $config ); |
|
45 | 45 | $this->phpcsFile->process(); |
46 | 46 | |
47 | 47 | }//end setUp() |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | */ |
55 | 55 | public function tearDown() |
56 | 56 | { |
57 | - unset($this->phpcsFile); |
|
57 | + unset( $this->phpcsFile ); |
|
58 | 58 | |
59 | 59 | }//end tearDown() |
60 | 60 | |
@@ -77,7 +77,7 @@ discard block |
||
77 | 77 | 'has_body' => true, |
78 | 78 | ]; |
79 | 79 | |
80 | - $start = ($this->phpcsFile->numTokens - 1); |
|
80 | + $start = ( $this->phpcsFile->numTokens - 1 ); |
|
81 | 81 | $function = $this->phpcsFile->findPrevious( |
82 | 82 | T_COMMENT, |
83 | 83 | $start, |
@@ -86,9 +86,9 @@ discard block |
||
86 | 86 | '/* testBasicFunction */' |
87 | 87 | ); |
88 | 88 | |
89 | - $found = $this->phpcsFile->getMethodProperties(($function + 2)); |
|
90 | - unset($found['return_type_token']); |
|
91 | - $this->assertSame($expected, $found); |
|
89 | + $found = $this->phpcsFile->getMethodProperties( ( $function + 2 ) ); |
|
90 | + unset( $found[ 'return_type_token' ] ); |
|
91 | + $this->assertSame( $expected, $found ); |
|
92 | 92 | |
93 | 93 | }//end testBasicFunction() |
94 | 94 | |
@@ -111,7 +111,7 @@ discard block |
||
111 | 111 | 'has_body' => true, |
112 | 112 | ]; |
113 | 113 | |
114 | - $start = ($this->phpcsFile->numTokens - 1); |
|
114 | + $start = ( $this->phpcsFile->numTokens - 1 ); |
|
115 | 115 | $function = $this->phpcsFile->findPrevious( |
116 | 116 | T_COMMENT, |
117 | 117 | $start, |
@@ -120,9 +120,9 @@ discard block |
||
120 | 120 | '/* testReturnFunction */' |
121 | 121 | ); |
122 | 122 | |
123 | - $found = $this->phpcsFile->getMethodProperties(($function + 2)); |
|
124 | - unset($found['return_type_token']); |
|
125 | - $this->assertSame($expected, $found); |
|
123 | + $found = $this->phpcsFile->getMethodProperties( ( $function + 2 ) ); |
|
124 | + unset( $found[ 'return_type_token' ] ); |
|
125 | + $this->assertSame( $expected, $found ); |
|
126 | 126 | |
127 | 127 | }//end testReturnFunction() |
128 | 128 | |
@@ -145,7 +145,7 @@ discard block |
||
145 | 145 | 'has_body' => true, |
146 | 146 | ]; |
147 | 147 | |
148 | - $start = ($this->phpcsFile->numTokens - 1); |
|
148 | + $start = ( $this->phpcsFile->numTokens - 1 ); |
|
149 | 149 | $function = $this->phpcsFile->findPrevious( |
150 | 150 | T_COMMENT, |
151 | 151 | $start, |
@@ -154,9 +154,9 @@ discard block |
||
154 | 154 | '/* testNestedClosure */' |
155 | 155 | ); |
156 | 156 | |
157 | - $found = $this->phpcsFile->getMethodProperties(($function + 1)); |
|
158 | - unset($found['return_type_token']); |
|
159 | - $this->assertSame($expected, $found); |
|
157 | + $found = $this->phpcsFile->getMethodProperties( ( $function + 1 ) ); |
|
158 | + unset( $found[ 'return_type_token' ] ); |
|
159 | + $this->assertSame( $expected, $found ); |
|
160 | 160 | |
161 | 161 | }//end testNestedClosure() |
162 | 162 | |
@@ -179,7 +179,7 @@ discard block |
||
179 | 179 | 'has_body' => true, |
180 | 180 | ]; |
181 | 181 | |
182 | - $start = ($this->phpcsFile->numTokens - 1); |
|
182 | + $start = ( $this->phpcsFile->numTokens - 1 ); |
|
183 | 183 | $function = $this->phpcsFile->findPrevious( |
184 | 184 | T_COMMENT, |
185 | 185 | $start, |
@@ -188,9 +188,9 @@ discard block |
||
188 | 188 | '/* testBasicMethod */' |
189 | 189 | ); |
190 | 190 | |
191 | - $found = $this->phpcsFile->getMethodProperties(($function + 3)); |
|
192 | - unset($found['return_type_token']); |
|
193 | - $this->assertSame($expected, $found); |
|
191 | + $found = $this->phpcsFile->getMethodProperties( ( $function + 3 ) ); |
|
192 | + unset( $found[ 'return_type_token' ] ); |
|
193 | + $this->assertSame( $expected, $found ); |
|
194 | 194 | |
195 | 195 | }//end testBasicMethod() |
196 | 196 | |
@@ -213,7 +213,7 @@ discard block |
||
213 | 213 | 'has_body' => true, |
214 | 214 | ]; |
215 | 215 | |
216 | - $start = ($this->phpcsFile->numTokens - 1); |
|
216 | + $start = ( $this->phpcsFile->numTokens - 1 ); |
|
217 | 217 | $function = $this->phpcsFile->findPrevious( |
218 | 218 | T_COMMENT, |
219 | 219 | $start, |
@@ -222,9 +222,9 @@ discard block |
||
222 | 222 | '/* testPrivateStaticMethod */' |
223 | 223 | ); |
224 | 224 | |
225 | - $found = $this->phpcsFile->getMethodProperties(($function + 7)); |
|
226 | - unset($found['return_type_token']); |
|
227 | - $this->assertSame($expected, $found); |
|
225 | + $found = $this->phpcsFile->getMethodProperties( ( $function + 7 ) ); |
|
226 | + unset( $found[ 'return_type_token' ] ); |
|
227 | + $this->assertSame( $expected, $found ); |
|
228 | 228 | |
229 | 229 | }//end testPrivateStaticMethod() |
230 | 230 | |
@@ -247,7 +247,7 @@ discard block |
||
247 | 247 | 'has_body' => true, |
248 | 248 | ]; |
249 | 249 | |
250 | - $start = ($this->phpcsFile->numTokens - 1); |
|
250 | + $start = ( $this->phpcsFile->numTokens - 1 ); |
|
251 | 251 | $function = $this->phpcsFile->findPrevious( |
252 | 252 | T_COMMENT, |
253 | 253 | $start, |
@@ -256,9 +256,9 @@ discard block |
||
256 | 256 | '/* testFinalMethod */' |
257 | 257 | ); |
258 | 258 | |
259 | - $found = $this->phpcsFile->getMethodProperties(($function + 7)); |
|
260 | - unset($found['return_type_token']); |
|
261 | - $this->assertSame($expected, $found); |
|
259 | + $found = $this->phpcsFile->getMethodProperties( ( $function + 7 ) ); |
|
260 | + unset( $found[ 'return_type_token' ] ); |
|
261 | + $this->assertSame( $expected, $found ); |
|
262 | 262 | |
263 | 263 | }//end testFinalMethod() |
264 | 264 | |
@@ -281,7 +281,7 @@ discard block |
||
281 | 281 | 'has_body' => true, |
282 | 282 | ]; |
283 | 283 | |
284 | - $start = ($this->phpcsFile->numTokens - 1); |
|
284 | + $start = ( $this->phpcsFile->numTokens - 1 ); |
|
285 | 285 | $function = $this->phpcsFile->findPrevious( |
286 | 286 | T_COMMENT, |
287 | 287 | $start, |
@@ -290,9 +290,9 @@ discard block |
||
290 | 290 | '/* testProtectedReturnMethod */' |
291 | 291 | ); |
292 | 292 | |
293 | - $found = $this->phpcsFile->getMethodProperties(($function + 5)); |
|
294 | - unset($found['return_type_token']); |
|
295 | - $this->assertSame($expected, $found); |
|
293 | + $found = $this->phpcsFile->getMethodProperties( ( $function + 5 ) ); |
|
294 | + unset( $found[ 'return_type_token' ] ); |
|
295 | + $this->assertSame( $expected, $found ); |
|
296 | 296 | |
297 | 297 | }//end testProtectedReturnMethod() |
298 | 298 | |
@@ -315,7 +315,7 @@ discard block |
||
315 | 315 | 'has_body' => true, |
316 | 316 | ]; |
317 | 317 | |
318 | - $start = ($this->phpcsFile->numTokens - 1); |
|
318 | + $start = ( $this->phpcsFile->numTokens - 1 ); |
|
319 | 319 | $function = $this->phpcsFile->findPrevious( |
320 | 320 | T_COMMENT, |
321 | 321 | $start, |
@@ -324,9 +324,9 @@ discard block |
||
324 | 324 | '/* testPublicReturnMethod */' |
325 | 325 | ); |
326 | 326 | |
327 | - $found = $this->phpcsFile->getMethodProperties(($function + 5)); |
|
328 | - unset($found['return_type_token']); |
|
329 | - $this->assertSame($expected, $found); |
|
327 | + $found = $this->phpcsFile->getMethodProperties( ( $function + 5 ) ); |
|
328 | + unset( $found[ 'return_type_token' ] ); |
|
329 | + $this->assertSame( $expected, $found ); |
|
330 | 330 | |
331 | 331 | }//end testPublicReturnMethod() |
332 | 332 | |
@@ -349,7 +349,7 @@ discard block |
||
349 | 349 | 'has_body' => true, |
350 | 350 | ]; |
351 | 351 | |
352 | - $start = ($this->phpcsFile->numTokens - 1); |
|
352 | + $start = ( $this->phpcsFile->numTokens - 1 ); |
|
353 | 353 | $function = $this->phpcsFile->findPrevious( |
354 | 354 | T_COMMENT, |
355 | 355 | $start, |
@@ -358,9 +358,9 @@ discard block |
||
358 | 358 | '/* testNullableReturnMethod */' |
359 | 359 | ); |
360 | 360 | |
361 | - $found = $this->phpcsFile->getMethodProperties(($function + 5)); |
|
362 | - unset($found['return_type_token']); |
|
363 | - $this->assertSame($expected, $found); |
|
361 | + $found = $this->phpcsFile->getMethodProperties( ( $function + 5 ) ); |
|
362 | + unset( $found[ 'return_type_token' ] ); |
|
363 | + $this->assertSame( $expected, $found ); |
|
364 | 364 | |
365 | 365 | }//end testNullableReturnMethod() |
366 | 366 | |
@@ -383,7 +383,7 @@ discard block |
||
383 | 383 | 'has_body' => true, |
384 | 384 | ]; |
385 | 385 | |
386 | - $start = ($this->phpcsFile->numTokens - 1); |
|
386 | + $start = ( $this->phpcsFile->numTokens - 1 ); |
|
387 | 387 | $function = $this->phpcsFile->findPrevious( |
388 | 388 | T_COMMENT, |
389 | 389 | $start, |
@@ -392,9 +392,9 @@ discard block |
||
392 | 392 | '/* testMessyNullableReturnMethod */' |
393 | 393 | ); |
394 | 394 | |
395 | - $found = $this->phpcsFile->getMethodProperties(($function + 5)); |
|
396 | - unset($found['return_type_token']); |
|
397 | - $this->assertSame($expected, $found); |
|
395 | + $found = $this->phpcsFile->getMethodProperties( ( $function + 5 ) ); |
|
396 | + unset( $found[ 'return_type_token' ] ); |
|
397 | + $this->assertSame( $expected, $found ); |
|
398 | 398 | |
399 | 399 | }//end testMessyNullableReturnMethod() |
400 | 400 | |
@@ -417,7 +417,7 @@ discard block |
||
417 | 417 | 'has_body' => true, |
418 | 418 | ]; |
419 | 419 | |
420 | - $start = ($this->phpcsFile->numTokens - 1); |
|
420 | + $start = ( $this->phpcsFile->numTokens - 1 ); |
|
421 | 421 | $function = $this->phpcsFile->findPrevious( |
422 | 422 | T_COMMENT, |
423 | 423 | $start, |
@@ -426,9 +426,9 @@ discard block |
||
426 | 426 | '/* testReturnNamespace */' |
427 | 427 | ); |
428 | 428 | |
429 | - $found = $this->phpcsFile->getMethodProperties(($function + 3)); |
|
430 | - unset($found['return_type_token']); |
|
431 | - $this->assertSame($expected, $found); |
|
429 | + $found = $this->phpcsFile->getMethodProperties( ( $function + 3 ) ); |
|
430 | + unset( $found[ 'return_type_token' ] ); |
|
431 | + $this->assertSame( $expected, $found ); |
|
432 | 432 | |
433 | 433 | }//end testReturnNamespace() |
434 | 434 | |
@@ -451,7 +451,7 @@ discard block |
||
451 | 451 | 'has_body' => true, |
452 | 452 | ]; |
453 | 453 | |
454 | - $start = ($this->phpcsFile->numTokens - 1); |
|
454 | + $start = ( $this->phpcsFile->numTokens - 1 ); |
|
455 | 455 | $function = $this->phpcsFile->findPrevious( |
456 | 456 | T_COMMENT, |
457 | 457 | $start, |
@@ -460,9 +460,9 @@ discard block |
||
460 | 460 | '/* testReturnMultilineNamespace */' |
461 | 461 | ); |
462 | 462 | |
463 | - $found = $this->phpcsFile->getMethodProperties(($function + 3)); |
|
464 | - unset($found['return_type_token']); |
|
465 | - $this->assertSame($expected, $found); |
|
463 | + $found = $this->phpcsFile->getMethodProperties( ( $function + 3 ) ); |
|
464 | + unset( $found[ 'return_type_token' ] ); |
|
465 | + $this->assertSame( $expected, $found ); |
|
466 | 466 | |
467 | 467 | }//end testReturnMultilineNamespace() |
468 | 468 | |
@@ -485,7 +485,7 @@ discard block |
||
485 | 485 | 'has_body' => false, |
486 | 486 | ]; |
487 | 487 | |
488 | - $start = ($this->phpcsFile->numTokens - 1); |
|
488 | + $start = ( $this->phpcsFile->numTokens - 1 ); |
|
489 | 489 | $function = $this->phpcsFile->findPrevious( |
490 | 490 | T_COMMENT, |
491 | 491 | $start, |
@@ -494,9 +494,9 @@ discard block |
||
494 | 494 | '/* testAbstractMethod */' |
495 | 495 | ); |
496 | 496 | |
497 | - $found = $this->phpcsFile->getMethodProperties(($function + 5)); |
|
498 | - unset($found['return_type_token']); |
|
499 | - $this->assertSame($expected, $found); |
|
497 | + $found = $this->phpcsFile->getMethodProperties( ( $function + 5 ) ); |
|
498 | + unset( $found[ 'return_type_token' ] ); |
|
499 | + $this->assertSame( $expected, $found ); |
|
500 | 500 | |
501 | 501 | }//end testAbstractMethod() |
502 | 502 | |
@@ -519,7 +519,7 @@ discard block |
||
519 | 519 | 'has_body' => false, |
520 | 520 | ]; |
521 | 521 | |
522 | - $start = ($this->phpcsFile->numTokens - 1); |
|
522 | + $start = ( $this->phpcsFile->numTokens - 1 ); |
|
523 | 523 | $function = $this->phpcsFile->findPrevious( |
524 | 524 | T_COMMENT, |
525 | 525 | $start, |
@@ -528,9 +528,9 @@ discard block |
||
528 | 528 | '/* testAbstractReturnMethod */' |
529 | 529 | ); |
530 | 530 | |
531 | - $found = $this->phpcsFile->getMethodProperties(($function + 7)); |
|
532 | - unset($found['return_type_token']); |
|
533 | - $this->assertSame($expected, $found); |
|
531 | + $found = $this->phpcsFile->getMethodProperties( ( $function + 7 ) ); |
|
532 | + unset( $found[ 'return_type_token' ] ); |
|
533 | + $this->assertSame( $expected, $found ); |
|
534 | 534 | |
535 | 535 | }//end testAbstractReturnMethod() |
536 | 536 | |
@@ -553,7 +553,7 @@ discard block |
||
553 | 553 | 'has_body' => false, |
554 | 554 | ]; |
555 | 555 | |
556 | - $start = ($this->phpcsFile->numTokens - 1); |
|
556 | + $start = ( $this->phpcsFile->numTokens - 1 ); |
|
557 | 557 | $function = $this->phpcsFile->findPrevious( |
558 | 558 | T_COMMENT, |
559 | 559 | $start, |
@@ -562,9 +562,9 @@ discard block |
||
562 | 562 | '/* testInterfaceMethod */' |
563 | 563 | ); |
564 | 564 | |
565 | - $found = $this->phpcsFile->getMethodProperties(($function + 3)); |
|
566 | - unset($found['return_type_token']); |
|
567 | - $this->assertSame($expected, $found); |
|
565 | + $found = $this->phpcsFile->getMethodProperties( ( $function + 3 ) ); |
|
566 | + unset( $found[ 'return_type_token' ] ); |
|
567 | + $this->assertSame( $expected, $found ); |
|
568 | 568 | |
569 | 569 | }//end testInterfaceMethod() |
570 | 570 |
@@ -36,12 +36,12 @@ discard block |
||
36 | 36 | public function setUp() |
37 | 37 | { |
38 | 38 | $config = new Config(); |
39 | - $config->standards = ['Generic']; |
|
39 | + $config->standards = [ 'Generic' ]; |
|
40 | 40 | |
41 | - $ruleset = new Ruleset($config); |
|
41 | + $ruleset = new Ruleset( $config ); |
|
42 | 42 | |
43 | - $pathToTestFile = dirname(__FILE__).'/'.basename(__FILE__, '.php').'.inc'; |
|
44 | - $this->phpcsFile = new DummyFile(file_get_contents($pathToTestFile), $ruleset, $config); |
|
43 | + $pathToTestFile = dirname( __FILE__ ) . '/' . basename( __FILE__, '.php' ) . '.inc'; |
|
44 | + $this->phpcsFile = new DummyFile( file_get_contents( $pathToTestFile ), $ruleset, $config ); |
|
45 | 45 | $this->phpcsFile->process(); |
46 | 46 | |
47 | 47 | }//end setUp() |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | */ |
55 | 55 | public function tearDown() |
56 | 56 | { |
57 | - unset($this->phpcsFile); |
|
57 | + unset( $this->phpcsFile ); |
|
58 | 58 | |
59 | 59 | }//end tearDown() |
60 | 60 | |
@@ -69,9 +69,9 @@ discard block |
||
69 | 69 | * |
70 | 70 | * @return void |
71 | 71 | */ |
72 | - public function testIsReference($identifier, $expected) |
|
72 | + public function testIsReference( $identifier, $expected ) |
|
73 | 73 | { |
74 | - $start = ($this->phpcsFile->numTokens - 1); |
|
74 | + $start = ( $this->phpcsFile->numTokens - 1 ); |
|
75 | 75 | $delim = $this->phpcsFile->findPrevious( |
76 | 76 | T_COMMENT, |
77 | 77 | $start, |
@@ -79,10 +79,10 @@ discard block |
||
79 | 79 | false, |
80 | 80 | $identifier |
81 | 81 | ); |
82 | - $bitwiseAnd = $this->phpcsFile->findNext(T_BITWISE_AND, ($delim + 1)); |
|
82 | + $bitwiseAnd = $this->phpcsFile->findNext( T_BITWISE_AND, ( $delim + 1 ) ); |
|
83 | 83 | |
84 | - $result = $this->phpcsFile->isReference($bitwiseAnd); |
|
85 | - $this->assertSame($expected, $result); |
|
84 | + $result = $this->phpcsFile->isReference( $bitwiseAnd ); |
|
85 | + $this->assertSame( $expected, $result ); |
|
86 | 86 | |
87 | 87 | }//end testIsReference() |
88 | 88 |
@@ -17,10 +17,10 @@ |
||
17 | 17 | interface testFECNInterface {} |
18 | 18 | |
19 | 19 | /* testInterfaceThatExtendsInterface */ |
20 | -interface testInterfaceThatExtendsInterface extends testFECNInterface{} |
|
20 | +interface testInterfaceThatExtendsInterface extends testFECNInterface {} |
|
21 | 21 | |
22 | 22 | /* testInterfaceThatExtendsFQCNInterface */ |
23 | -interface testInterfaceThatExtendsFQCNInterface extends \PHP_CodeSniffer\Tests\Core\File\testFECNInterface{} |
|
23 | +interface testInterfaceThatExtendsFQCNInterface extends \PHP_CodeSniffer\Tests\Core\File\testFECNInterface {} |
|
24 | 24 | |
25 | 25 | /* testNestedExtendedClass */ |
26 | 26 | class testFECNNestedExtendedClass { |
@@ -24,10 +24,10 @@ discard block |
||
24 | 24 | $a = $something & $somethingElse; |
25 | 25 | |
26 | 26 | /* bitwiseAndH */ |
27 | -function myFunction($a = 10 & 20) {} |
|
27 | +function myFunction( $a = 10 & 20 ) {} |
|
28 | 28 | |
29 | 29 | /* bitwiseAndI */ |
30 | -$closure = function ($a = MY_CONSTANT & parent::OTHER_CONSTANT) {}; |
|
30 | +$closure = function( $a = MY_CONSTANT & parent::OTHER_CONSTANT ) {}; |
|
31 | 31 | |
32 | 32 | /* functionReturnByReference */ |
33 | 33 | function &myFunction() {} |
@@ -39,25 +39,25 @@ discard block |
||
39 | 39 | function myFunction( $a, &$b ) {} |
40 | 40 | |
41 | 41 | /* functionPassByReferenceC */ |
42 | -$closure = function ( &$a ) {}; |
|
42 | +$closure = function( &$a ) {}; |
|
43 | 43 | |
44 | 44 | /* functionPassByReferenceD */ |
45 | -$closure = function ( $a, &$b ) {}; |
|
45 | +$closure = function( $a, &$b ) {}; |
|
46 | 46 | |
47 | 47 | /* functionPassByReferenceE */ |
48 | -function myFunction(array &$one) {} |
|
48 | +function myFunction( array &$one ) {} |
|
49 | 49 | |
50 | 50 | /* functionPassByReferenceF */ |
51 | -$closure = function (\MyClass &$one) {}; |
|
51 | +$closure = function( \MyClass &$one ) {}; |
|
52 | 52 | |
53 | 53 | /* functionPassByReferenceG */ |
54 | -$closure = function myFunc($param, &...$moreParams) {}; |
|
54 | +$closure = function myFunc( $param, &...$moreParams ) {}; |
|
55 | 55 | |
56 | 56 | /* foreachValueByReference */ |
57 | -foreach( $array as $key => &$value ) {} |
|
57 | +foreach ( $array as $key => &$value ) {} |
|
58 | 58 | |
59 | 59 | /* foreachKeyByReference */ |
60 | -foreach( $array as &$key => $value ) {} |
|
60 | +foreach ( $array as &$key => $value ) {} |
|
61 | 61 | |
62 | 62 | /* arrayValueByReferenceA */ |
63 | 63 | $a = [ 'a' => &$something ]; |
@@ -87,7 +87,7 @@ discard block |
||
87 | 87 | $b = &$something; |
88 | 88 | |
89 | 89 | /* assignByReferenceB */ |
90 | -$b =& $something; |
|
90 | +$b = & $something; |
|
91 | 91 | |
92 | 92 | /* assignByReferenceC */ |
93 | 93 | $b .= &$something; |
@@ -99,40 +99,40 @@ discard block |
||
99 | 99 | $collection = &collector(); |
100 | 100 | |
101 | 101 | /* passByReferenceA */ |
102 | -functionCall(&$something, $somethingElse); |
|
102 | +functionCall( &$something, $somethingElse ); |
|
103 | 103 | |
104 | 104 | /* passByReferenceB */ |
105 | -functionCall($something, &$somethingElse); |
|
105 | +functionCall( $something, &$somethingElse ); |
|
106 | 106 | |
107 | 107 | /* passByReferenceC */ |
108 | -functionCall($something, &$this->somethingElse); |
|
108 | +functionCall( $something, &$this->somethingElse ); |
|
109 | 109 | |
110 | 110 | /* passByReferenceD */ |
111 | -functionCall($something, &self::$somethingElse); |
|
111 | +functionCall( $something, &self::$somethingElse ); |
|
112 | 112 | |
113 | 113 | /* passByReferenceE */ |
114 | -functionCall($something, &parent::$somethingElse); |
|
114 | +functionCall( $something, &parent::$somethingElse ); |
|
115 | 115 | |
116 | 116 | /* passByReferenceF */ |
117 | -functionCall($something, &static::$somethingElse); |
|
117 | +functionCall( $something, &static::$somethingElse ); |
|
118 | 118 | |
119 | 119 | /* passByReferenceG */ |
120 | -functionCall($something, &SomeClass::$somethingElse); |
|
120 | +functionCall( $something, &SomeClass::$somethingElse ); |
|
121 | 121 | |
122 | 122 | /* passByReferenceH */ |
123 | -functionCall(&\SomeClass::$somethingElse); |
|
123 | +functionCall( &\SomeClass::$somethingElse ); |
|
124 | 124 | |
125 | 125 | /* passByReferenceI */ |
126 | -functionCall($something, &\SomeNS\SomeClass::$somethingElse); |
|
126 | +functionCall( $something, &\SomeNS\SomeClass::$somethingElse ); |
|
127 | 127 | |
128 | 128 | /* passByReferenceJ */ |
129 | -functionCall($something, &namespace\SomeClass::$somethingElse); |
|
129 | +functionCall( $something, &namespace\SomeClass::$somethingElse ); |
|
130 | 130 | |
131 | 131 | /* newByReferenceA */ |
132 | 132 | $foobar2 = &new Foobar(); |
133 | 133 | |
134 | 134 | /* newByReferenceB */ |
135 | -functionCall( $something , &new Foobar() ); |
|
135 | +functionCall( $something, &new Foobar() ); |
|
136 | 136 | |
137 | 137 | /* useByReference */ |
138 | -$closure = function() use (&$var){}; |
|
138 | +$closure = function() use ( &$var ){}; |
@@ -33,7 +33,7 @@ discard block |
||
33 | 33 | */ |
34 | 34 | public static function main() |
35 | 35 | { |
36 | - TestRunner::run(self::suite()); |
|
36 | + TestRunner::run( self::suite() ); |
|
37 | 37 | |
38 | 38 | }//end main() |
39 | 39 | |
@@ -45,16 +45,16 @@ discard block |
||
45 | 45 | */ |
46 | 46 | public static function suite() |
47 | 47 | { |
48 | - $suite = new TestSuite('PHP CodeSniffer Core'); |
|
49 | - $suite->addTestSuite('PHP_CodeSniffer\Tests\Core\IsCamelCapsTest'); |
|
50 | - $suite->addTestSuite('PHP_CodeSniffer\Tests\Core\ErrorSuppressionTest'); |
|
51 | - $suite->addTestSuite('PHP_CodeSniffer\Tests\Core\File\FindEndOfStatementTest'); |
|
52 | - $suite->addTestSuite('PHP_CodeSniffer\Tests\Core\File\FindExtendedClassNameTest'); |
|
53 | - $suite->addTestSuite('PHP_CodeSniffer\Tests\Core\File\FindImplementedInterfaceNamesTest'); |
|
54 | - $suite->addTestSuite('PHP_CodeSniffer\Tests\Core\File\GetMemberPropertiesTest'); |
|
55 | - $suite->addTestSuite('PHP_CodeSniffer\Tests\Core\File\GetMethodParametersTest'); |
|
56 | - $suite->addTestSuite('PHP_CodeSniffer\Tests\Core\File\GetMethodPropertiesTest'); |
|
57 | - $suite->addTestSuite('PHP_CodeSniffer\Tests\Core\File\IsReferenceTest'); |
|
48 | + $suite = new TestSuite( 'PHP CodeSniffer Core' ); |
|
49 | + $suite->addTestSuite( 'PHP_CodeSniffer\Tests\Core\IsCamelCapsTest' ); |
|
50 | + $suite->addTestSuite( 'PHP_CodeSniffer\Tests\Core\ErrorSuppressionTest' ); |
|
51 | + $suite->addTestSuite( 'PHP_CodeSniffer\Tests\Core\File\FindEndOfStatementTest' ); |
|
52 | + $suite->addTestSuite( 'PHP_CodeSniffer\Tests\Core\File\FindExtendedClassNameTest' ); |
|
53 | + $suite->addTestSuite( 'PHP_CodeSniffer\Tests\Core\File\FindImplementedInterfaceNamesTest' ); |
|
54 | + $suite->addTestSuite( 'PHP_CodeSniffer\Tests\Core\File\GetMemberPropertiesTest' ); |
|
55 | + $suite->addTestSuite( 'PHP_CodeSniffer\Tests\Core\File\GetMethodParametersTest' ); |
|
56 | + $suite->addTestSuite( 'PHP_CodeSniffer\Tests\Core\File\GetMethodPropertiesTest' ); |
|
57 | + $suite->addTestSuite( 'PHP_CodeSniffer\Tests\Core\File\IsReferenceTest' ); |
|
58 | 58 | return $suite; |
59 | 59 | |
60 | 60 | }//end suite() |
@@ -26,150 +26,150 @@ discard block |
||
26 | 26 | public function testSuppressError() |
27 | 27 | { |
28 | 28 | $config = new Config(); |
29 | - $config->standards = ['Generic']; |
|
30 | - $config->sniffs = ['Generic.PHP.LowerCaseConstant']; |
|
29 | + $config->standards = [ 'Generic' ]; |
|
30 | + $config->sniffs = [ 'Generic.PHP.LowerCaseConstant' ]; |
|
31 | 31 | |
32 | - $ruleset = new Ruleset($config); |
|
32 | + $ruleset = new Ruleset( $config ); |
|
33 | 33 | |
34 | 34 | // Process without suppression. |
35 | - $content = '<?php '.PHP_EOL.'$var = FALSE;'; |
|
36 | - $file = new DummyFile($content, $ruleset, $config); |
|
35 | + $content = '<?php ' . PHP_EOL . '$var = FALSE;'; |
|
36 | + $file = new DummyFile( $content, $ruleset, $config ); |
|
37 | 37 | $file->process(); |
38 | 38 | |
39 | 39 | $errors = $file->getErrors(); |
40 | 40 | $numErrors = $file->getErrorCount(); |
41 | - $this->assertEquals(1, $numErrors); |
|
42 | - $this->assertCount(1, $errors); |
|
41 | + $this->assertEquals( 1, $numErrors ); |
|
42 | + $this->assertCount( 1, $errors ); |
|
43 | 43 | |
44 | 44 | // Process with inline comment suppression. |
45 | - $content = '<?php '.PHP_EOL.'// phpcs:disable'.PHP_EOL.'$var = FALSE;'.PHP_EOL.'// phpcs:enable'; |
|
46 | - $file = new DummyFile($content, $ruleset, $config); |
|
45 | + $content = '<?php ' . PHP_EOL . '// phpcs:disable' . PHP_EOL . '$var = FALSE;' . PHP_EOL . '// phpcs:enable'; |
|
46 | + $file = new DummyFile( $content, $ruleset, $config ); |
|
47 | 47 | $file->process(); |
48 | 48 | |
49 | 49 | $errors = $file->getErrors(); |
50 | 50 | $numErrors = $file->getErrorCount(); |
51 | - $this->assertEquals(0, $numErrors); |
|
52 | - $this->assertCount(0, $errors); |
|
51 | + $this->assertEquals( 0, $numErrors ); |
|
52 | + $this->assertCount( 0, $errors ); |
|
53 | 53 | |
54 | 54 | // Process with multi-line inline comment suppression, tab-indented. |
55 | - $content = '<?php '.PHP_EOL."\t".'// For reasons'.PHP_EOL."\t".'// phpcs:disable'.PHP_EOL."\t".'$var = FALSE;'.PHP_EOL."\t".'// phpcs:enable'; |
|
56 | - $file = new DummyFile($content, $ruleset, $config); |
|
55 | + $content = '<?php ' . PHP_EOL . "\t" . '// For reasons' . PHP_EOL . "\t" . '// phpcs:disable' . PHP_EOL . "\t" . '$var = FALSE;' . PHP_EOL . "\t" . '// phpcs:enable'; |
|
56 | + $file = new DummyFile( $content, $ruleset, $config ); |
|
57 | 57 | $file->process(); |
58 | 58 | |
59 | 59 | $errors = $file->getErrors(); |
60 | 60 | $numErrors = $file->getErrorCount(); |
61 | - $this->assertEquals(0, $numErrors); |
|
62 | - $this->assertCount(0, $errors); |
|
61 | + $this->assertEquals( 0, $numErrors ); |
|
62 | + $this->assertCount( 0, $errors ); |
|
63 | 63 | |
64 | 64 | // Process with inline @ comment suppression. |
65 | - $content = '<?php '.PHP_EOL.'// @phpcs:disable'.PHP_EOL.'$var = FALSE;'.PHP_EOL.'// @phpcs:enable'; |
|
66 | - $file = new DummyFile($content, $ruleset, $config); |
|
65 | + $content = '<?php ' . PHP_EOL . '// @phpcs:disable' . PHP_EOL . '$var = FALSE;' . PHP_EOL . '// @phpcs:enable'; |
|
66 | + $file = new DummyFile( $content, $ruleset, $config ); |
|
67 | 67 | $file->process(); |
68 | 68 | |
69 | 69 | $errors = $file->getErrors(); |
70 | 70 | $numErrors = $file->getErrorCount(); |
71 | - $this->assertEquals(0, $numErrors); |
|
72 | - $this->assertCount(0, $errors); |
|
71 | + $this->assertEquals( 0, $numErrors ); |
|
72 | + $this->assertCount( 0, $errors ); |
|
73 | 73 | |
74 | 74 | // Process with inline comment suppression mixed case. |
75 | - $content = '<?php '.PHP_EOL.'// PHPCS:Disable'.PHP_EOL.'$var = FALSE;'.PHP_EOL.'// pHPcs:enabLE'; |
|
76 | - $file = new DummyFile($content, $ruleset, $config); |
|
75 | + $content = '<?php ' . PHP_EOL . '// PHPCS:Disable' . PHP_EOL . '$var = FALSE;' . PHP_EOL . '// pHPcs:enabLE'; |
|
76 | + $file = new DummyFile( $content, $ruleset, $config ); |
|
77 | 77 | $file->process(); |
78 | 78 | |
79 | 79 | $errors = $file->getErrors(); |
80 | 80 | $numErrors = $file->getErrorCount(); |
81 | - $this->assertEquals(0, $numErrors); |
|
82 | - $this->assertCount(0, $errors); |
|
81 | + $this->assertEquals( 0, $numErrors ); |
|
82 | + $this->assertCount( 0, $errors ); |
|
83 | 83 | |
84 | 84 | // Process with inline comment suppression (deprecated syntax). |
85 | - $content = '<?php '.PHP_EOL.'// @codingStandardsIgnoreStart'.PHP_EOL.'$var = FALSE;'.PHP_EOL.'// @codingStandardsIgnoreEnd'; |
|
86 | - $file = new DummyFile($content, $ruleset, $config); |
|
85 | + $content = '<?php ' . PHP_EOL . '// @codingStandardsIgnoreStart' . PHP_EOL . '$var = FALSE;' . PHP_EOL . '// @codingStandardsIgnoreEnd'; |
|
86 | + $file = new DummyFile( $content, $ruleset, $config ); |
|
87 | 87 | $file->process(); |
88 | 88 | |
89 | 89 | $errors = $file->getErrors(); |
90 | 90 | $numErrors = $file->getErrorCount(); |
91 | - $this->assertEquals(0, $numErrors); |
|
92 | - $this->assertCount(0, $errors); |
|
91 | + $this->assertEquals( 0, $numErrors ); |
|
92 | + $this->assertCount( 0, $errors ); |
|
93 | 93 | |
94 | 94 | // Process with block comment suppression. |
95 | - $content = '<?php '.PHP_EOL.'/* phpcs:disable */'.PHP_EOL.'$var = FALSE;'.PHP_EOL.'/* phpcs:enable */'; |
|
96 | - $file = new DummyFile($content, $ruleset, $config); |
|
95 | + $content = '<?php ' . PHP_EOL . '/* phpcs:disable */' . PHP_EOL . '$var = FALSE;' . PHP_EOL . '/* phpcs:enable */'; |
|
96 | + $file = new DummyFile( $content, $ruleset, $config ); |
|
97 | 97 | $file->process(); |
98 | 98 | |
99 | 99 | $errors = $file->getErrors(); |
100 | 100 | $numErrors = $file->getErrorCount(); |
101 | - $this->assertEquals(0, $numErrors); |
|
102 | - $this->assertCount(0, $errors); |
|
101 | + $this->assertEquals( 0, $numErrors ); |
|
102 | + $this->assertCount( 0, $errors ); |
|
103 | 103 | |
104 | 104 | // Process with multi-line block comment suppression. |
105 | - $content = '<?php '.PHP_EOL.'/*'.PHP_EOL.' phpcs:disable'.PHP_EOL.' */'.PHP_EOL.'$var = FALSE;'.PHP_EOL.'/*'.PHP_EOL.' phpcs:enable'.PHP_EOL.' */'; |
|
106 | - $file = new DummyFile($content, $ruleset, $config); |
|
105 | + $content = '<?php ' . PHP_EOL . '/*' . PHP_EOL . ' phpcs:disable' . PHP_EOL . ' */' . PHP_EOL . '$var = FALSE;' . PHP_EOL . '/*' . PHP_EOL . ' phpcs:enable' . PHP_EOL . ' */'; |
|
106 | + $file = new DummyFile( $content, $ruleset, $config ); |
|
107 | 107 | $file->process(); |
108 | 108 | |
109 | 109 | $errors = $file->getErrors(); |
110 | 110 | $numErrors = $file->getErrorCount(); |
111 | - $this->assertEquals(0, $numErrors); |
|
112 | - $this->assertCount(0, $errors); |
|
111 | + $this->assertEquals( 0, $numErrors ); |
|
112 | + $this->assertCount( 0, $errors ); |
|
113 | 113 | |
114 | 114 | // Process with multi-line block comment suppression, each line starred. |
115 | - $content = '<?php '.PHP_EOL.'/*'.PHP_EOL.' * phpcs:disable'.PHP_EOL.' */'.PHP_EOL.'$var = FALSE;'.PHP_EOL.'/*'.PHP_EOL.' * phpcs:enable'.PHP_EOL.' */'; |
|
116 | - $file = new DummyFile($content, $ruleset, $config); |
|
115 | + $content = '<?php ' . PHP_EOL . '/*' . PHP_EOL . ' * phpcs:disable' . PHP_EOL . ' */' . PHP_EOL . '$var = FALSE;' . PHP_EOL . '/*' . PHP_EOL . ' * phpcs:enable' . PHP_EOL . ' */'; |
|
116 | + $file = new DummyFile( $content, $ruleset, $config ); |
|
117 | 117 | $file->process(); |
118 | 118 | |
119 | 119 | $errors = $file->getErrors(); |
120 | 120 | $numErrors = $file->getErrorCount(); |
121 | - $this->assertEquals(0, $numErrors); |
|
122 | - $this->assertCount(0, $errors); |
|
121 | + $this->assertEquals( 0, $numErrors ); |
|
122 | + $this->assertCount( 0, $errors ); |
|
123 | 123 | |
124 | 124 | // Process with multi-line block comment suppression, tab-indented. |
125 | - $content = '<?php '.PHP_EOL."\t".'/*'.PHP_EOL."\t".' * phpcs:disable'.PHP_EOL."\t".' */'.PHP_EOL."\t".'$var = FALSE;'.PHP_EOL."\t".'/*'.PHP_EOL.' * phpcs:enable'.PHP_EOL.' */'; |
|
126 | - $file = new DummyFile($content, $ruleset, $config); |
|
125 | + $content = '<?php ' . PHP_EOL . "\t" . '/*' . PHP_EOL . "\t" . ' * phpcs:disable' . PHP_EOL . "\t" . ' */' . PHP_EOL . "\t" . '$var = FALSE;' . PHP_EOL . "\t" . '/*' . PHP_EOL . ' * phpcs:enable' . PHP_EOL . ' */'; |
|
126 | + $file = new DummyFile( $content, $ruleset, $config ); |
|
127 | 127 | $file->process(); |
128 | 128 | |
129 | 129 | $errors = $file->getErrors(); |
130 | 130 | $numErrors = $file->getErrorCount(); |
131 | - $this->assertEquals(0, $numErrors); |
|
132 | - $this->assertCount(0, $errors); |
|
131 | + $this->assertEquals( 0, $numErrors ); |
|
132 | + $this->assertCount( 0, $errors ); |
|
133 | 133 | |
134 | 134 | // Process with block comment suppression (deprecated syntax). |
135 | - $content = '<?php '.PHP_EOL.'/* @codingStandardsIgnoreStart */'.PHP_EOL.'$var = FALSE;'.PHP_EOL.'/* @codingStandardsIgnoreEnd */'; |
|
136 | - $file = new DummyFile($content, $ruleset, $config); |
|
135 | + $content = '<?php ' . PHP_EOL . '/* @codingStandardsIgnoreStart */' . PHP_EOL . '$var = FALSE;' . PHP_EOL . '/* @codingStandardsIgnoreEnd */'; |
|
136 | + $file = new DummyFile( $content, $ruleset, $config ); |
|
137 | 137 | $file->process(); |
138 | 138 | |
139 | 139 | $errors = $file->getErrors(); |
140 | 140 | $numErrors = $file->getErrorCount(); |
141 | - $this->assertEquals(0, $numErrors); |
|
142 | - $this->assertCount(0, $errors); |
|
141 | + $this->assertEquals( 0, $numErrors ); |
|
142 | + $this->assertCount( 0, $errors ); |
|
143 | 143 | |
144 | 144 | // Process with multi-line block comment suppression (deprecated syntax). |
145 | - $content = '<?php '.PHP_EOL.'/*'.PHP_EOL.' @codingStandardsIgnoreStart'.PHP_EOL.' */'.PHP_EOL.'$var = FALSE;'.PHP_EOL.'/*'.PHP_EOL.' @codingStandardsIgnoreEnd'.PHP_EOL.' */'; |
|
146 | - $file = new DummyFile($content, $ruleset, $config); |
|
145 | + $content = '<?php ' . PHP_EOL . '/*' . PHP_EOL . ' @codingStandardsIgnoreStart' . PHP_EOL . ' */' . PHP_EOL . '$var = FALSE;' . PHP_EOL . '/*' . PHP_EOL . ' @codingStandardsIgnoreEnd' . PHP_EOL . ' */'; |
|
146 | + $file = new DummyFile( $content, $ruleset, $config ); |
|
147 | 147 | $file->process(); |
148 | 148 | |
149 | 149 | $errors = $file->getErrors(); |
150 | 150 | $numErrors = $file->getErrorCount(); |
151 | - $this->assertEquals(0, $numErrors); |
|
152 | - $this->assertCount(0, $errors); |
|
151 | + $this->assertEquals( 0, $numErrors ); |
|
152 | + $this->assertCount( 0, $errors ); |
|
153 | 153 | |
154 | 154 | // Process with a docblock suppression. |
155 | - $content = '<?php '.PHP_EOL.'/** phpcs:disable */'.PHP_EOL.'$var = FALSE;'.PHP_EOL.'/** phpcs:enable */'; |
|
156 | - $file = new DummyFile($content, $ruleset, $config); |
|
155 | + $content = '<?php ' . PHP_EOL . '/** phpcs:disable */' . PHP_EOL . '$var = FALSE;' . PHP_EOL . '/** phpcs:enable */'; |
|
156 | + $file = new DummyFile( $content, $ruleset, $config ); |
|
157 | 157 | $file->process(); |
158 | 158 | |
159 | 159 | $errors = $file->getErrors(); |
160 | 160 | $numErrors = $file->getErrorCount(); |
161 | - $this->assertEquals(0, $numErrors); |
|
162 | - $this->assertCount(0, $errors); |
|
161 | + $this->assertEquals( 0, $numErrors ); |
|
162 | + $this->assertCount( 0, $errors ); |
|
163 | 163 | |
164 | 164 | // Process with a docblock suppression (deprecated syntax). |
165 | - $content = '<?php '.PHP_EOL.'/** @codingStandardsIgnoreStart */'.PHP_EOL.'$var = FALSE;'.PHP_EOL.'/** @codingStandardsIgnoreEnd */'; |
|
166 | - $file = new DummyFile($content, $ruleset, $config); |
|
165 | + $content = '<?php ' . PHP_EOL . '/** @codingStandardsIgnoreStart */' . PHP_EOL . '$var = FALSE;' . PHP_EOL . '/** @codingStandardsIgnoreEnd */'; |
|
166 | + $file = new DummyFile( $content, $ruleset, $config ); |
|
167 | 167 | $file->process(); |
168 | 168 | |
169 | 169 | $errors = $file->getErrors(); |
170 | 170 | $numErrors = $file->getErrorCount(); |
171 | - $this->assertEquals(0, $numErrors); |
|
172 | - $this->assertCount(0, $errors); |
|
171 | + $this->assertEquals( 0, $numErrors ); |
|
172 | + $this->assertCount( 0, $errors ); |
|
173 | 173 | |
174 | 174 | }//end testSuppressError() |
175 | 175 | |
@@ -182,70 +182,70 @@ discard block |
||
182 | 182 | public function testSuppressSomeErrors() |
183 | 183 | { |
184 | 184 | $config = new Config(); |
185 | - $config->standards = ['Generic']; |
|
186 | - $config->sniffs = ['Generic.PHP.LowerCaseConstant']; |
|
185 | + $config->standards = [ 'Generic' ]; |
|
186 | + $config->sniffs = [ 'Generic.PHP.LowerCaseConstant' ]; |
|
187 | 187 | |
188 | - $ruleset = new Ruleset($config); |
|
188 | + $ruleset = new Ruleset( $config ); |
|
189 | 189 | |
190 | 190 | // Process without suppression. |
191 | - $content = '<?php '.PHP_EOL.'$var = FALSE;'.PHP_EOL.'$var = TRUE;'; |
|
192 | - $file = new DummyFile($content, $ruleset, $config); |
|
191 | + $content = '<?php ' . PHP_EOL . '$var = FALSE;' . PHP_EOL . '$var = TRUE;'; |
|
192 | + $file = new DummyFile( $content, $ruleset, $config ); |
|
193 | 193 | $file->process(); |
194 | 194 | |
195 | 195 | $errors = $file->getErrors(); |
196 | 196 | $numErrors = $file->getErrorCount(); |
197 | - $this->assertEquals(2, $numErrors); |
|
198 | - $this->assertCount(2, $errors); |
|
197 | + $this->assertEquals( 2, $numErrors ); |
|
198 | + $this->assertCount( 2, $errors ); |
|
199 | 199 | |
200 | 200 | // Process with suppression. |
201 | - $content = '<?php '.PHP_EOL.'// phpcs:disable'.PHP_EOL.'$var = FALSE;'.PHP_EOL.'// phpcs:enable'.PHP_EOL.'$var = TRUE;'; |
|
202 | - $file = new DummyFile($content, $ruleset, $config); |
|
201 | + $content = '<?php ' . PHP_EOL . '// phpcs:disable' . PHP_EOL . '$var = FALSE;' . PHP_EOL . '// phpcs:enable' . PHP_EOL . '$var = TRUE;'; |
|
202 | + $file = new DummyFile( $content, $ruleset, $config ); |
|
203 | 203 | $file->process(); |
204 | 204 | |
205 | 205 | $errors = $file->getErrors(); |
206 | 206 | $numErrors = $file->getErrorCount(); |
207 | - $this->assertEquals(1, $numErrors); |
|
208 | - $this->assertCount(1, $errors); |
|
207 | + $this->assertEquals( 1, $numErrors ); |
|
208 | + $this->assertCount( 1, $errors ); |
|
209 | 209 | |
210 | 210 | // Process with @ suppression. |
211 | - $content = '<?php '.PHP_EOL.'// @phpcs:disable'.PHP_EOL.'$var = FALSE;'.PHP_EOL.'// @phpcs:enable'.PHP_EOL.'$var = TRUE;'; |
|
212 | - $file = new DummyFile($content, $ruleset, $config); |
|
211 | + $content = '<?php ' . PHP_EOL . '// @phpcs:disable' . PHP_EOL . '$var = FALSE;' . PHP_EOL . '// @phpcs:enable' . PHP_EOL . '$var = TRUE;'; |
|
212 | + $file = new DummyFile( $content, $ruleset, $config ); |
|
213 | 213 | $file->process(); |
214 | 214 | |
215 | 215 | $errors = $file->getErrors(); |
216 | 216 | $numErrors = $file->getErrorCount(); |
217 | - $this->assertEquals(1, $numErrors); |
|
218 | - $this->assertCount(1, $errors); |
|
217 | + $this->assertEquals( 1, $numErrors ); |
|
218 | + $this->assertCount( 1, $errors ); |
|
219 | 219 | |
220 | 220 | // Process with suppression (deprecated syntax). |
221 | - $content = '<?php '.PHP_EOL.'// @codingStandardsIgnoreStart'.PHP_EOL.'$var = FALSE;'.PHP_EOL.'// @codingStandardsIgnoreEnd'.PHP_EOL.'$var = TRUE;'; |
|
222 | - $file = new DummyFile($content, $ruleset, $config); |
|
221 | + $content = '<?php ' . PHP_EOL . '// @codingStandardsIgnoreStart' . PHP_EOL . '$var = FALSE;' . PHP_EOL . '// @codingStandardsIgnoreEnd' . PHP_EOL . '$var = TRUE;'; |
|
222 | + $file = new DummyFile( $content, $ruleset, $config ); |
|
223 | 223 | $file->process(); |
224 | 224 | |
225 | 225 | $errors = $file->getErrors(); |
226 | 226 | $numErrors = $file->getErrorCount(); |
227 | - $this->assertEquals(1, $numErrors); |
|
228 | - $this->assertCount(1, $errors); |
|
227 | + $this->assertEquals( 1, $numErrors ); |
|
228 | + $this->assertCount( 1, $errors ); |
|
229 | 229 | |
230 | 230 | // Process with a PHPDoc block suppression. |
231 | - $content = '<?php '.PHP_EOL.'/** phpcs:disable */'.PHP_EOL.'$var = FALSE;'.PHP_EOL.'/** phpcs:enable */'.PHP_EOL.'$var = TRUE;'; |
|
232 | - $file = new DummyFile($content, $ruleset, $config); |
|
231 | + $content = '<?php ' . PHP_EOL . '/** phpcs:disable */' . PHP_EOL . '$var = FALSE;' . PHP_EOL . '/** phpcs:enable */' . PHP_EOL . '$var = TRUE;'; |
|
232 | + $file = new DummyFile( $content, $ruleset, $config ); |
|
233 | 233 | $file->process(); |
234 | 234 | |
235 | 235 | $errors = $file->getErrors(); |
236 | 236 | $numErrors = $file->getErrorCount(); |
237 | - $this->assertEquals(1, $numErrors); |
|
238 | - $this->assertCount(1, $errors); |
|
237 | + $this->assertEquals( 1, $numErrors ); |
|
238 | + $this->assertCount( 1, $errors ); |
|
239 | 239 | |
240 | 240 | // Process with a PHPDoc block suppression (deprecated syntax). |
241 | - $content = '<?php '.PHP_EOL.'/** @codingStandardsIgnoreStart */'.PHP_EOL.'$var = FALSE;'.PHP_EOL.'/** @codingStandardsIgnoreEnd */'.PHP_EOL.'$var = TRUE;'; |
|
242 | - $file = new DummyFile($content, $ruleset, $config); |
|
241 | + $content = '<?php ' . PHP_EOL . '/** @codingStandardsIgnoreStart */' . PHP_EOL . '$var = FALSE;' . PHP_EOL . '/** @codingStandardsIgnoreEnd */' . PHP_EOL . '$var = TRUE;'; |
|
242 | + $file = new DummyFile( $content, $ruleset, $config ); |
|
243 | 243 | $file->process(); |
244 | 244 | |
245 | 245 | $errors = $file->getErrors(); |
246 | 246 | $numErrors = $file->getErrorCount(); |
247 | - $this->assertEquals(1, $numErrors); |
|
248 | - $this->assertCount(1, $errors); |
|
247 | + $this->assertEquals( 1, $numErrors ); |
|
248 | + $this->assertCount( 1, $errors ); |
|
249 | 249 | |
250 | 250 | }//end testSuppressSomeErrors() |
251 | 251 | |
@@ -258,70 +258,70 @@ discard block |
||
258 | 258 | public function testSuppressWarning() |
259 | 259 | { |
260 | 260 | $config = new Config(); |
261 | - $config->standards = ['Generic']; |
|
262 | - $config->sniffs = ['Generic.Commenting.Todo']; |
|
261 | + $config->standards = [ 'Generic' ]; |
|
262 | + $config->sniffs = [ 'Generic.Commenting.Todo' ]; |
|
263 | 263 | |
264 | - $ruleset = new Ruleset($config); |
|
264 | + $ruleset = new Ruleset( $config ); |
|
265 | 265 | |
266 | 266 | // Process without suppression. |
267 | - $content = '<?php '.PHP_EOL.'//TODO: write some code'; |
|
268 | - $file = new DummyFile($content, $ruleset, $config); |
|
267 | + $content = '<?php ' . PHP_EOL . '//TODO: write some code'; |
|
268 | + $file = new DummyFile( $content, $ruleset, $config ); |
|
269 | 269 | $file->process(); |
270 | 270 | |
271 | 271 | $warnings = $file->getWarnings(); |
272 | 272 | $numWarnings = $file->getWarningCount(); |
273 | - $this->assertEquals(1, $numWarnings); |
|
274 | - $this->assertCount(1, $warnings); |
|
273 | + $this->assertEquals( 1, $numWarnings ); |
|
274 | + $this->assertCount( 1, $warnings ); |
|
275 | 275 | |
276 | 276 | // Process with suppression. |
277 | - $content = '<?php '.PHP_EOL.'// phpcs:disable'.PHP_EOL.'//TODO: write some code'.PHP_EOL.'// phpcs:enable'; |
|
278 | - $file = new DummyFile($content, $ruleset, $config); |
|
277 | + $content = '<?php ' . PHP_EOL . '// phpcs:disable' . PHP_EOL . '//TODO: write some code' . PHP_EOL . '// phpcs:enable'; |
|
278 | + $file = new DummyFile( $content, $ruleset, $config ); |
|
279 | 279 | $file->process(); |
280 | 280 | |
281 | 281 | $warnings = $file->getWarnings(); |
282 | 282 | $numWarnings = $file->getWarningCount(); |
283 | - $this->assertEquals(0, $numWarnings); |
|
284 | - $this->assertCount(0, $warnings); |
|
283 | + $this->assertEquals( 0, $numWarnings ); |
|
284 | + $this->assertCount( 0, $warnings ); |
|
285 | 285 | |
286 | 286 | // Process with @ suppression. |
287 | - $content = '<?php '.PHP_EOL.'// @phpcs:disable'.PHP_EOL.'//TODO: write some code'.PHP_EOL.'// @phpcs:enable'; |
|
288 | - $file = new DummyFile($content, $ruleset, $config); |
|
287 | + $content = '<?php ' . PHP_EOL . '// @phpcs:disable' . PHP_EOL . '//TODO: write some code' . PHP_EOL . '// @phpcs:enable'; |
|
288 | + $file = new DummyFile( $content, $ruleset, $config ); |
|
289 | 289 | $file->process(); |
290 | 290 | |
291 | 291 | $warnings = $file->getWarnings(); |
292 | 292 | $numWarnings = $file->getWarningCount(); |
293 | - $this->assertEquals(0, $numWarnings); |
|
294 | - $this->assertCount(0, $warnings); |
|
293 | + $this->assertEquals( 0, $numWarnings ); |
|
294 | + $this->assertCount( 0, $warnings ); |
|
295 | 295 | |
296 | 296 | // Process with suppression (deprecated syntax). |
297 | - $content = '<?php '.PHP_EOL.'// @codingStandardsIgnoreStart'.PHP_EOL.'//TODO: write some code'.PHP_EOL.'// @codingStandardsIgnoreEnd'; |
|
298 | - $file = new DummyFile($content, $ruleset, $config); |
|
297 | + $content = '<?php ' . PHP_EOL . '// @codingStandardsIgnoreStart' . PHP_EOL . '//TODO: write some code' . PHP_EOL . '// @codingStandardsIgnoreEnd'; |
|
298 | + $file = new DummyFile( $content, $ruleset, $config ); |
|
299 | 299 | $file->process(); |
300 | 300 | |
301 | 301 | $warnings = $file->getWarnings(); |
302 | 302 | $numWarnings = $file->getWarningCount(); |
303 | - $this->assertEquals(0, $numWarnings); |
|
304 | - $this->assertCount(0, $warnings); |
|
303 | + $this->assertEquals( 0, $numWarnings ); |
|
304 | + $this->assertCount( 0, $warnings ); |
|
305 | 305 | |
306 | 306 | // Process with a docblock suppression. |
307 | - $content = '<?php '.PHP_EOL.'/** phpcs:disable */'.PHP_EOL.'//TODO: write some code'.PHP_EOL.'/** phpcs:enable */'; |
|
308 | - $file = new DummyFile($content, $ruleset, $config); |
|
307 | + $content = '<?php ' . PHP_EOL . '/** phpcs:disable */' . PHP_EOL . '//TODO: write some code' . PHP_EOL . '/** phpcs:enable */'; |
|
308 | + $file = new DummyFile( $content, $ruleset, $config ); |
|
309 | 309 | $file->process(); |
310 | 310 | |
311 | 311 | $warnings = $file->getWarnings(); |
312 | 312 | $numWarnings = $file->getWarningCount(); |
313 | - $this->assertEquals(0, $numWarnings); |
|
314 | - $this->assertCount(0, $warnings); |
|
313 | + $this->assertEquals( 0, $numWarnings ); |
|
314 | + $this->assertCount( 0, $warnings ); |
|
315 | 315 | |
316 | 316 | // Process with a docblock suppression (deprecated syntax). |
317 | - $content = '<?php '.PHP_EOL.'/** @codingStandardsIgnoreStart */'.PHP_EOL.'//TODO: write some code'.PHP_EOL.'/** @codingStandardsIgnoreEnd */'; |
|
318 | - $file = new DummyFile($content, $ruleset, $config); |
|
317 | + $content = '<?php ' . PHP_EOL . '/** @codingStandardsIgnoreStart */' . PHP_EOL . '//TODO: write some code' . PHP_EOL . '/** @codingStandardsIgnoreEnd */'; |
|
318 | + $file = new DummyFile( $content, $ruleset, $config ); |
|
319 | 319 | $file->process(); |
320 | 320 | |
321 | 321 | $warnings = $file->getWarnings(); |
322 | 322 | $numWarnings = $file->getWarningCount(); |
323 | - $this->assertEquals(0, $numWarnings); |
|
324 | - $this->assertCount(0, $warnings); |
|
323 | + $this->assertEquals( 0, $numWarnings ); |
|
324 | + $this->assertCount( 0, $warnings ); |
|
325 | 325 | |
326 | 326 | }//end testSuppressWarning() |
327 | 327 | |
@@ -334,100 +334,100 @@ discard block |
||
334 | 334 | public function testSuppressLine() |
335 | 335 | { |
336 | 336 | $config = new Config(); |
337 | - $config->standards = ['Generic']; |
|
338 | - $config->sniffs = ['Generic.PHP.LowerCaseConstant']; |
|
337 | + $config->standards = [ 'Generic' ]; |
|
338 | + $config->sniffs = [ 'Generic.PHP.LowerCaseConstant' ]; |
|
339 | 339 | |
340 | - $ruleset = new Ruleset($config); |
|
340 | + $ruleset = new Ruleset( $config ); |
|
341 | 341 | |
342 | 342 | // Process without suppression. |
343 | - $content = '<?php '.PHP_EOL.'$var = FALSE;'.PHP_EOL.'$var = FALSE;'; |
|
344 | - $file = new DummyFile($content, $ruleset, $config); |
|
343 | + $content = '<?php ' . PHP_EOL . '$var = FALSE;' . PHP_EOL . '$var = FALSE;'; |
|
344 | + $file = new DummyFile( $content, $ruleset, $config ); |
|
345 | 345 | $file->process(); |
346 | 346 | |
347 | 347 | $errors = $file->getErrors(); |
348 | 348 | $numErrors = $file->getErrorCount(); |
349 | - $this->assertEquals(2, $numErrors); |
|
350 | - $this->assertCount(2, $errors); |
|
349 | + $this->assertEquals( 2, $numErrors ); |
|
350 | + $this->assertCount( 2, $errors ); |
|
351 | 351 | |
352 | 352 | // Process with suppression on line before. |
353 | - $content = '<?php '.PHP_EOL.'// phpcs:ignore'.PHP_EOL.'$var = FALSE;'.PHP_EOL.'$var = FALSE;'; |
|
354 | - $file = new DummyFile($content, $ruleset, $config); |
|
353 | + $content = '<?php ' . PHP_EOL . '// phpcs:ignore' . PHP_EOL . '$var = FALSE;' . PHP_EOL . '$var = FALSE;'; |
|
354 | + $file = new DummyFile( $content, $ruleset, $config ); |
|
355 | 355 | $file->process(); |
356 | 356 | |
357 | 357 | $errors = $file->getErrors(); |
358 | 358 | $numErrors = $file->getErrorCount(); |
359 | - $this->assertEquals(1, $numErrors); |
|
360 | - $this->assertCount(1, $errors); |
|
359 | + $this->assertEquals( 1, $numErrors ); |
|
360 | + $this->assertCount( 1, $errors ); |
|
361 | 361 | |
362 | 362 | // Process with @ suppression on line before. |
363 | - $content = '<?php '.PHP_EOL.'// @phpcs:ignore'.PHP_EOL.'$var = FALSE;'.PHP_EOL.'$var = FALSE;'; |
|
364 | - $file = new DummyFile($content, $ruleset, $config); |
|
363 | + $content = '<?php ' . PHP_EOL . '// @phpcs:ignore' . PHP_EOL . '$var = FALSE;' . PHP_EOL . '$var = FALSE;'; |
|
364 | + $file = new DummyFile( $content, $ruleset, $config ); |
|
365 | 365 | $file->process(); |
366 | 366 | |
367 | 367 | $errors = $file->getErrors(); |
368 | 368 | $numErrors = $file->getErrorCount(); |
369 | - $this->assertEquals(1, $numErrors); |
|
370 | - $this->assertCount(1, $errors); |
|
369 | + $this->assertEquals( 1, $numErrors ); |
|
370 | + $this->assertCount( 1, $errors ); |
|
371 | 371 | |
372 | 372 | // Process with suppression on line before. |
373 | - $content = '<?php '.PHP_EOL.'/* phpcs:ignore */'.PHP_EOL.'$var = FALSE;'.PHP_EOL.'$var = FALSE;'; |
|
374 | - $file = new DummyFile($content, $ruleset, $config); |
|
373 | + $content = '<?php ' . PHP_EOL . '/* phpcs:ignore */' . PHP_EOL . '$var = FALSE;' . PHP_EOL . '$var = FALSE;'; |
|
374 | + $file = new DummyFile( $content, $ruleset, $config ); |
|
375 | 375 | $file->process(); |
376 | 376 | |
377 | 377 | $errors = $file->getErrors(); |
378 | 378 | $numErrors = $file->getErrorCount(); |
379 | - $this->assertEquals(1, $numErrors); |
|
380 | - $this->assertCount(1, $errors); |
|
379 | + $this->assertEquals( 1, $numErrors ); |
|
380 | + $this->assertCount( 1, $errors ); |
|
381 | 381 | |
382 | 382 | // Process with @ suppression on line before. |
383 | - $content = '<?php '.PHP_EOL.'/* @phpcs:ignore */'.PHP_EOL.'$var = FALSE;'.PHP_EOL.'$var = FALSE;'; |
|
384 | - $file = new DummyFile($content, $ruleset, $config); |
|
383 | + $content = '<?php ' . PHP_EOL . '/* @phpcs:ignore */' . PHP_EOL . '$var = FALSE;' . PHP_EOL . '$var = FALSE;'; |
|
384 | + $file = new DummyFile( $content, $ruleset, $config ); |
|
385 | 385 | $file->process(); |
386 | 386 | |
387 | 387 | $errors = $file->getErrors(); |
388 | 388 | $numErrors = $file->getErrorCount(); |
389 | - $this->assertEquals(1, $numErrors); |
|
390 | - $this->assertCount(1, $errors); |
|
389 | + $this->assertEquals( 1, $numErrors ); |
|
390 | + $this->assertCount( 1, $errors ); |
|
391 | 391 | |
392 | 392 | // Process with suppression on line before (deprecated syntax). |
393 | - $content = '<?php '.PHP_EOL.'// @codingStandardsIgnoreLine'.PHP_EOL.'$var = FALSE;'.PHP_EOL.'$var = FALSE;'; |
|
394 | - $file = new DummyFile($content, $ruleset, $config); |
|
393 | + $content = '<?php ' . PHP_EOL . '// @codingStandardsIgnoreLine' . PHP_EOL . '$var = FALSE;' . PHP_EOL . '$var = FALSE;'; |
|
394 | + $file = new DummyFile( $content, $ruleset, $config ); |
|
395 | 395 | $file->process(); |
396 | 396 | |
397 | 397 | $errors = $file->getErrors(); |
398 | 398 | $numErrors = $file->getErrorCount(); |
399 | - $this->assertEquals(1, $numErrors); |
|
400 | - $this->assertCount(1, $errors); |
|
399 | + $this->assertEquals( 1, $numErrors ); |
|
400 | + $this->assertCount( 1, $errors ); |
|
401 | 401 | |
402 | 402 | // Process with suppression on same line. |
403 | - $content = '<?php '.PHP_EOL.'$var = FALSE; // phpcs:ignore'.PHP_EOL.'$var = FALSE;'; |
|
404 | - $file = new DummyFile($content, $ruleset, $config); |
|
403 | + $content = '<?php ' . PHP_EOL . '$var = FALSE; // phpcs:ignore' . PHP_EOL . '$var = FALSE;'; |
|
404 | + $file = new DummyFile( $content, $ruleset, $config ); |
|
405 | 405 | $file->process(); |
406 | 406 | |
407 | 407 | $errors = $file->getErrors(); |
408 | 408 | $numErrors = $file->getErrorCount(); |
409 | - $this->assertEquals(1, $numErrors); |
|
410 | - $this->assertCount(1, $errors); |
|
409 | + $this->assertEquals( 1, $numErrors ); |
|
410 | + $this->assertCount( 1, $errors ); |
|
411 | 411 | |
412 | 412 | // Process with @ suppression on same line. |
413 | - $content = '<?php '.PHP_EOL.'$var = FALSE; // @phpcs:ignore'.PHP_EOL.'$var = FALSE;'; |
|
414 | - $file = new DummyFile($content, $ruleset, $config); |
|
413 | + $content = '<?php ' . PHP_EOL . '$var = FALSE; // @phpcs:ignore' . PHP_EOL . '$var = FALSE;'; |
|
414 | + $file = new DummyFile( $content, $ruleset, $config ); |
|
415 | 415 | $file->process(); |
416 | 416 | |
417 | 417 | $errors = $file->getErrors(); |
418 | 418 | $numErrors = $file->getErrorCount(); |
419 | - $this->assertEquals(1, $numErrors); |
|
420 | - $this->assertCount(1, $errors); |
|
419 | + $this->assertEquals( 1, $numErrors ); |
|
420 | + $this->assertCount( 1, $errors ); |
|
421 | 421 | |
422 | 422 | // Process with suppression on same line (deprecated syntax). |
423 | - $content = '<?php '.PHP_EOL.'$var = FALSE; // @codingStandardsIgnoreLine'.PHP_EOL.'$var = FALSE;'; |
|
424 | - $file = new DummyFile($content, $ruleset, $config); |
|
423 | + $content = '<?php ' . PHP_EOL . '$var = FALSE; // @codingStandardsIgnoreLine' . PHP_EOL . '$var = FALSE;'; |
|
424 | + $file = new DummyFile( $content, $ruleset, $config ); |
|
425 | 425 | $file->process(); |
426 | 426 | |
427 | 427 | $errors = $file->getErrors(); |
428 | 428 | $numErrors = $file->getErrorCount(); |
429 | - $this->assertEquals(1, $numErrors); |
|
430 | - $this->assertCount(1, $errors); |
|
429 | + $this->assertEquals( 1, $numErrors ); |
|
430 | + $this->assertCount( 1, $errors ); |
|
431 | 431 | |
432 | 432 | }//end testSuppressLine() |
433 | 433 | |
@@ -440,70 +440,70 @@ discard block |
||
440 | 440 | public function testNestedSuppressLine() |
441 | 441 | { |
442 | 442 | $config = new Config(); |
443 | - $config->standards = ['Generic']; |
|
444 | - $config->sniffs = ['Generic.PHP.LowerCaseConstant']; |
|
443 | + $config->standards = [ 'Generic' ]; |
|
444 | + $config->sniffs = [ 'Generic.PHP.LowerCaseConstant' ]; |
|
445 | 445 | |
446 | - $ruleset = new Ruleset($config); |
|
446 | + $ruleset = new Ruleset( $config ); |
|
447 | 447 | |
448 | 448 | // Process with disable/enable suppression and no single line suppression. |
449 | - $content = '<?php '.PHP_EOL.'// phpcs:disable'.PHP_EOL.'$var = FALSE;'.PHP_EOL.'$var = TRUE;'.PHP_EOL.'// phpcs:enable'; |
|
450 | - $file = new DummyFile($content, $ruleset, $config); |
|
449 | + $content = '<?php ' . PHP_EOL . '// phpcs:disable' . PHP_EOL . '$var = FALSE;' . PHP_EOL . '$var = TRUE;' . PHP_EOL . '// phpcs:enable'; |
|
450 | + $file = new DummyFile( $content, $ruleset, $config ); |
|
451 | 451 | $file->process(); |
452 | 452 | |
453 | 453 | $errors = $file->getErrors(); |
454 | 454 | $numErrors = $file->getErrorCount(); |
455 | - $this->assertEquals(0, $numErrors); |
|
456 | - $this->assertCount(0, $errors); |
|
455 | + $this->assertEquals( 0, $numErrors ); |
|
456 | + $this->assertCount( 0, $errors ); |
|
457 | 457 | |
458 | 458 | // Process with disable/enable @ suppression and no single line suppression. |
459 | - $content = '<?php '.PHP_EOL.'// @phpcs:disable'.PHP_EOL.'$var = FALSE;'.PHP_EOL.'$var = TRUE;'.PHP_EOL.'// @phpcs:enable'; |
|
460 | - $file = new DummyFile($content, $ruleset, $config); |
|
459 | + $content = '<?php ' . PHP_EOL . '// @phpcs:disable' . PHP_EOL . '$var = FALSE;' . PHP_EOL . '$var = TRUE;' . PHP_EOL . '// @phpcs:enable'; |
|
460 | + $file = new DummyFile( $content, $ruleset, $config ); |
|
461 | 461 | $file->process(); |
462 | 462 | |
463 | 463 | $errors = $file->getErrors(); |
464 | 464 | $numErrors = $file->getErrorCount(); |
465 | - $this->assertEquals(0, $numErrors); |
|
466 | - $this->assertCount(0, $errors); |
|
465 | + $this->assertEquals( 0, $numErrors ); |
|
466 | + $this->assertCount( 0, $errors ); |
|
467 | 467 | |
468 | 468 | // Process with disable/enable suppression and no single line suppression (deprecated syntax). |
469 | - $content = '<?php '.PHP_EOL.'// @codingStandardsIgnoreStart'.PHP_EOL.'$var = FALSE;'.PHP_EOL.'$var = TRUE;'.PHP_EOL.'// @codingStandardsIgnoreEnd'; |
|
470 | - $file = new DummyFile($content, $ruleset, $config); |
|
469 | + $content = '<?php ' . PHP_EOL . '// @codingStandardsIgnoreStart' . PHP_EOL . '$var = FALSE;' . PHP_EOL . '$var = TRUE;' . PHP_EOL . '// @codingStandardsIgnoreEnd'; |
|
470 | + $file = new DummyFile( $content, $ruleset, $config ); |
|
471 | 471 | $file->process(); |
472 | 472 | |
473 | 473 | $errors = $file->getErrors(); |
474 | 474 | $numErrors = $file->getErrorCount(); |
475 | - $this->assertEquals(0, $numErrors); |
|
476 | - $this->assertCount(0, $errors); |
|
475 | + $this->assertEquals( 0, $numErrors ); |
|
476 | + $this->assertCount( 0, $errors ); |
|
477 | 477 | |
478 | 478 | // Process with line suppression nested within disable/enable suppression. |
479 | - $content = '<?php '.PHP_EOL.'// phpcs:disable'.PHP_EOL.'// phpcs:ignore'.PHP_EOL.'$var = FALSE;'.PHP_EOL.'$var = TRUE;'.PHP_EOL.'// phpcs:enable'; |
|
480 | - $file = new DummyFile($content, $ruleset, $config); |
|
479 | + $content = '<?php ' . PHP_EOL . '// phpcs:disable' . PHP_EOL . '// phpcs:ignore' . PHP_EOL . '$var = FALSE;' . PHP_EOL . '$var = TRUE;' . PHP_EOL . '// phpcs:enable'; |
|
480 | + $file = new DummyFile( $content, $ruleset, $config ); |
|
481 | 481 | $file->process(); |
482 | 482 | |
483 | 483 | $errors = $file->getErrors(); |
484 | 484 | $numErrors = $file->getErrorCount(); |
485 | - $this->assertEquals(0, $numErrors); |
|
486 | - $this->assertCount(0, $errors); |
|
485 | + $this->assertEquals( 0, $numErrors ); |
|
486 | + $this->assertCount( 0, $errors ); |
|
487 | 487 | |
488 | 488 | // Process with line @ suppression nested within disable/enable @ suppression. |
489 | - $content = '<?php '.PHP_EOL.'// @phpcs:disable'.PHP_EOL.'// @phpcs:ignore'.PHP_EOL.'$var = FALSE;'.PHP_EOL.'$var = TRUE;'.PHP_EOL.'// @phpcs:enable'; |
|
490 | - $file = new DummyFile($content, $ruleset, $config); |
|
489 | + $content = '<?php ' . PHP_EOL . '// @phpcs:disable' . PHP_EOL . '// @phpcs:ignore' . PHP_EOL . '$var = FALSE;' . PHP_EOL . '$var = TRUE;' . PHP_EOL . '// @phpcs:enable'; |
|
490 | + $file = new DummyFile( $content, $ruleset, $config ); |
|
491 | 491 | $file->process(); |
492 | 492 | |
493 | 493 | $errors = $file->getErrors(); |
494 | 494 | $numErrors = $file->getErrorCount(); |
495 | - $this->assertEquals(0, $numErrors); |
|
496 | - $this->assertCount(0, $errors); |
|
495 | + $this->assertEquals( 0, $numErrors ); |
|
496 | + $this->assertCount( 0, $errors ); |
|
497 | 497 | |
498 | 498 | // Process with line suppression nested within disable/enable suppression (deprecated syntax). |
499 | - $content = '<?php '.PHP_EOL.'// @codingStandardsIgnoreStart'.PHP_EOL.'// @codingStandardsIgnoreLine'.PHP_EOL.'$var = FALSE;'.PHP_EOL.'$var = TRUE;'.PHP_EOL.'// @codingStandardsIgnoreEnd'; |
|
500 | - $file = new DummyFile($content, $ruleset, $config); |
|
499 | + $content = '<?php ' . PHP_EOL . '// @codingStandardsIgnoreStart' . PHP_EOL . '// @codingStandardsIgnoreLine' . PHP_EOL . '$var = FALSE;' . PHP_EOL . '$var = TRUE;' . PHP_EOL . '// @codingStandardsIgnoreEnd'; |
|
500 | + $file = new DummyFile( $content, $ruleset, $config ); |
|
501 | 501 | $file->process(); |
502 | 502 | |
503 | 503 | $errors = $file->getErrors(); |
504 | 504 | $numErrors = $file->getErrorCount(); |
505 | - $this->assertEquals(0, $numErrors); |
|
506 | - $this->assertCount(0, $errors); |
|
505 | + $this->assertEquals( 0, $numErrors ); |
|
506 | + $this->assertCount( 0, $errors ); |
|
507 | 507 | |
508 | 508 | }//end testNestedSuppressLine() |
509 | 509 | |
@@ -516,77 +516,77 @@ discard block |
||
516 | 516 | public function testSuppressScope() |
517 | 517 | { |
518 | 518 | $config = new Config(); |
519 | - $config->standards = ['PEAR']; |
|
520 | - $config->sniffs = ['PEAR.NamingConventions.ValidVariableName']; |
|
519 | + $config->standards = [ 'PEAR' ]; |
|
520 | + $config->sniffs = [ 'PEAR.NamingConventions.ValidVariableName' ]; |
|
521 | 521 | |
522 | - $ruleset = new Ruleset($config); |
|
522 | + $ruleset = new Ruleset( $config ); |
|
523 | 523 | |
524 | 524 | // Process without suppression. |
525 | - $content = '<?php '.PHP_EOL.'class MyClass() {'.PHP_EOL.'function myFunction() {'.PHP_EOL.'$this->foo();'.PHP_EOL.'}'.PHP_EOL.'}'; |
|
526 | - $file = new DummyFile($content, $ruleset, $config); |
|
525 | + $content = '<?php ' . PHP_EOL . 'class MyClass() {' . PHP_EOL . 'function myFunction() {' . PHP_EOL . '$this->foo();' . PHP_EOL . '}' . PHP_EOL . '}'; |
|
526 | + $file = new DummyFile( $content, $ruleset, $config ); |
|
527 | 527 | $file->process(); |
528 | 528 | |
529 | 529 | $errors = $file->getErrors(); |
530 | 530 | $numErrors = $file->getErrorCount(); |
531 | - $this->assertEquals(0, $numErrors); |
|
532 | - $this->assertCount(0, $errors); |
|
531 | + $this->assertEquals( 0, $numErrors ); |
|
532 | + $this->assertCount( 0, $errors ); |
|
533 | 533 | |
534 | 534 | // Process with suppression. |
535 | - $content = '<?php '.PHP_EOL.'class MyClass() {'.PHP_EOL.'//phpcs:disable'.PHP_EOL.'function myFunction() {'.PHP_EOL.'//phpcs:enable'.PHP_EOL.'$this->foo();'.PHP_EOL.'}'.PHP_EOL.'}'; |
|
536 | - $file = new DummyFile($content, $ruleset, $config); |
|
535 | + $content = '<?php ' . PHP_EOL . 'class MyClass() {' . PHP_EOL . '//phpcs:disable' . PHP_EOL . 'function myFunction() {' . PHP_EOL . '//phpcs:enable' . PHP_EOL . '$this->foo();' . PHP_EOL . '}' . PHP_EOL . '}'; |
|
536 | + $file = new DummyFile( $content, $ruleset, $config ); |
|
537 | 537 | $file->process(); |
538 | 538 | |
539 | 539 | $errors = $file->getErrors(); |
540 | 540 | $numErrors = $file->getErrorCount(); |
541 | - $this->assertEquals(0, $numErrors); |
|
542 | - $this->assertCount(0, $errors); |
|
541 | + $this->assertEquals( 0, $numErrors ); |
|
542 | + $this->assertCount( 0, $errors ); |
|
543 | 543 | |
544 | 544 | // Process with suppression. |
545 | - $content = '<?php '.PHP_EOL.'class MyClass() {'.PHP_EOL.'//@phpcs:disable'.PHP_EOL.'function myFunction() {'.PHP_EOL.'//@phpcs:enable'.PHP_EOL.'$this->foo();'.PHP_EOL.'}'.PHP_EOL.'}'; |
|
546 | - $file = new DummyFile($content, $ruleset, $config); |
|
545 | + $content = '<?php ' . PHP_EOL . 'class MyClass() {' . PHP_EOL . '//@phpcs:disable' . PHP_EOL . 'function myFunction() {' . PHP_EOL . '//@phpcs:enable' . PHP_EOL . '$this->foo();' . PHP_EOL . '}' . PHP_EOL . '}'; |
|
546 | + $file = new DummyFile( $content, $ruleset, $config ); |
|
547 | 547 | $file->process(); |
548 | 548 | |
549 | 549 | $errors = $file->getErrors(); |
550 | 550 | $numErrors = $file->getErrorCount(); |
551 | - $this->assertEquals(0, $numErrors); |
|
552 | - $this->assertCount(0, $errors); |
|
551 | + $this->assertEquals( 0, $numErrors ); |
|
552 | + $this->assertCount( 0, $errors ); |
|
553 | 553 | |
554 | 554 | // Process with suppression (deprecated syntax). |
555 | - $content = '<?php '.PHP_EOL.'class MyClass() {'.PHP_EOL.'//@codingStandardsIgnoreStart'.PHP_EOL.'function myFunction() {'.PHP_EOL.'//@codingStandardsIgnoreEnd'.PHP_EOL.'$this->foo();'.PHP_EOL.'}'.PHP_EOL.'}'; |
|
556 | - $file = new DummyFile($content, $ruleset, $config); |
|
555 | + $content = '<?php ' . PHP_EOL . 'class MyClass() {' . PHP_EOL . '//@codingStandardsIgnoreStart' . PHP_EOL . 'function myFunction() {' . PHP_EOL . '//@codingStandardsIgnoreEnd' . PHP_EOL . '$this->foo();' . PHP_EOL . '}' . PHP_EOL . '}'; |
|
556 | + $file = new DummyFile( $content, $ruleset, $config ); |
|
557 | 557 | $file->process(); |
558 | 558 | |
559 | 559 | $errors = $file->getErrors(); |
560 | 560 | $numErrors = $file->getErrorCount(); |
561 | - $this->assertEquals(0, $numErrors); |
|
562 | - $this->assertCount(0, $errors); |
|
561 | + $this->assertEquals( 0, $numErrors ); |
|
562 | + $this->assertCount( 0, $errors ); |
|
563 | 563 | |
564 | 564 | // Process with a docblock suppression. |
565 | - $content = '<?php '.PHP_EOL.'class MyClass() {'.PHP_EOL.'/** phpcs:disable */'.PHP_EOL.'function myFunction() {'.PHP_EOL.'/** phpcs:enable */'.PHP_EOL.'$this->foo();'.PHP_EOL.'}'.PHP_EOL.'}'; |
|
566 | - $file = new DummyFile($content, $ruleset, $config); |
|
565 | + $content = '<?php ' . PHP_EOL . 'class MyClass() {' . PHP_EOL . '/** phpcs:disable */' . PHP_EOL . 'function myFunction() {' . PHP_EOL . '/** phpcs:enable */' . PHP_EOL . '$this->foo();' . PHP_EOL . '}' . PHP_EOL . '}'; |
|
566 | + $file = new DummyFile( $content, $ruleset, $config ); |
|
567 | 567 | |
568 | 568 | $errors = $file->getErrors(); |
569 | 569 | $numErrors = $file->getErrorCount(); |
570 | - $this->assertEquals(0, $numErrors); |
|
571 | - $this->assertCount(0, $errors); |
|
570 | + $this->assertEquals( 0, $numErrors ); |
|
571 | + $this->assertCount( 0, $errors ); |
|
572 | 572 | |
573 | 573 | // Process with a docblock @ suppression. |
574 | - $content = '<?php '.PHP_EOL.'class MyClass() {'.PHP_EOL.'/** @phpcs:disable */'.PHP_EOL.'function myFunction() {'.PHP_EOL.'/** @phpcs:enable */'.PHP_EOL.'$this->foo();'.PHP_EOL.'}'.PHP_EOL.'}'; |
|
575 | - $file = new DummyFile($content, $ruleset, $config); |
|
574 | + $content = '<?php ' . PHP_EOL . 'class MyClass() {' . PHP_EOL . '/** @phpcs:disable */' . PHP_EOL . 'function myFunction() {' . PHP_EOL . '/** @phpcs:enable */' . PHP_EOL . '$this->foo();' . PHP_EOL . '}' . PHP_EOL . '}'; |
|
575 | + $file = new DummyFile( $content, $ruleset, $config ); |
|
576 | 576 | |
577 | 577 | $errors = $file->getErrors(); |
578 | 578 | $numErrors = $file->getErrorCount(); |
579 | - $this->assertEquals(0, $numErrors); |
|
580 | - $this->assertCount(0, $errors); |
|
579 | + $this->assertEquals( 0, $numErrors ); |
|
580 | + $this->assertCount( 0, $errors ); |
|
581 | 581 | |
582 | 582 | // Process with a docblock suppression (deprecated syntax). |
583 | - $content = '<?php '.PHP_EOL.'class MyClass() {'.PHP_EOL.'/** @codingStandardsIgnoreStart */'.PHP_EOL.'function myFunction() {'.PHP_EOL.'/** @codingStandardsIgnoreEnd */'.PHP_EOL.'$this->foo();'.PHP_EOL.'}'.PHP_EOL.'}'; |
|
584 | - $file = new DummyFile($content, $ruleset, $config); |
|
583 | + $content = '<?php ' . PHP_EOL . 'class MyClass() {' . PHP_EOL . '/** @codingStandardsIgnoreStart */' . PHP_EOL . 'function myFunction() {' . PHP_EOL . '/** @codingStandardsIgnoreEnd */' . PHP_EOL . '$this->foo();' . PHP_EOL . '}' . PHP_EOL . '}'; |
|
584 | + $file = new DummyFile( $content, $ruleset, $config ); |
|
585 | 585 | |
586 | 586 | $errors = $file->getErrors(); |
587 | 587 | $numErrors = $file->getErrorCount(); |
588 | - $this->assertEquals(0, $numErrors); |
|
589 | - $this->assertCount(0, $errors); |
|
588 | + $this->assertEquals( 0, $numErrors ); |
|
589 | + $this->assertCount( 0, $errors ); |
|
590 | 590 | |
591 | 591 | }//end testSuppressScope() |
592 | 592 | |
@@ -599,140 +599,140 @@ discard block |
||
599 | 599 | public function testSuppressFile() |
600 | 600 | { |
601 | 601 | $config = new Config(); |
602 | - $config->standards = ['Generic']; |
|
603 | - $config->sniffs = ['Generic.Commenting.Todo']; |
|
602 | + $config->standards = [ 'Generic' ]; |
|
603 | + $config->sniffs = [ 'Generic.Commenting.Todo' ]; |
|
604 | 604 | |
605 | - $ruleset = new Ruleset($config); |
|
605 | + $ruleset = new Ruleset( $config ); |
|
606 | 606 | |
607 | 607 | // Process without suppression. |
608 | - $content = '<?php '.PHP_EOL.'//TODO: write some code'; |
|
609 | - $file = new DummyFile($content, $ruleset, $config); |
|
608 | + $content = '<?php ' . PHP_EOL . '//TODO: write some code'; |
|
609 | + $file = new DummyFile( $content, $ruleset, $config ); |
|
610 | 610 | $file->process(); |
611 | 611 | |
612 | 612 | $warnings = $file->getWarnings(); |
613 | 613 | $numWarnings = $file->getWarningCount(); |
614 | - $this->assertEquals(1, $numWarnings); |
|
615 | - $this->assertCount(1, $warnings); |
|
614 | + $this->assertEquals( 1, $numWarnings ); |
|
615 | + $this->assertCount( 1, $warnings ); |
|
616 | 616 | |
617 | 617 | // Process with suppression. |
618 | - $content = '<?php '.PHP_EOL.'// phpcs:ignoreFile'.PHP_EOL.'//TODO: write some code'; |
|
619 | - $file = new DummyFile($content, $ruleset, $config); |
|
618 | + $content = '<?php ' . PHP_EOL . '// phpcs:ignoreFile' . PHP_EOL . '//TODO: write some code'; |
|
619 | + $file = new DummyFile( $content, $ruleset, $config ); |
|
620 | 620 | $file->process(); |
621 | 621 | |
622 | 622 | $warnings = $file->getWarnings(); |
623 | 623 | $numWarnings = $file->getWarningCount(); |
624 | - $this->assertEquals(0, $numWarnings); |
|
625 | - $this->assertCount(0, $warnings); |
|
624 | + $this->assertEquals( 0, $numWarnings ); |
|
625 | + $this->assertCount( 0, $warnings ); |
|
626 | 626 | |
627 | 627 | // Process with @ suppression. |
628 | - $content = '<?php '.PHP_EOL.'// @phpcs:ignoreFile'.PHP_EOL.'//TODO: write some code'; |
|
629 | - $file = new DummyFile($content, $ruleset, $config); |
|
628 | + $content = '<?php ' . PHP_EOL . '// @phpcs:ignoreFile' . PHP_EOL . '//TODO: write some code'; |
|
629 | + $file = new DummyFile( $content, $ruleset, $config ); |
|
630 | 630 | $file->process(); |
631 | 631 | |
632 | 632 | $warnings = $file->getWarnings(); |
633 | 633 | $numWarnings = $file->getWarningCount(); |
634 | - $this->assertEquals(0, $numWarnings); |
|
635 | - $this->assertCount(0, $warnings); |
|
634 | + $this->assertEquals( 0, $numWarnings ); |
|
635 | + $this->assertCount( 0, $warnings ); |
|
636 | 636 | |
637 | 637 | // Process with suppression (deprecated syntax). |
638 | - $content = '<?php '.PHP_EOL.'// @codingStandardsIgnoreFile'.PHP_EOL.'//TODO: write some code'; |
|
639 | - $file = new DummyFile($content, $ruleset, $config); |
|
638 | + $content = '<?php ' . PHP_EOL . '// @codingStandardsIgnoreFile' . PHP_EOL . '//TODO: write some code'; |
|
639 | + $file = new DummyFile( $content, $ruleset, $config ); |
|
640 | 640 | $file->process(); |
641 | 641 | |
642 | 642 | $warnings = $file->getWarnings(); |
643 | 643 | $numWarnings = $file->getWarningCount(); |
644 | - $this->assertEquals(0, $numWarnings); |
|
645 | - $this->assertCount(0, $warnings); |
|
644 | + $this->assertEquals( 0, $numWarnings ); |
|
645 | + $this->assertCount( 0, $warnings ); |
|
646 | 646 | |
647 | 647 | // Process mixed case. |
648 | - $content = '<?php '.PHP_EOL.'// PHPCS:Ignorefile'.PHP_EOL.'//TODO: write some code'; |
|
649 | - $file = new DummyFile($content, $ruleset, $config); |
|
648 | + $content = '<?php ' . PHP_EOL . '// PHPCS:Ignorefile' . PHP_EOL . '//TODO: write some code'; |
|
649 | + $file = new DummyFile( $content, $ruleset, $config ); |
|
650 | 650 | $file->process(); |
651 | 651 | |
652 | 652 | $warnings = $file->getWarnings(); |
653 | 653 | $numWarnings = $file->getWarningCount(); |
654 | - $this->assertEquals(0, $numWarnings); |
|
655 | - $this->assertCount(0, $warnings); |
|
654 | + $this->assertEquals( 0, $numWarnings ); |
|
655 | + $this->assertCount( 0, $warnings ); |
|
656 | 656 | |
657 | 657 | // Process late comment. |
658 | - $content = '<?php '.PHP_EOL.'class MyClass {}'.PHP_EOL.'$foo = new MyClass()'.PHP_EOL.'// phpcs:ignoreFile'; |
|
659 | - $file = new DummyFile($content, $ruleset, $config); |
|
658 | + $content = '<?php ' . PHP_EOL . 'class MyClass {}' . PHP_EOL . '$foo = new MyClass()' . PHP_EOL . '// phpcs:ignoreFile'; |
|
659 | + $file = new DummyFile( $content, $ruleset, $config ); |
|
660 | 660 | $file->process(); |
661 | 661 | |
662 | 662 | $warnings = $file->getWarnings(); |
663 | 663 | $numWarnings = $file->getWarningCount(); |
664 | - $this->assertEquals(0, $numWarnings); |
|
665 | - $this->assertCount(0, $warnings); |
|
664 | + $this->assertEquals( 0, $numWarnings ); |
|
665 | + $this->assertCount( 0, $warnings ); |
|
666 | 666 | |
667 | 667 | // Process late comment (deprecated syntax). |
668 | - $content = '<?php '.PHP_EOL.'class MyClass {}'.PHP_EOL.'$foo = new MyClass()'.PHP_EOL.'// @codingStandardsIgnoreFile'; |
|
669 | - $file = new DummyFile($content, $ruleset, $config); |
|
668 | + $content = '<?php ' . PHP_EOL . 'class MyClass {}' . PHP_EOL . '$foo = new MyClass()' . PHP_EOL . '// @codingStandardsIgnoreFile'; |
|
669 | + $file = new DummyFile( $content, $ruleset, $config ); |
|
670 | 670 | $file->process(); |
671 | 671 | |
672 | 672 | $warnings = $file->getWarnings(); |
673 | 673 | $numWarnings = $file->getWarningCount(); |
674 | - $this->assertEquals(0, $numWarnings); |
|
675 | - $this->assertCount(0, $warnings); |
|
674 | + $this->assertEquals( 0, $numWarnings ); |
|
675 | + $this->assertCount( 0, $warnings ); |
|
676 | 676 | |
677 | 677 | // Process with a block comment suppression. |
678 | - $content = '<?php '.PHP_EOL.'/* phpcs:ignoreFile */'.PHP_EOL.'//TODO: write some code'; |
|
679 | - $file = new DummyFile($content, $ruleset, $config); |
|
678 | + $content = '<?php ' . PHP_EOL . '/* phpcs:ignoreFile */' . PHP_EOL . '//TODO: write some code'; |
|
679 | + $file = new DummyFile( $content, $ruleset, $config ); |
|
680 | 680 | $file->process(); |
681 | 681 | |
682 | 682 | $warnings = $file->getWarnings(); |
683 | 683 | $numWarnings = $file->getWarningCount(); |
684 | - $this->assertEquals(0, $numWarnings); |
|
685 | - $this->assertCount(0, $warnings); |
|
684 | + $this->assertEquals( 0, $numWarnings ); |
|
685 | + $this->assertCount( 0, $warnings ); |
|
686 | 686 | |
687 | 687 | // Process with a multi-line block comment suppression. |
688 | - $content = '<?php '.PHP_EOL.'/*'.PHP_EOL.' phpcs:ignoreFile'.PHP_EOL.' */'.PHP_EOL.'//TODO: write some code'; |
|
689 | - $file = new DummyFile($content, $ruleset, $config); |
|
688 | + $content = '<?php ' . PHP_EOL . '/*' . PHP_EOL . ' phpcs:ignoreFile' . PHP_EOL . ' */' . PHP_EOL . '//TODO: write some code'; |
|
689 | + $file = new DummyFile( $content, $ruleset, $config ); |
|
690 | 690 | $file->process(); |
691 | 691 | |
692 | 692 | $warnings = $file->getWarnings(); |
693 | 693 | $numWarnings = $file->getWarningCount(); |
694 | - $this->assertEquals(0, $numWarnings); |
|
695 | - $this->assertCount(0, $warnings); |
|
694 | + $this->assertEquals( 0, $numWarnings ); |
|
695 | + $this->assertCount( 0, $warnings ); |
|
696 | 696 | |
697 | 697 | // Process with a block comment suppression (deprecated syntax). |
698 | - $content = '<?php '.PHP_EOL.'/* @codingStandardsIgnoreFile */'.PHP_EOL.'//TODO: write some code'; |
|
699 | - $file = new DummyFile($content, $ruleset, $config); |
|
698 | + $content = '<?php ' . PHP_EOL . '/* @codingStandardsIgnoreFile */' . PHP_EOL . '//TODO: write some code'; |
|
699 | + $file = new DummyFile( $content, $ruleset, $config ); |
|
700 | 700 | $file->process(); |
701 | 701 | |
702 | 702 | $warnings = $file->getWarnings(); |
703 | 703 | $numWarnings = $file->getWarningCount(); |
704 | - $this->assertEquals(0, $numWarnings); |
|
705 | - $this->assertCount(0, $warnings); |
|
704 | + $this->assertEquals( 0, $numWarnings ); |
|
705 | + $this->assertCount( 0, $warnings ); |
|
706 | 706 | |
707 | 707 | // Process with a multi-line block comment suppression (deprecated syntax). |
708 | - $content = '<?php '.PHP_EOL.'/*'.PHP_EOL.' @codingStandardsIgnoreFile'.PHP_EOL.' */'.PHP_EOL.'//TODO: write some code'; |
|
709 | - $file = new DummyFile($content, $ruleset, $config); |
|
708 | + $content = '<?php ' . PHP_EOL . '/*' . PHP_EOL . ' @codingStandardsIgnoreFile' . PHP_EOL . ' */' . PHP_EOL . '//TODO: write some code'; |
|
709 | + $file = new DummyFile( $content, $ruleset, $config ); |
|
710 | 710 | $file->process(); |
711 | 711 | |
712 | 712 | $warnings = $file->getWarnings(); |
713 | 713 | $numWarnings = $file->getWarningCount(); |
714 | - $this->assertEquals(0, $numWarnings); |
|
715 | - $this->assertCount(0, $warnings); |
|
714 | + $this->assertEquals( 0, $numWarnings ); |
|
715 | + $this->assertCount( 0, $warnings ); |
|
716 | 716 | |
717 | 717 | // Process with docblock suppression. |
718 | - $content = '<?php '.PHP_EOL.'/** phpcs:ignoreFile */'.PHP_EOL.'//TODO: write some code'; |
|
719 | - $file = new DummyFile($content, $ruleset, $config); |
|
718 | + $content = '<?php ' . PHP_EOL . '/** phpcs:ignoreFile */' . PHP_EOL . '//TODO: write some code'; |
|
719 | + $file = new DummyFile( $content, $ruleset, $config ); |
|
720 | 720 | $file->process(); |
721 | 721 | |
722 | 722 | $warnings = $file->getWarnings(); |
723 | 723 | $numWarnings = $file->getWarningCount(); |
724 | - $this->assertEquals(0, $numWarnings); |
|
725 | - $this->assertCount(0, $warnings); |
|
724 | + $this->assertEquals( 0, $numWarnings ); |
|
725 | + $this->assertCount( 0, $warnings ); |
|
726 | 726 | |
727 | 727 | // Process with docblock suppression (deprecated syntax). |
728 | - $content = '<?php '.PHP_EOL.'/** @codingStandardsIgnoreFile */'.PHP_EOL.'//TODO: write some code'; |
|
729 | - $file = new DummyFile($content, $ruleset, $config); |
|
728 | + $content = '<?php ' . PHP_EOL . '/** @codingStandardsIgnoreFile */' . PHP_EOL . '//TODO: write some code'; |
|
729 | + $file = new DummyFile( $content, $ruleset, $config ); |
|
730 | 730 | $file->process(); |
731 | 731 | |
732 | 732 | $warnings = $file->getWarnings(); |
733 | 733 | $numWarnings = $file->getWarningCount(); |
734 | - $this->assertEquals(0, $numWarnings); |
|
735 | - $this->assertCount(0, $warnings); |
|
734 | + $this->assertEquals( 0, $numWarnings ); |
|
735 | + $this->assertCount( 0, $warnings ); |
|
736 | 736 | |
737 | 737 | }//end testSuppressFile() |
738 | 738 | |
@@ -745,141 +745,141 @@ discard block |
||
745 | 745 | public function testDisableSelected() |
746 | 746 | { |
747 | 747 | $config = new Config(); |
748 | - $config->standards = ['Generic']; |
|
748 | + $config->standards = [ 'Generic' ]; |
|
749 | 749 | $config->sniffs = [ |
750 | 750 | 'Generic.PHP.LowerCaseConstant', |
751 | 751 | 'Generic.Commenting.Todo', |
752 | 752 | ]; |
753 | 753 | |
754 | - $ruleset = new Ruleset($config); |
|
754 | + $ruleset = new Ruleset( $config ); |
|
755 | 755 | |
756 | 756 | // Suppress a single sniff. |
757 | - $content = '<?php '.PHP_EOL.'// phpcs:disable Generic.Commenting.Todo'.PHP_EOL.'$var = FALSE;'.PHP_EOL.'//TODO: write some code'; |
|
758 | - $file = new DummyFile($content, $ruleset, $config); |
|
757 | + $content = '<?php ' . PHP_EOL . '// phpcs:disable Generic.Commenting.Todo' . PHP_EOL . '$var = FALSE;' . PHP_EOL . '//TODO: write some code'; |
|
758 | + $file = new DummyFile( $content, $ruleset, $config ); |
|
759 | 759 | $file->process(); |
760 | 760 | |
761 | 761 | $errors = $file->getErrors(); |
762 | 762 | $numErrors = $file->getErrorCount(); |
763 | 763 | $warnings = $file->getWarnings(); |
764 | 764 | $numWarnings = $file->getWarningCount(); |
765 | - $this->assertEquals(1, $numErrors); |
|
766 | - $this->assertCount(1, $errors); |
|
767 | - $this->assertEquals(0, $numWarnings); |
|
768 | - $this->assertCount(0, $warnings); |
|
765 | + $this->assertEquals( 1, $numErrors ); |
|
766 | + $this->assertCount( 1, $errors ); |
|
767 | + $this->assertEquals( 0, $numWarnings ); |
|
768 | + $this->assertCount( 0, $warnings ); |
|
769 | 769 | |
770 | 770 | // Suppress multiple sniffs. |
771 | - $content = '<?php '.PHP_EOL.'// phpcs:disable Generic.Commenting.Todo,Generic.PHP.LowerCaseConstant'.PHP_EOL.'$var = FALSE;'.PHP_EOL.'//TODO: write some code'; |
|
772 | - $file = new DummyFile($content, $ruleset, $config); |
|
771 | + $content = '<?php ' . PHP_EOL . '// phpcs:disable Generic.Commenting.Todo,Generic.PHP.LowerCaseConstant' . PHP_EOL . '$var = FALSE;' . PHP_EOL . '//TODO: write some code'; |
|
772 | + $file = new DummyFile( $content, $ruleset, $config ); |
|
773 | 773 | $file->process(); |
774 | 774 | |
775 | 775 | $errors = $file->getErrors(); |
776 | 776 | $numErrors = $file->getErrorCount(); |
777 | 777 | $warnings = $file->getWarnings(); |
778 | 778 | $numWarnings = $file->getWarningCount(); |
779 | - $this->assertEquals(0, $numErrors); |
|
780 | - $this->assertCount(0, $errors); |
|
781 | - $this->assertEquals(0, $numWarnings); |
|
782 | - $this->assertCount(0, $warnings); |
|
779 | + $this->assertEquals( 0, $numErrors ); |
|
780 | + $this->assertCount( 0, $errors ); |
|
781 | + $this->assertEquals( 0, $numWarnings ); |
|
782 | + $this->assertCount( 0, $warnings ); |
|
783 | 783 | |
784 | 784 | // Suppress adding sniffs. |
785 | - $content = '<?php '.PHP_EOL.'// phpcs:disable Generic.Commenting.Todo'.PHP_EOL.'// phpcs:disable Generic.PHP.LowerCaseConstant'.PHP_EOL.'$var = FALSE;'.PHP_EOL.'//TODO: write some code'; |
|
786 | - $file = new DummyFile($content, $ruleset, $config); |
|
785 | + $content = '<?php ' . PHP_EOL . '// phpcs:disable Generic.Commenting.Todo' . PHP_EOL . '// phpcs:disable Generic.PHP.LowerCaseConstant' . PHP_EOL . '$var = FALSE;' . PHP_EOL . '//TODO: write some code'; |
|
786 | + $file = new DummyFile( $content, $ruleset, $config ); |
|
787 | 787 | $file->process(); |
788 | 788 | |
789 | 789 | $errors = $file->getErrors(); |
790 | 790 | $numErrors = $file->getErrorCount(); |
791 | 791 | $warnings = $file->getWarnings(); |
792 | 792 | $numWarnings = $file->getWarningCount(); |
793 | - $this->assertEquals(0, $numErrors); |
|
794 | - $this->assertCount(0, $errors); |
|
795 | - $this->assertEquals(0, $numWarnings); |
|
796 | - $this->assertCount(0, $warnings); |
|
793 | + $this->assertEquals( 0, $numErrors ); |
|
794 | + $this->assertCount( 0, $errors ); |
|
795 | + $this->assertEquals( 0, $numWarnings ); |
|
796 | + $this->assertCount( 0, $warnings ); |
|
797 | 797 | |
798 | 798 | // Suppress a category of sniffs. |
799 | - $content = '<?php '.PHP_EOL.'// phpcs:disable Generic.Commenting'.PHP_EOL.'$var = FALSE;'.PHP_EOL.'//TODO: write some code'; |
|
800 | - $file = new DummyFile($content, $ruleset, $config); |
|
799 | + $content = '<?php ' . PHP_EOL . '// phpcs:disable Generic.Commenting' . PHP_EOL . '$var = FALSE;' . PHP_EOL . '//TODO: write some code'; |
|
800 | + $file = new DummyFile( $content, $ruleset, $config ); |
|
801 | 801 | $file->process(); |
802 | 802 | |
803 | 803 | $errors = $file->getErrors(); |
804 | 804 | $numErrors = $file->getErrorCount(); |
805 | 805 | $warnings = $file->getWarnings(); |
806 | 806 | $numWarnings = $file->getWarningCount(); |
807 | - $this->assertEquals(1, $numErrors); |
|
808 | - $this->assertCount(1, $errors); |
|
809 | - $this->assertEquals(0, $numWarnings); |
|
810 | - $this->assertCount(0, $warnings); |
|
807 | + $this->assertEquals( 1, $numErrors ); |
|
808 | + $this->assertCount( 1, $errors ); |
|
809 | + $this->assertEquals( 0, $numWarnings ); |
|
810 | + $this->assertCount( 0, $warnings ); |
|
811 | 811 | |
812 | 812 | // Suppress a whole standard. |
813 | - $content = '<?php '.PHP_EOL.'// phpcs:disable Generic'.PHP_EOL.'$var = FALSE;'.PHP_EOL.'//TODO: write some code'; |
|
814 | - $file = new DummyFile($content, $ruleset, $config); |
|
813 | + $content = '<?php ' . PHP_EOL . '// phpcs:disable Generic' . PHP_EOL . '$var = FALSE;' . PHP_EOL . '//TODO: write some code'; |
|
814 | + $file = new DummyFile( $content, $ruleset, $config ); |
|
815 | 815 | $file->process(); |
816 | 816 | |
817 | 817 | $errors = $file->getErrors(); |
818 | 818 | $numErrors = $file->getErrorCount(); |
819 | 819 | $warnings = $file->getWarnings(); |
820 | 820 | $numWarnings = $file->getWarningCount(); |
821 | - $this->assertEquals(0, $numErrors); |
|
822 | - $this->assertCount(0, $errors); |
|
823 | - $this->assertEquals(0, $numWarnings); |
|
824 | - $this->assertCount(0, $warnings); |
|
821 | + $this->assertEquals( 0, $numErrors ); |
|
822 | + $this->assertCount( 0, $errors ); |
|
823 | + $this->assertEquals( 0, $numWarnings ); |
|
824 | + $this->assertCount( 0, $warnings ); |
|
825 | 825 | |
826 | 826 | // Suppress using docblocks. |
827 | - $content = '<?php '.PHP_EOL.'/** |
|
828 | - '.PHP_EOL.' * phpcs:disable Generic.Commenting.Todo'.PHP_EOL.' */ '.PHP_EOL.'//TODO: write some code'; |
|
829 | - $file = new DummyFile($content, $ruleset, $config); |
|
827 | + $content = '<?php ' . PHP_EOL . '/** |
|
828 | + '.PHP_EOL . ' * phpcs:disable Generic.Commenting.Todo' . PHP_EOL . ' */ ' . PHP_EOL . '//TODO: write some code'; |
|
829 | + $file = new DummyFile( $content, $ruleset, $config ); |
|
830 | 830 | $file->process(); |
831 | 831 | |
832 | 832 | $errors = $file->getErrors(); |
833 | 833 | $numErrors = $file->getErrorCount(); |
834 | 834 | $warnings = $file->getWarnings(); |
835 | 835 | $numWarnings = $file->getWarningCount(); |
836 | - $this->assertEquals(0, $numErrors); |
|
837 | - $this->assertCount(0, $errors); |
|
838 | - $this->assertEquals(0, $numWarnings); |
|
839 | - $this->assertCount(0, $warnings); |
|
836 | + $this->assertEquals( 0, $numErrors ); |
|
837 | + $this->assertCount( 0, $errors ); |
|
838 | + $this->assertEquals( 0, $numWarnings ); |
|
839 | + $this->assertCount( 0, $warnings ); |
|
840 | 840 | |
841 | - $content = '<?php '.PHP_EOL.'/** |
|
842 | - '.PHP_EOL.' * @phpcs:disable Generic.Commenting.Todo'.PHP_EOL.' */ '.PHP_EOL.'//TODO: write some code'; |
|
843 | - $file = new DummyFile($content, $ruleset, $config); |
|
841 | + $content = '<?php ' . PHP_EOL . '/** |
|
842 | + '.PHP_EOL . ' * @phpcs:disable Generic.Commenting.Todo' . PHP_EOL . ' */ ' . PHP_EOL . '//TODO: write some code'; |
|
843 | + $file = new DummyFile( $content, $ruleset, $config ); |
|
844 | 844 | $file->process(); |
845 | 845 | |
846 | 846 | $errors = $file->getErrors(); |
847 | 847 | $numErrors = $file->getErrorCount(); |
848 | 848 | $warnings = $file->getWarnings(); |
849 | 849 | $numWarnings = $file->getWarningCount(); |
850 | - $this->assertEquals(0, $numErrors); |
|
851 | - $this->assertCount(0, $errors); |
|
852 | - $this->assertEquals(0, $numWarnings); |
|
853 | - $this->assertCount(0, $warnings); |
|
850 | + $this->assertEquals( 0, $numErrors ); |
|
851 | + $this->assertCount( 0, $errors ); |
|
852 | + $this->assertEquals( 0, $numWarnings ); |
|
853 | + $this->assertCount( 0, $warnings ); |
|
854 | 854 | |
855 | 855 | // Suppress wrong category using docblocks. |
856 | - $content = '<?php '.PHP_EOL.'/** |
|
857 | - '.PHP_EOL.' * phpcs:disable Generic.Files'.PHP_EOL.' */ '.PHP_EOL.'//TODO: write some code'; |
|
858 | - $file = new DummyFile($content, $ruleset, $config); |
|
856 | + $content = '<?php ' . PHP_EOL . '/** |
|
857 | + '.PHP_EOL . ' * phpcs:disable Generic.Files' . PHP_EOL . ' */ ' . PHP_EOL . '//TODO: write some code'; |
|
858 | + $file = new DummyFile( $content, $ruleset, $config ); |
|
859 | 859 | $file->process(); |
860 | 860 | |
861 | 861 | $errors = $file->getErrors(); |
862 | 862 | $numErrors = $file->getErrorCount(); |
863 | 863 | $warnings = $file->getWarnings(); |
864 | 864 | $numWarnings = $file->getWarningCount(); |
865 | - $this->assertEquals(0, $numErrors); |
|
866 | - $this->assertCount(0, $errors); |
|
867 | - $this->assertEquals(1, $numWarnings); |
|
868 | - $this->assertCount(1, $warnings); |
|
865 | + $this->assertEquals( 0, $numErrors ); |
|
866 | + $this->assertCount( 0, $errors ); |
|
867 | + $this->assertEquals( 1, $numWarnings ); |
|
868 | + $this->assertCount( 1, $warnings ); |
|
869 | 869 | |
870 | - $content = '<?php '.PHP_EOL.'/** |
|
871 | - '.PHP_EOL.' * @phpcs:disable Generic.Files'.PHP_EOL.' */ '.PHP_EOL.'//TODO: write some code'; |
|
872 | - $file = new DummyFile($content, $ruleset, $config); |
|
870 | + $content = '<?php ' . PHP_EOL . '/** |
|
871 | + '.PHP_EOL . ' * @phpcs:disable Generic.Files' . PHP_EOL . ' */ ' . PHP_EOL . '//TODO: write some code'; |
|
872 | + $file = new DummyFile( $content, $ruleset, $config ); |
|
873 | 873 | $file->process(); |
874 | 874 | |
875 | 875 | $errors = $file->getErrors(); |
876 | 876 | $numErrors = $file->getErrorCount(); |
877 | 877 | $warnings = $file->getWarnings(); |
878 | 878 | $numWarnings = $file->getWarningCount(); |
879 | - $this->assertEquals(0, $numErrors); |
|
880 | - $this->assertCount(0, $errors); |
|
881 | - $this->assertEquals(1, $numWarnings); |
|
882 | - $this->assertCount(1, $warnings); |
|
879 | + $this->assertEquals( 0, $numErrors ); |
|
880 | + $this->assertCount( 0, $errors ); |
|
881 | + $this->assertEquals( 1, $numWarnings ); |
|
882 | + $this->assertCount( 1, $warnings ); |
|
883 | 883 | |
884 | 884 | }//end testDisableSelected() |
885 | 885 | |
@@ -892,167 +892,167 @@ discard block |
||
892 | 892 | public function testEnableSelected() |
893 | 893 | { |
894 | 894 | $config = new Config(); |
895 | - $config->standards = ['Generic']; |
|
895 | + $config->standards = [ 'Generic' ]; |
|
896 | 896 | $config->sniffs = [ |
897 | 897 | 'Generic.PHP.LowerCaseConstant', |
898 | 898 | 'Generic.Commenting.Todo', |
899 | 899 | ]; |
900 | 900 | |
901 | - $ruleset = new Ruleset($config); |
|
901 | + $ruleset = new Ruleset( $config ); |
|
902 | 902 | |
903 | 903 | // Suppress a single sniff and re-enable. |
904 | - $content = '<?php '.PHP_EOL.'// phpcs:disable Generic.Commenting.Todo'.PHP_EOL.'$var = FALSE;'.PHP_EOL.'//TODO: write some code'.PHP_EOL.'// phpcs:enable Generic.Commenting.Todo'.PHP_EOL.'//TODO: write some code'; |
|
905 | - $file = new DummyFile($content, $ruleset, $config); |
|
904 | + $content = '<?php ' . PHP_EOL . '// phpcs:disable Generic.Commenting.Todo' . PHP_EOL . '$var = FALSE;' . PHP_EOL . '//TODO: write some code' . PHP_EOL . '// phpcs:enable Generic.Commenting.Todo' . PHP_EOL . '//TODO: write some code'; |
|
905 | + $file = new DummyFile( $content, $ruleset, $config ); |
|
906 | 906 | $file->process(); |
907 | 907 | |
908 | 908 | $errors = $file->getErrors(); |
909 | 909 | $numErrors = $file->getErrorCount(); |
910 | 910 | $warnings = $file->getWarnings(); |
911 | 911 | $numWarnings = $file->getWarningCount(); |
912 | - $this->assertEquals(1, $numErrors); |
|
913 | - $this->assertCount(1, $errors); |
|
914 | - $this->assertEquals(1, $numWarnings); |
|
915 | - $this->assertCount(1, $warnings); |
|
912 | + $this->assertEquals( 1, $numErrors ); |
|
913 | + $this->assertCount( 1, $errors ); |
|
914 | + $this->assertEquals( 1, $numWarnings ); |
|
915 | + $this->assertCount( 1, $warnings ); |
|
916 | 916 | |
917 | 917 | // Suppress multiple sniffs and re-enable. |
918 | - $content = '<?php '.PHP_EOL.'// phpcs:disable Generic.Commenting.Todo,Generic.PHP.LowerCaseConstant'.PHP_EOL.'$var = FALSE;'.PHP_EOL.'//TODO: write some code'.PHP_EOL.'// phpcs:enable Generic.Commenting.Todo,Generic.PHP.LowerCaseConstant'.PHP_EOL.'//TODO: write some code'.PHP_EOL.'$var = FALSE;'; |
|
919 | - $file = new DummyFile($content, $ruleset, $config); |
|
918 | + $content = '<?php ' . PHP_EOL . '// phpcs:disable Generic.Commenting.Todo,Generic.PHP.LowerCaseConstant' . PHP_EOL . '$var = FALSE;' . PHP_EOL . '//TODO: write some code' . PHP_EOL . '// phpcs:enable Generic.Commenting.Todo,Generic.PHP.LowerCaseConstant' . PHP_EOL . '//TODO: write some code' . PHP_EOL . '$var = FALSE;'; |
|
919 | + $file = new DummyFile( $content, $ruleset, $config ); |
|
920 | 920 | $file->process(); |
921 | 921 | |
922 | 922 | $errors = $file->getErrors(); |
923 | 923 | $numErrors = $file->getErrorCount(); |
924 | 924 | $warnings = $file->getWarnings(); |
925 | 925 | $numWarnings = $file->getWarningCount(); |
926 | - $this->assertEquals(1, $numErrors); |
|
927 | - $this->assertCount(1, $errors); |
|
928 | - $this->assertEquals(1, $numWarnings); |
|
929 | - $this->assertCount(1, $warnings); |
|
926 | + $this->assertEquals( 1, $numErrors ); |
|
927 | + $this->assertCount( 1, $errors ); |
|
928 | + $this->assertEquals( 1, $numWarnings ); |
|
929 | + $this->assertCount( 1, $warnings ); |
|
930 | 930 | |
931 | 931 | // Suppress multiple sniffs and re-enable one. |
932 | - $content = '<?php '.PHP_EOL.'// phpcs:disable Generic.Commenting.Todo,Generic.PHP.LowerCaseConstant'.PHP_EOL.'$var = FALSE;'.PHP_EOL.'//TODO: write some code'.PHP_EOL.'// phpcs:enable Generic.Commenting.Todo'.PHP_EOL.'//TODO: write some code'.PHP_EOL.'$var = FALSE;'; |
|
933 | - $file = new DummyFile($content, $ruleset, $config); |
|
932 | + $content = '<?php ' . PHP_EOL . '// phpcs:disable Generic.Commenting.Todo,Generic.PHP.LowerCaseConstant' . PHP_EOL . '$var = FALSE;' . PHP_EOL . '//TODO: write some code' . PHP_EOL . '// phpcs:enable Generic.Commenting.Todo' . PHP_EOL . '//TODO: write some code' . PHP_EOL . '$var = FALSE;'; |
|
933 | + $file = new DummyFile( $content, $ruleset, $config ); |
|
934 | 934 | $file->process(); |
935 | 935 | |
936 | 936 | $errors = $file->getErrors(); |
937 | 937 | $numErrors = $file->getErrorCount(); |
938 | 938 | $warnings = $file->getWarnings(); |
939 | 939 | $numWarnings = $file->getWarningCount(); |
940 | - $this->assertEquals(0, $numErrors); |
|
941 | - $this->assertCount(0, $errors); |
|
942 | - $this->assertEquals(1, $numWarnings); |
|
943 | - $this->assertCount(1, $warnings); |
|
940 | + $this->assertEquals( 0, $numErrors ); |
|
941 | + $this->assertCount( 0, $errors ); |
|
942 | + $this->assertEquals( 1, $numWarnings ); |
|
943 | + $this->assertCount( 1, $warnings ); |
|
944 | 944 | |
945 | 945 | // Suppress a category of sniffs and re-enable. |
946 | - $content = '<?php '.PHP_EOL.'// phpcs:disable Generic.Commenting'.PHP_EOL.'$var = FALSE;'.PHP_EOL.'//TODO: write some code'.PHP_EOL.'// phpcs:enable Generic.Commenting'.PHP_EOL.'//TODO: write some code'; |
|
947 | - $file = new DummyFile($content, $ruleset, $config); |
|
946 | + $content = '<?php ' . PHP_EOL . '// phpcs:disable Generic.Commenting' . PHP_EOL . '$var = FALSE;' . PHP_EOL . '//TODO: write some code' . PHP_EOL . '// phpcs:enable Generic.Commenting' . PHP_EOL . '//TODO: write some code'; |
|
947 | + $file = new DummyFile( $content, $ruleset, $config ); |
|
948 | 948 | $file->process(); |
949 | 949 | |
950 | 950 | $errors = $file->getErrors(); |
951 | 951 | $numErrors = $file->getErrorCount(); |
952 | 952 | $warnings = $file->getWarnings(); |
953 | 953 | $numWarnings = $file->getWarningCount(); |
954 | - $this->assertEquals(1, $numErrors); |
|
955 | - $this->assertCount(1, $errors); |
|
956 | - $this->assertEquals(1, $numWarnings); |
|
957 | - $this->assertCount(1, $warnings); |
|
954 | + $this->assertEquals( 1, $numErrors ); |
|
955 | + $this->assertCount( 1, $errors ); |
|
956 | + $this->assertEquals( 1, $numWarnings ); |
|
957 | + $this->assertCount( 1, $warnings ); |
|
958 | 958 | |
959 | 959 | // Suppress a whole standard and re-enable. |
960 | - $content = '<?php '.PHP_EOL.'// phpcs:disable Generic'.PHP_EOL.'$var = FALSE;'.PHP_EOL.'//TODO: write some code'.PHP_EOL.'// phpcs:enable Generic'.PHP_EOL.'//TODO: write some code'; |
|
961 | - $file = new DummyFile($content, $ruleset, $config); |
|
960 | + $content = '<?php ' . PHP_EOL . '// phpcs:disable Generic' . PHP_EOL . '$var = FALSE;' . PHP_EOL . '//TODO: write some code' . PHP_EOL . '// phpcs:enable Generic' . PHP_EOL . '//TODO: write some code'; |
|
961 | + $file = new DummyFile( $content, $ruleset, $config ); |
|
962 | 962 | $file->process(); |
963 | 963 | |
964 | 964 | $errors = $file->getErrors(); |
965 | 965 | $numErrors = $file->getErrorCount(); |
966 | 966 | $warnings = $file->getWarnings(); |
967 | 967 | $numWarnings = $file->getWarningCount(); |
968 | - $this->assertEquals(0, $numErrors); |
|
969 | - $this->assertCount(0, $errors); |
|
970 | - $this->assertEquals(1, $numWarnings); |
|
971 | - $this->assertCount(1, $warnings); |
|
968 | + $this->assertEquals( 0, $numErrors ); |
|
969 | + $this->assertCount( 0, $errors ); |
|
970 | + $this->assertEquals( 1, $numWarnings ); |
|
971 | + $this->assertCount( 1, $warnings ); |
|
972 | 972 | |
973 | 973 | // Suppress a whole standard and re-enable a category. |
974 | - $content = '<?php '.PHP_EOL.'// phpcs:disable Generic'.PHP_EOL.'$var = FALSE;'.PHP_EOL.'//TODO: write some code'.PHP_EOL.'// phpcs:enable Generic.Commenting'.PHP_EOL.'//TODO: write some code'; |
|
975 | - $file = new DummyFile($content, $ruleset, $config); |
|
974 | + $content = '<?php ' . PHP_EOL . '// phpcs:disable Generic' . PHP_EOL . '$var = FALSE;' . PHP_EOL . '//TODO: write some code' . PHP_EOL . '// phpcs:enable Generic.Commenting' . PHP_EOL . '//TODO: write some code'; |
|
975 | + $file = new DummyFile( $content, $ruleset, $config ); |
|
976 | 976 | $file->process(); |
977 | 977 | |
978 | 978 | $errors = $file->getErrors(); |
979 | 979 | $numErrors = $file->getErrorCount(); |
980 | 980 | $warnings = $file->getWarnings(); |
981 | 981 | $numWarnings = $file->getWarningCount(); |
982 | - $this->assertEquals(0, $numErrors); |
|
983 | - $this->assertCount(0, $errors); |
|
984 | - $this->assertEquals(1, $numWarnings); |
|
985 | - $this->assertCount(1, $warnings); |
|
982 | + $this->assertEquals( 0, $numErrors ); |
|
983 | + $this->assertCount( 0, $errors ); |
|
984 | + $this->assertEquals( 1, $numWarnings ); |
|
985 | + $this->assertCount( 1, $warnings ); |
|
986 | 986 | |
987 | 987 | // Suppress a category and re-enable a whole standard. |
988 | - $content = '<?php '.PHP_EOL.'// phpcs:disable Generic.Commenting'.PHP_EOL.'$var = FALSE;'.PHP_EOL.'//TODO: write some code'.PHP_EOL.'// phpcs:enable Generic'.PHP_EOL.'//TODO: write some code'; |
|
989 | - $file = new DummyFile($content, $ruleset, $config); |
|
988 | + $content = '<?php ' . PHP_EOL . '// phpcs:disable Generic.Commenting' . PHP_EOL . '$var = FALSE;' . PHP_EOL . '//TODO: write some code' . PHP_EOL . '// phpcs:enable Generic' . PHP_EOL . '//TODO: write some code'; |
|
989 | + $file = new DummyFile( $content, $ruleset, $config ); |
|
990 | 990 | $file->process(); |
991 | 991 | |
992 | 992 | $errors = $file->getErrors(); |
993 | 993 | $numErrors = $file->getErrorCount(); |
994 | 994 | $warnings = $file->getWarnings(); |
995 | 995 | $numWarnings = $file->getWarningCount(); |
996 | - $this->assertEquals(1, $numErrors); |
|
997 | - $this->assertCount(1, $errors); |
|
998 | - $this->assertEquals(1, $numWarnings); |
|
999 | - $this->assertCount(1, $warnings); |
|
996 | + $this->assertEquals( 1, $numErrors ); |
|
997 | + $this->assertCount( 1, $errors ); |
|
998 | + $this->assertEquals( 1, $numWarnings ); |
|
999 | + $this->assertCount( 1, $warnings ); |
|
1000 | 1000 | |
1001 | 1001 | // Suppress a sniff and re-enable a category. |
1002 | - $content = '<?php '.PHP_EOL.'// phpcs:disable Generic.Commenting.Todo'.PHP_EOL.'$var = FALSE;'.PHP_EOL.'//TODO: write some code'.PHP_EOL.'// phpcs:enable Generic.Commenting'.PHP_EOL.'//TODO: write some code'; |
|
1003 | - $file = new DummyFile($content, $ruleset, $config); |
|
1002 | + $content = '<?php ' . PHP_EOL . '// phpcs:disable Generic.Commenting.Todo' . PHP_EOL . '$var = FALSE;' . PHP_EOL . '//TODO: write some code' . PHP_EOL . '// phpcs:enable Generic.Commenting' . PHP_EOL . '//TODO: write some code'; |
|
1003 | + $file = new DummyFile( $content, $ruleset, $config ); |
|
1004 | 1004 | $file->process(); |
1005 | 1005 | |
1006 | 1006 | $errors = $file->getErrors(); |
1007 | 1007 | $numErrors = $file->getErrorCount(); |
1008 | 1008 | $warnings = $file->getWarnings(); |
1009 | 1009 | $numWarnings = $file->getWarningCount(); |
1010 | - $this->assertEquals(1, $numErrors); |
|
1011 | - $this->assertCount(1, $errors); |
|
1012 | - $this->assertEquals(1, $numWarnings); |
|
1013 | - $this->assertCount(1, $warnings); |
|
1010 | + $this->assertEquals( 1, $numErrors ); |
|
1011 | + $this->assertCount( 1, $errors ); |
|
1012 | + $this->assertEquals( 1, $numWarnings ); |
|
1013 | + $this->assertCount( 1, $warnings ); |
|
1014 | 1014 | |
1015 | 1015 | // Suppress a whole standard and re-enable a sniff. |
1016 | - $content = '<?php '.PHP_EOL.'// phpcs:disable Generic'.PHP_EOL.'$var = FALSE;'.PHP_EOL.'//TODO: write some code'.PHP_EOL.'// phpcs:enable Generic.Commenting.Todo'.PHP_EOL.'//TODO: write some code'; |
|
1017 | - $file = new DummyFile($content, $ruleset, $config); |
|
1016 | + $content = '<?php ' . PHP_EOL . '// phpcs:disable Generic' . PHP_EOL . '$var = FALSE;' . PHP_EOL . '//TODO: write some code' . PHP_EOL . '// phpcs:enable Generic.Commenting.Todo' . PHP_EOL . '//TODO: write some code'; |
|
1017 | + $file = new DummyFile( $content, $ruleset, $config ); |
|
1018 | 1018 | $file->process(); |
1019 | 1019 | |
1020 | 1020 | $errors = $file->getErrors(); |
1021 | 1021 | $numErrors = $file->getErrorCount(); |
1022 | 1022 | $warnings = $file->getWarnings(); |
1023 | 1023 | $numWarnings = $file->getWarningCount(); |
1024 | - $this->assertEquals(0, $numErrors); |
|
1025 | - $this->assertCount(0, $errors); |
|
1026 | - $this->assertEquals(1, $numWarnings); |
|
1027 | - $this->assertCount(1, $warnings); |
|
1024 | + $this->assertEquals( 0, $numErrors ); |
|
1025 | + $this->assertCount( 0, $errors ); |
|
1026 | + $this->assertEquals( 1, $numWarnings ); |
|
1027 | + $this->assertCount( 1, $warnings ); |
|
1028 | 1028 | |
1029 | 1029 | // Suppress a whole standard and re-enable and re-disable a sniff. |
1030 | - $content = '<?php '.PHP_EOL.'// phpcs:disable Generic'.PHP_EOL.'$var = FALSE;'.PHP_EOL.'//TODO: write some code'.PHP_EOL.'// phpcs:enable Generic.Commenting.Todo'.PHP_EOL.'//TODO: write some code'.PHP_EOL.'// phpcs:disable Generic.Commenting.Todo'.PHP_EOL.'//TODO: write some code'.PHP_EOL.'// phpcs:enable'.PHP_EOL.'//TODO: write some code'; |
|
1031 | - $file = new DummyFile($content, $ruleset, $config); |
|
1030 | + $content = '<?php ' . PHP_EOL . '// phpcs:disable Generic' . PHP_EOL . '$var = FALSE;' . PHP_EOL . '//TODO: write some code' . PHP_EOL . '// phpcs:enable Generic.Commenting.Todo' . PHP_EOL . '//TODO: write some code' . PHP_EOL . '// phpcs:disable Generic.Commenting.Todo' . PHP_EOL . '//TODO: write some code' . PHP_EOL . '// phpcs:enable' . PHP_EOL . '//TODO: write some code'; |
|
1031 | + $file = new DummyFile( $content, $ruleset, $config ); |
|
1032 | 1032 | $file->process(); |
1033 | 1033 | |
1034 | 1034 | $errors = $file->getErrors(); |
1035 | 1035 | $numErrors = $file->getErrorCount(); |
1036 | 1036 | $warnings = $file->getWarnings(); |
1037 | 1037 | $numWarnings = $file->getWarningCount(); |
1038 | - $this->assertEquals(0, $numErrors); |
|
1039 | - $this->assertCount(0, $errors); |
|
1040 | - $this->assertEquals(2, $numWarnings); |
|
1041 | - $this->assertCount(2, $warnings); |
|
1038 | + $this->assertEquals( 0, $numErrors ); |
|
1039 | + $this->assertCount( 0, $errors ); |
|
1040 | + $this->assertEquals( 2, $numWarnings ); |
|
1041 | + $this->assertCount( 2, $warnings ); |
|
1042 | 1042 | |
1043 | 1043 | // Suppress a whole standard and re-enable 2 specific sniffs independently. |
1044 | - $content = '<?php '.PHP_EOL.'// phpcs:disable Generic'.PHP_EOL.'$var = FALSE;'.PHP_EOL.'//TODO: write some code'.PHP_EOL.'// phpcs:enable Generic.Commenting.Todo'.PHP_EOL.'//TODO: write some code'.PHP_EOL.'$var = FALSE;'.PHP_EOL.'// phpcs:enable Generic.PHP.LowerCaseConstant'.PHP_EOL.'//TODO: write some code'.PHP_EOL.'$var = FALSE;'.PHP_EOL; |
|
1045 | - $file = new DummyFile($content, $ruleset, $config); |
|
1044 | + $content = '<?php ' . PHP_EOL . '// phpcs:disable Generic' . PHP_EOL . '$var = FALSE;' . PHP_EOL . '//TODO: write some code' . PHP_EOL . '// phpcs:enable Generic.Commenting.Todo' . PHP_EOL . '//TODO: write some code' . PHP_EOL . '$var = FALSE;' . PHP_EOL . '// phpcs:enable Generic.PHP.LowerCaseConstant' . PHP_EOL . '//TODO: write some code' . PHP_EOL . '$var = FALSE;' . PHP_EOL; |
|
1045 | + $file = new DummyFile( $content, $ruleset, $config ); |
|
1046 | 1046 | $file->process(); |
1047 | 1047 | |
1048 | 1048 | $errors = $file->getErrors(); |
1049 | 1049 | $numErrors = $file->getErrorCount(); |
1050 | 1050 | $warnings = $file->getWarnings(); |
1051 | 1051 | $numWarnings = $file->getWarningCount(); |
1052 | - $this->assertEquals(1, $numErrors); |
|
1053 | - $this->assertCount(1, $errors); |
|
1054 | - $this->assertEquals(2, $numWarnings); |
|
1055 | - $this->assertCount(2, $warnings); |
|
1052 | + $this->assertEquals( 1, $numErrors ); |
|
1053 | + $this->assertCount( 1, $errors ); |
|
1054 | + $this->assertEquals( 2, $numWarnings ); |
|
1055 | + $this->assertCount( 2, $warnings ); |
|
1056 | 1056 | |
1057 | 1057 | }//end testEnableSelected() |
1058 | 1058 | |
@@ -1065,97 +1065,97 @@ discard block |
||
1065 | 1065 | public function testIgnoreSelected() |
1066 | 1066 | { |
1067 | 1067 | $config = new Config(); |
1068 | - $config->standards = ['Generic']; |
|
1068 | + $config->standards = [ 'Generic' ]; |
|
1069 | 1069 | $config->sniffs = [ |
1070 | 1070 | 'Generic.PHP.LowerCaseConstant', |
1071 | 1071 | 'Generic.Commenting.Todo', |
1072 | 1072 | ]; |
1073 | 1073 | |
1074 | - $ruleset = new Ruleset($config); |
|
1074 | + $ruleset = new Ruleset( $config ); |
|
1075 | 1075 | |
1076 | 1076 | // No suppression. |
1077 | - $content = '<?php '.PHP_EOL.'$var = FALSE; //TODO: write some code'.PHP_EOL.'$var = FALSE; //TODO: write some code'; |
|
1078 | - $file = new DummyFile($content, $ruleset, $config); |
|
1077 | + $content = '<?php ' . PHP_EOL . '$var = FALSE; //TODO: write some code' . PHP_EOL . '$var = FALSE; //TODO: write some code'; |
|
1078 | + $file = new DummyFile( $content, $ruleset, $config ); |
|
1079 | 1079 | $file->process(); |
1080 | 1080 | |
1081 | 1081 | $errors = $file->getErrors(); |
1082 | 1082 | $numErrors = $file->getErrorCount(); |
1083 | 1083 | $warnings = $file->getWarnings(); |
1084 | 1084 | $numWarnings = $file->getWarningCount(); |
1085 | - $this->assertEquals(2, $numErrors); |
|
1086 | - $this->assertCount(2, $errors); |
|
1087 | - $this->assertEquals(2, $numWarnings); |
|
1088 | - $this->assertCount(2, $warnings); |
|
1085 | + $this->assertEquals( 2, $numErrors ); |
|
1086 | + $this->assertCount( 2, $errors ); |
|
1087 | + $this->assertEquals( 2, $numWarnings ); |
|
1088 | + $this->assertCount( 2, $warnings ); |
|
1089 | 1089 | |
1090 | 1090 | // Suppress a single sniff. |
1091 | - $content = '<?php '.PHP_EOL.'// phpcs:ignore Generic.Commenting.Todo'.PHP_EOL.'$var = FALSE; //TODO: write some code'.PHP_EOL.'$var = FALSE; //TODO: write some code'; |
|
1092 | - $file = new DummyFile($content, $ruleset, $config); |
|
1091 | + $content = '<?php ' . PHP_EOL . '// phpcs:ignore Generic.Commenting.Todo' . PHP_EOL . '$var = FALSE; //TODO: write some code' . PHP_EOL . '$var = FALSE; //TODO: write some code'; |
|
1092 | + $file = new DummyFile( $content, $ruleset, $config ); |
|
1093 | 1093 | $file->process(); |
1094 | 1094 | |
1095 | 1095 | $errors = $file->getErrors(); |
1096 | 1096 | $numErrors = $file->getErrorCount(); |
1097 | 1097 | $warnings = $file->getWarnings(); |
1098 | 1098 | $numWarnings = $file->getWarningCount(); |
1099 | - $this->assertEquals(2, $numErrors); |
|
1100 | - $this->assertCount(2, $errors); |
|
1101 | - $this->assertEquals(1, $numWarnings); |
|
1102 | - $this->assertCount(1, $warnings); |
|
1099 | + $this->assertEquals( 2, $numErrors ); |
|
1100 | + $this->assertCount( 2, $errors ); |
|
1101 | + $this->assertEquals( 1, $numWarnings ); |
|
1102 | + $this->assertCount( 1, $warnings ); |
|
1103 | 1103 | |
1104 | 1104 | // Suppress multiple sniffs. |
1105 | - $content = '<?php '.PHP_EOL.'// phpcs:ignore Generic.Commenting.Todo,Generic.PHP.LowerCaseConstant'.PHP_EOL.'$var = FALSE; //TODO: write some code'.PHP_EOL.'$var = FALSE; //TODO: write some code'; |
|
1106 | - $file = new DummyFile($content, $ruleset, $config); |
|
1105 | + $content = '<?php ' . PHP_EOL . '// phpcs:ignore Generic.Commenting.Todo,Generic.PHP.LowerCaseConstant' . PHP_EOL . '$var = FALSE; //TODO: write some code' . PHP_EOL . '$var = FALSE; //TODO: write some code'; |
|
1106 | + $file = new DummyFile( $content, $ruleset, $config ); |
|
1107 | 1107 | $file->process(); |
1108 | 1108 | |
1109 | 1109 | $errors = $file->getErrors(); |
1110 | 1110 | $numErrors = $file->getErrorCount(); |
1111 | 1111 | $warnings = $file->getWarnings(); |
1112 | 1112 | $numWarnings = $file->getWarningCount(); |
1113 | - $this->assertEquals(1, $numErrors); |
|
1114 | - $this->assertCount(1, $errors); |
|
1115 | - $this->assertEquals(1, $numWarnings); |
|
1116 | - $this->assertCount(1, $warnings); |
|
1113 | + $this->assertEquals( 1, $numErrors ); |
|
1114 | + $this->assertCount( 1, $errors ); |
|
1115 | + $this->assertEquals( 1, $numWarnings ); |
|
1116 | + $this->assertCount( 1, $warnings ); |
|
1117 | 1117 | |
1118 | 1118 | // Add to suppression. |
1119 | - $content = '<?php '.PHP_EOL.'// phpcs:disable Generic.Commenting.Todo'.PHP_EOL.'// phpcs:ignore Generic.PHP.LowerCaseConstant'.PHP_EOL.'$var = FALSE; //TODO: write some code'.PHP_EOL.'$var = FALSE; //TODO: write some code'; |
|
1120 | - $file = new DummyFile($content, $ruleset, $config); |
|
1119 | + $content = '<?php ' . PHP_EOL . '// phpcs:disable Generic.Commenting.Todo' . PHP_EOL . '// phpcs:ignore Generic.PHP.LowerCaseConstant' . PHP_EOL . '$var = FALSE; //TODO: write some code' . PHP_EOL . '$var = FALSE; //TODO: write some code'; |
|
1120 | + $file = new DummyFile( $content, $ruleset, $config ); |
|
1121 | 1121 | $file->process(); |
1122 | 1122 | |
1123 | 1123 | $errors = $file->getErrors(); |
1124 | 1124 | $numErrors = $file->getErrorCount(); |
1125 | 1125 | $warnings = $file->getWarnings(); |
1126 | 1126 | $numWarnings = $file->getWarningCount(); |
1127 | - $this->assertEquals(1, $numErrors); |
|
1128 | - $this->assertCount(1, $errors); |
|
1129 | - $this->assertEquals(0, $numWarnings); |
|
1130 | - $this->assertCount(0, $warnings); |
|
1127 | + $this->assertEquals( 1, $numErrors ); |
|
1128 | + $this->assertCount( 1, $errors ); |
|
1129 | + $this->assertEquals( 0, $numWarnings ); |
|
1130 | + $this->assertCount( 0, $warnings ); |
|
1131 | 1131 | |
1132 | 1132 | // Suppress a category of sniffs. |
1133 | - $content = '<?php '.PHP_EOL.'// phpcs:ignore Generic.Commenting'.PHP_EOL.'$var = FALSE; //TODO: write some code'.PHP_EOL.'$var = FALSE; //TODO: write some code'; |
|
1134 | - $file = new DummyFile($content, $ruleset, $config); |
|
1133 | + $content = '<?php ' . PHP_EOL . '// phpcs:ignore Generic.Commenting' . PHP_EOL . '$var = FALSE; //TODO: write some code' . PHP_EOL . '$var = FALSE; //TODO: write some code'; |
|
1134 | + $file = new DummyFile( $content, $ruleset, $config ); |
|
1135 | 1135 | $file->process(); |
1136 | 1136 | |
1137 | 1137 | $errors = $file->getErrors(); |
1138 | 1138 | $numErrors = $file->getErrorCount(); |
1139 | 1139 | $warnings = $file->getWarnings(); |
1140 | 1140 | $numWarnings = $file->getWarningCount(); |
1141 | - $this->assertEquals(2, $numErrors); |
|
1142 | - $this->assertCount(2, $errors); |
|
1143 | - $this->assertEquals(1, $numWarnings); |
|
1144 | - $this->assertCount(1, $warnings); |
|
1141 | + $this->assertEquals( 2, $numErrors ); |
|
1142 | + $this->assertCount( 2, $errors ); |
|
1143 | + $this->assertEquals( 1, $numWarnings ); |
|
1144 | + $this->assertCount( 1, $warnings ); |
|
1145 | 1145 | |
1146 | 1146 | // Suppress a whole standard. |
1147 | - $content = '<?php '.PHP_EOL.'// phpcs:ignore Generic'.PHP_EOL.'$var = FALSE; //TODO: write some code'.PHP_EOL.'$var = FALSE; //TODO: write some code'; |
|
1148 | - $file = new DummyFile($content, $ruleset, $config); |
|
1147 | + $content = '<?php ' . PHP_EOL . '// phpcs:ignore Generic' . PHP_EOL . '$var = FALSE; //TODO: write some code' . PHP_EOL . '$var = FALSE; //TODO: write some code'; |
|
1148 | + $file = new DummyFile( $content, $ruleset, $config ); |
|
1149 | 1149 | $file->process(); |
1150 | 1150 | |
1151 | 1151 | $errors = $file->getErrors(); |
1152 | 1152 | $numErrors = $file->getErrorCount(); |
1153 | 1153 | $warnings = $file->getWarnings(); |
1154 | 1154 | $numWarnings = $file->getWarningCount(); |
1155 | - $this->assertEquals(1, $numErrors); |
|
1156 | - $this->assertCount(1, $errors); |
|
1157 | - $this->assertEquals(1, $numWarnings); |
|
1158 | - $this->assertCount(1, $warnings); |
|
1155 | + $this->assertEquals( 1, $numErrors ); |
|
1156 | + $this->assertCount( 1, $errors ); |
|
1157 | + $this->assertEquals( 1, $numWarnings ); |
|
1158 | + $this->assertCount( 1, $warnings ); |
|
1159 | 1159 | |
1160 | 1160 | }//end testIgnoreSelected() |
1161 | 1161 | |
@@ -1168,83 +1168,83 @@ discard block |
||
1168 | 1168 | public function testCommenting() |
1169 | 1169 | { |
1170 | 1170 | $config = new Config(); |
1171 | - $config->standards = ['Generic']; |
|
1171 | + $config->standards = [ 'Generic' ]; |
|
1172 | 1172 | $config->sniffs = [ |
1173 | 1173 | 'Generic.PHP.LowerCaseConstant', |
1174 | 1174 | 'Generic.Commenting.Todo', |
1175 | 1175 | ]; |
1176 | 1176 | |
1177 | - $ruleset = new Ruleset($config); |
|
1177 | + $ruleset = new Ruleset( $config ); |
|
1178 | 1178 | |
1179 | 1179 | // Suppress a single sniff. |
1180 | - $content = '<?php '.PHP_EOL.'// phpcs:ignore Generic.Commenting.Todo -- Because reasons'.PHP_EOL.'$var = FALSE; //TODO: write some code'.PHP_EOL.'$var = FALSE; //TODO: write some code'; |
|
1181 | - $file = new DummyFile($content, $ruleset, $config); |
|
1180 | + $content = '<?php ' . PHP_EOL . '// phpcs:ignore Generic.Commenting.Todo -- Because reasons' . PHP_EOL . '$var = FALSE; //TODO: write some code' . PHP_EOL . '$var = FALSE; //TODO: write some code'; |
|
1181 | + $file = new DummyFile( $content, $ruleset, $config ); |
|
1182 | 1182 | $file->process(); |
1183 | 1183 | |
1184 | 1184 | $errors = $file->getErrors(); |
1185 | 1185 | $numErrors = $file->getErrorCount(); |
1186 | 1186 | $warnings = $file->getWarnings(); |
1187 | 1187 | $numWarnings = $file->getWarningCount(); |
1188 | - $this->assertEquals(2, $numErrors); |
|
1189 | - $this->assertCount(2, $errors); |
|
1190 | - $this->assertEquals(1, $numWarnings); |
|
1191 | - $this->assertCount(1, $warnings); |
|
1188 | + $this->assertEquals( 2, $numErrors ); |
|
1189 | + $this->assertCount( 2, $errors ); |
|
1190 | + $this->assertEquals( 1, $numWarnings ); |
|
1191 | + $this->assertCount( 1, $warnings ); |
|
1192 | 1192 | |
1193 | 1193 | // Suppress a single sniff and re-enable. |
1194 | - $content = '<?php '.PHP_EOL.'// phpcs:disable Generic.Commenting.Todo --Because reasons'.PHP_EOL.'$var = FALSE;'.PHP_EOL.'//TODO: write some code'.PHP_EOL.'// phpcs:enable Generic.Commenting.Todo -- Because reasons'.PHP_EOL.'//TODO: write some code'; |
|
1195 | - $file = new DummyFile($content, $ruleset, $config); |
|
1194 | + $content = '<?php ' . PHP_EOL . '// phpcs:disable Generic.Commenting.Todo --Because reasons' . PHP_EOL . '$var = FALSE;' . PHP_EOL . '//TODO: write some code' . PHP_EOL . '// phpcs:enable Generic.Commenting.Todo -- Because reasons' . PHP_EOL . '//TODO: write some code'; |
|
1195 | + $file = new DummyFile( $content, $ruleset, $config ); |
|
1196 | 1196 | $file->process(); |
1197 | 1197 | |
1198 | 1198 | $errors = $file->getErrors(); |
1199 | 1199 | $numErrors = $file->getErrorCount(); |
1200 | 1200 | $warnings = $file->getWarnings(); |
1201 | 1201 | $numWarnings = $file->getWarningCount(); |
1202 | - $this->assertEquals(1, $numErrors); |
|
1203 | - $this->assertCount(1, $errors); |
|
1204 | - $this->assertEquals(1, $numWarnings); |
|
1205 | - $this->assertCount(1, $warnings); |
|
1202 | + $this->assertEquals( 1, $numErrors ); |
|
1203 | + $this->assertCount( 1, $errors ); |
|
1204 | + $this->assertEquals( 1, $numWarnings ); |
|
1205 | + $this->assertCount( 1, $warnings ); |
|
1206 | 1206 | |
1207 | 1207 | // Suppress a single sniff using block comments. |
1208 | - $content = '<?php '.PHP_EOL.'/*'.PHP_EOL.' Disable some checks'.PHP_EOL.' phpcs:disable Generic.Commenting.Todo'.PHP_EOL.'*/'.PHP_EOL.'$var = FALSE;'.PHP_EOL.'//TODO: write some code'; |
|
1209 | - $file = new DummyFile($content, $ruleset, $config); |
|
1208 | + $content = '<?php ' . PHP_EOL . '/*' . PHP_EOL . ' Disable some checks' . PHP_EOL . ' phpcs:disable Generic.Commenting.Todo' . PHP_EOL . '*/' . PHP_EOL . '$var = FALSE;' . PHP_EOL . '//TODO: write some code'; |
|
1209 | + $file = new DummyFile( $content, $ruleset, $config ); |
|
1210 | 1210 | $file->process(); |
1211 | 1211 | |
1212 | 1212 | $errors = $file->getErrors(); |
1213 | 1213 | $numErrors = $file->getErrorCount(); |
1214 | 1214 | $warnings = $file->getWarnings(); |
1215 | 1215 | $numWarnings = $file->getWarningCount(); |
1216 | - $this->assertEquals(1, $numErrors); |
|
1217 | - $this->assertCount(1, $errors); |
|
1218 | - $this->assertEquals(0, $numWarnings); |
|
1219 | - $this->assertCount(0, $warnings); |
|
1216 | + $this->assertEquals( 1, $numErrors ); |
|
1217 | + $this->assertCount( 1, $errors ); |
|
1218 | + $this->assertEquals( 0, $numWarnings ); |
|
1219 | + $this->assertCount( 0, $warnings ); |
|
1220 | 1220 | |
1221 | 1221 | // Suppress a single sniff with a multi-line comment. |
1222 | - $content = '<?php '.PHP_EOL.'// Turn off a check for the next line of code.'.PHP_EOL.'// phpcs:ignore Generic.Commenting.Todo'.PHP_EOL.'$var = FALSE; //TODO: write some code'.PHP_EOL.'$var = FALSE; //TODO: write some code'; |
|
1223 | - $file = new DummyFile($content, $ruleset, $config); |
|
1222 | + $content = '<?php ' . PHP_EOL . '// Turn off a check for the next line of code.' . PHP_EOL . '// phpcs:ignore Generic.Commenting.Todo' . PHP_EOL . '$var = FALSE; //TODO: write some code' . PHP_EOL . '$var = FALSE; //TODO: write some code'; |
|
1223 | + $file = new DummyFile( $content, $ruleset, $config ); |
|
1224 | 1224 | $file->process(); |
1225 | 1225 | |
1226 | 1226 | $errors = $file->getErrors(); |
1227 | 1227 | $numErrors = $file->getErrorCount(); |
1228 | 1228 | $warnings = $file->getWarnings(); |
1229 | 1229 | $numWarnings = $file->getWarningCount(); |
1230 | - $this->assertEquals(2, $numErrors); |
|
1231 | - $this->assertCount(2, $errors); |
|
1232 | - $this->assertEquals(1, $numWarnings); |
|
1233 | - $this->assertCount(1, $warnings); |
|
1230 | + $this->assertEquals( 2, $numErrors ); |
|
1231 | + $this->assertCount( 2, $errors ); |
|
1232 | + $this->assertEquals( 1, $numWarnings ); |
|
1233 | + $this->assertCount( 1, $warnings ); |
|
1234 | 1234 | |
1235 | 1235 | // Ignore an enable before a disable. |
1236 | - $content = '<?php '.PHP_EOL.'// phpcs:enable Generic.PHP.NoSilencedErrors -- Because reasons'.PHP_EOL.'$var = @delete( $filename );'.PHP_EOL; |
|
1237 | - $file = new DummyFile($content, $ruleset, $config); |
|
1236 | + $content = '<?php ' . PHP_EOL . '// phpcs:enable Generic.PHP.NoSilencedErrors -- Because reasons' . PHP_EOL . '$var = @delete( $filename );' . PHP_EOL; |
|
1237 | + $file = new DummyFile( $content, $ruleset, $config ); |
|
1238 | 1238 | $file->process(); |
1239 | 1239 | |
1240 | 1240 | $errors = $file->getErrors(); |
1241 | 1241 | $numErrors = $file->getErrorCount(); |
1242 | 1242 | $warnings = $file->getWarnings(); |
1243 | 1243 | $numWarnings = $file->getWarningCount(); |
1244 | - $this->assertEquals(0, $numErrors); |
|
1245 | - $this->assertCount(0, $errors); |
|
1246 | - $this->assertEquals(0, $numWarnings); |
|
1247 | - $this->assertCount(0, $warnings); |
|
1244 | + $this->assertEquals( 0, $numErrors ); |
|
1245 | + $this->assertCount( 0, $errors ); |
|
1246 | + $this->assertEquals( 0, $numWarnings ); |
|
1247 | + $this->assertCount( 0, $warnings ); |
|
1248 | 1248 | |
1249 | 1249 | }//end testCommenting() |
1250 | 1250 |
@@ -16,7 +16,7 @@ discard block |
||
16 | 16 | |
17 | 17 | namespace PHP_CodeSniffer; |
18 | 18 | |
19 | -if (class_exists('PHP_CodeSniffer\Autoload', false) === false) { |
|
19 | +if ( class_exists( 'PHP_CodeSniffer\Autoload', false ) === false ) { |
|
20 | 20 | class Autoload |
21 | 21 | { |
22 | 22 | |
@@ -32,14 +32,14 @@ discard block |
||
32 | 32 | * |
33 | 33 | * @var array<string, string> |
34 | 34 | */ |
35 | - private static $loadedClasses = []; |
|
35 | + private static $loadedClasses = [ ]; |
|
36 | 36 | |
37 | 37 | /** |
38 | 38 | * A mapping of class names to file names. |
39 | 39 | * |
40 | 40 | * @var array<string, string> |
41 | 41 | */ |
42 | - private static $loadedFiles = []; |
|
42 | + private static $loadedFiles = [ ]; |
|
43 | 43 | |
44 | 44 | /** |
45 | 45 | * A list of additional directories to search during autoloading. |
@@ -48,7 +48,7 @@ discard block |
||
48 | 48 | * |
49 | 49 | * @var string[] |
50 | 50 | */ |
51 | - private static $searchPaths = []; |
|
51 | + private static $searchPaths = [ ]; |
|
52 | 52 | |
53 | 53 | |
54 | 54 | /** |
@@ -61,23 +61,23 @@ discard block |
||
61 | 61 | * |
62 | 62 | * @return bool |
63 | 63 | */ |
64 | - public static function load($class) |
|
64 | + public static function load( $class ) |
|
65 | 65 | { |
66 | 66 | // Include the composer autoloader if there is one, but re-register it |
67 | 67 | // so this autoloader runs before the composer one as we need to include |
68 | 68 | // all files so we can figure out what the class/interface/trait name is. |
69 | - if (self::$composerAutoloader === null) { |
|
69 | + if ( self::$composerAutoloader === null ) { |
|
70 | 70 | // Make sure we don't try to load any of Composer's classes |
71 | 71 | // while the autoloader is being setup. |
72 | - if (strpos($class, 'Composer\\') === 0) { |
|
72 | + if ( strpos( $class, 'Composer\\' ) === 0 ) { |
|
73 | 73 | return; |
74 | 74 | } |
75 | 75 | |
76 | - if (strpos(__DIR__, 'phar://') !== 0 |
|
77 | - && file_exists(__DIR__.'/../../autoload.php') === true |
|
76 | + if ( strpos( __DIR__, 'phar://' ) !== 0 |
|
77 | + && file_exists( __DIR__ . '/../../autoload.php' ) === true |
|
78 | 78 | ) { |
79 | - self::$composerAutoloader = include __DIR__.'/../../autoload.php'; |
|
80 | - if (self::$composerAutoloader instanceof \Composer\Autoload\ClassLoader) { |
|
79 | + self::$composerAutoloader = include __DIR__ . '/../../autoload.php'; |
|
80 | + if ( self::$composerAutoloader instanceof \Composer\Autoload\ClassLoader ) { |
|
81 | 81 | self::$composerAutoloader->unregister(); |
82 | 82 | self::$composerAutoloader->register(); |
83 | 83 | } else { |
@@ -93,36 +93,36 @@ discard block |
||
93 | 93 | $ds = DIRECTORY_SEPARATOR; |
94 | 94 | $path = false; |
95 | 95 | |
96 | - if (substr($class, 0, 16) === 'PHP_CodeSniffer\\') { |
|
97 | - if (substr($class, 0, 22) === 'PHP_CodeSniffer\Tests\\') { |
|
98 | - $isInstalled = !is_dir(__DIR__.$ds.'tests'); |
|
99 | - if ($isInstalled === false) { |
|
100 | - $path = __DIR__.$ds.'tests'; |
|
96 | + if ( substr( $class, 0, 16 ) === 'PHP_CodeSniffer\\' ) { |
|
97 | + if ( substr( $class, 0, 22 ) === 'PHP_CodeSniffer\Tests\\' ) { |
|
98 | + $isInstalled = ! is_dir( __DIR__ . $ds . 'tests' ); |
|
99 | + if ( $isInstalled === false ) { |
|
100 | + $path = __DIR__ . $ds . 'tests'; |
|
101 | 101 | } else { |
102 | - $path = '@test_dir@'.$ds.'PHP_CodeSniffer'.$ds.'CodeSniffer'; |
|
102 | + $path = '@test_dir@' . $ds . 'PHP_CodeSniffer' . $ds . 'CodeSniffer'; |
|
103 | 103 | } |
104 | 104 | |
105 | - $path .= $ds.substr(str_replace('\\', $ds, $class), 22).'.php'; |
|
105 | + $path .= $ds . substr( str_replace( '\\', $ds, $class ), 22 ) . '.php'; |
|
106 | 106 | } else { |
107 | - $path = __DIR__.$ds.'src'.$ds.substr(str_replace('\\', $ds, $class), 16).'.php'; |
|
107 | + $path = __DIR__ . $ds . 'src' . $ds . substr( str_replace( '\\', $ds, $class ), 16 ) . '.php'; |
|
108 | 108 | } |
109 | 109 | } |
110 | 110 | |
111 | 111 | // See if the composer autoloader knows where the class is. |
112 | - if ($path === false && self::$composerAutoloader !== false) { |
|
113 | - $path = self::$composerAutoloader->findFile($class); |
|
112 | + if ( $path === false && self::$composerAutoloader !== false ) { |
|
113 | + $path = self::$composerAutoloader->findFile( $class ); |
|
114 | 114 | } |
115 | 115 | |
116 | 116 | // See if the class is inside one of our alternate search paths. |
117 | - if ($path === false) { |
|
118 | - foreach (self::$searchPaths as $searchPath => $nsPrefix) { |
|
117 | + if ( $path === false ) { |
|
118 | + foreach ( self::$searchPaths as $searchPath => $nsPrefix ) { |
|
119 | 119 | $className = $class; |
120 | - if ($nsPrefix !== '' && substr($class, 0, strlen($nsPrefix)) === $nsPrefix) { |
|
121 | - $className = substr($class, (strlen($nsPrefix) + 1)); |
|
120 | + if ( $nsPrefix !== '' && substr( $class, 0, strlen( $nsPrefix ) ) === $nsPrefix ) { |
|
121 | + $className = substr( $class, ( strlen( $nsPrefix ) + 1 ) ); |
|
122 | 122 | } |
123 | 123 | |
124 | - $path = $searchPath.$ds.str_replace('\\', $ds, $className).'.php'; |
|
125 | - if (is_file($path) === true) { |
|
124 | + $path = $searchPath . $ds . str_replace( '\\', $ds, $className ) . '.php'; |
|
125 | + if ( is_file( $path ) === true ) { |
|
126 | 126 | break; |
127 | 127 | } |
128 | 128 | |
@@ -130,8 +130,8 @@ discard block |
||
130 | 130 | } |
131 | 131 | } |
132 | 132 | |
133 | - if ($path !== false && is_file($path) === true) { |
|
134 | - self::loadFile($path); |
|
133 | + if ( $path !== false && is_file( $path ) === true ) { |
|
134 | + self::loadFile( $path ); |
|
135 | 135 | return true; |
136 | 136 | } |
137 | 137 | |
@@ -147,17 +147,17 @@ discard block |
||
147 | 147 | * |
148 | 148 | * @return string The fully qualified name of the class in the loaded file. |
149 | 149 | */ |
150 | - public static function loadFile($path) |
|
150 | + public static function loadFile( $path ) |
|
151 | 151 | { |
152 | - if (strpos(__DIR__, 'phar://') !== 0) { |
|
153 | - $path = realpath($path); |
|
154 | - if ($path === false) { |
|
152 | + if ( strpos( __DIR__, 'phar://' ) !== 0 ) { |
|
153 | + $path = realpath( $path ); |
|
154 | + if ( $path === false ) { |
|
155 | 155 | return false; |
156 | 156 | } |
157 | 157 | } |
158 | 158 | |
159 | - if (isset(self::$loadedClasses[$path]) === true) { |
|
160 | - return self::$loadedClasses[$path]; |
|
159 | + if ( isset( self::$loadedClasses[ $path ] ) === true ) { |
|
160 | + return self::$loadedClasses[ $path ]; |
|
161 | 161 | } |
162 | 162 | |
163 | 163 | $classes = get_declared_classes(); |
@@ -167,37 +167,37 @@ discard block |
||
167 | 167 | include $path; |
168 | 168 | |
169 | 169 | $className = null; |
170 | - $newClasses = array_reverse(array_diff(get_declared_classes(), $classes)); |
|
171 | - foreach ($newClasses as $name) { |
|
172 | - if (isset(self::$loadedFiles[$name]) === false) { |
|
170 | + $newClasses = array_reverse( array_diff( get_declared_classes(), $classes ) ); |
|
171 | + foreach ( $newClasses as $name ) { |
|
172 | + if ( isset( self::$loadedFiles[ $name ] ) === false ) { |
|
173 | 173 | $className = $name; |
174 | 174 | break; |
175 | 175 | } |
176 | 176 | } |
177 | 177 | |
178 | - if ($className === null) { |
|
179 | - $newClasses = array_reverse(array_diff(get_declared_interfaces(), $interfaces)); |
|
180 | - foreach ($newClasses as $name) { |
|
181 | - if (isset(self::$loadedFiles[$name]) === false) { |
|
178 | + if ( $className === null ) { |
|
179 | + $newClasses = array_reverse( array_diff( get_declared_interfaces(), $interfaces ) ); |
|
180 | + foreach ( $newClasses as $name ) { |
|
181 | + if ( isset( self::$loadedFiles[ $name ] ) === false ) { |
|
182 | 182 | $className = $name; |
183 | 183 | break; |
184 | 184 | } |
185 | 185 | } |
186 | 186 | } |
187 | 187 | |
188 | - if ($className === null) { |
|
189 | - $newClasses = array_reverse(array_diff(get_declared_traits(), $traits)); |
|
190 | - foreach ($newClasses as $name) { |
|
191 | - if (isset(self::$loadedFiles[$name]) === false) { |
|
188 | + if ( $className === null ) { |
|
189 | + $newClasses = array_reverse( array_diff( get_declared_traits(), $traits ) ); |
|
190 | + foreach ( $newClasses as $name ) { |
|
191 | + if ( isset( self::$loadedFiles[ $name ] ) === false ) { |
|
192 | 192 | $className = $name; |
193 | 193 | break; |
194 | 194 | } |
195 | 195 | } |
196 | 196 | } |
197 | 197 | |
198 | - self::$loadedClasses[$path] = $className; |
|
199 | - self::$loadedFiles[$className] = $path; |
|
200 | - return self::$loadedClasses[$path]; |
|
198 | + self::$loadedClasses[ $path ] = $className; |
|
199 | + self::$loadedFiles[ $className ] = $path; |
|
200 | + return self::$loadedClasses[ $path ]; |
|
201 | 201 | |
202 | 202 | }//end loadFile() |
203 | 203 | |
@@ -210,9 +210,9 @@ discard block |
||
210 | 210 | * |
211 | 211 | * @return void |
212 | 212 | */ |
213 | - public static function addSearchPath($path, $nsPrefix='') |
|
213 | + public static function addSearchPath( $path, $nsPrefix = '' ) |
|
214 | 214 | { |
215 | - self::$searchPaths[$path] = rtrim(trim((string) $nsPrefix), '\\'); |
|
215 | + self::$searchPaths[ $path ] = rtrim( trim( (string)$nsPrefix ), '\\' ); |
|
216 | 216 | |
217 | 217 | }//end addSearchPath() |
218 | 218 | |
@@ -237,13 +237,13 @@ discard block |
||
237 | 237 | * @throws \Exception If the file path has not been loaded. |
238 | 238 | * @return string |
239 | 239 | */ |
240 | - public static function getLoadedClassName($path) |
|
240 | + public static function getLoadedClassName( $path ) |
|
241 | 241 | { |
242 | - if (isset(self::$loadedClasses[$path]) === false) { |
|
243 | - throw new \Exception("Cannot get class name for $path; file has not been included"); |
|
242 | + if ( isset( self::$loadedClasses[ $path ] ) === false ) { |
|
243 | + throw new \Exception( "Cannot get class name for $path; file has not been included" ); |
|
244 | 244 | } |
245 | 245 | |
246 | - return self::$loadedClasses[$path]; |
|
246 | + return self::$loadedClasses[ $path ]; |
|
247 | 247 | |
248 | 248 | }//end getLoadedClassName() |
249 | 249 | |
@@ -256,13 +256,13 @@ discard block |
||
256 | 256 | * @throws \Exception If the class name has not been loaded |
257 | 257 | * @return string |
258 | 258 | */ |
259 | - public static function getLoadedFileName($class) |
|
259 | + public static function getLoadedFileName( $class ) |
|
260 | 260 | { |
261 | - if (isset(self::$loadedFiles[$class]) === false) { |
|
262 | - throw new \Exception("Cannot get file name for $class; class has not been included"); |
|
261 | + if ( isset( self::$loadedFiles[ $class ] ) === false ) { |
|
262 | + throw new \Exception( "Cannot get file name for $class; class has not been included" ); |
|
263 | 263 | } |
264 | 264 | |
265 | - return self::$loadedFiles[$class]; |
|
265 | + return self::$loadedFiles[ $class ]; |
|
266 | 266 | |
267 | 267 | }//end getLoadedFileName() |
268 | 268 | |
@@ -296,5 +296,5 @@ discard block |
||
296 | 296 | // Register the autoloader before any existing autoloaders to ensure |
297 | 297 | // it gets a chance to hear about every autoload request, and record |
298 | 298 | // the file and class name for it. |
299 | - spl_autoload_register(__NAMESPACE__.'\Autoload::load', true, true); |
|
299 | + spl_autoload_register( __NAMESPACE__ . '\Autoload::load', true, true ); |
|
300 | 300 | }//end if |