File tree Expand file tree Collapse file tree 2 files changed +35
-0
lines changed Expand file tree Collapse file tree 2 files changed +35
-0
lines changed Original file line number Diff line number Diff line change @@ -193,3 +193,11 @@ function switchWithConstantNonDefault($i) {
193
193
return 2 ;
194
194
}
195
195
}
196
+
197
+ class Foo {
198
+ /* testClassConstant */
199
+ const DEFAULT = 'foo ' ;
200
+
201
+ /* testMethodDeclaration */
202
+ public function default () {}
203
+ }
Original file line number Diff line number Diff line change @@ -267,9 +267,36 @@ public function dataNotDefaultKeyword()
267
267
'class-property-in-switch-case ' => ['/* testClassPropertyInSwitchCase */ ' ],
268
268
'namespaced-constant-in-switch-case ' => ['/* testNamespacedConstantInSwitchCase */ ' ],
269
269
'namespace-relative-constant-in-switch-case ' => ['/* testNamespaceRelativeConstantInSwitchCase */ ' ],
270
+
271
+ 'class-constant-declaration ' => ['/* testClassConstant */ ' ],
272
+ 'class-method-declaration ' => [
273
+ '/* testMethodDeclaration */ ' ,
274
+ 'default ' ,
275
+ ],
270
276
];
271
277
272
278
}//end dataNotDefaultKeyword()
273
279
274
280
281
+ /**
282
+ * Test a specific edge case where a scope opener would be incorrectly set.
283
+ *
284
+ * @link https://github.com/squizlabs/PHP_CodeSniffer/issues/3326
285
+ *
286
+ * @return void
287
+ */
288
+ public function testIssue3326 ()
289
+ {
290
+ $ tokens = self ::$ phpcsFile ->getTokens ();
291
+
292
+ $ token = $ this ->getTargetToken ('/* testClassConstant */ ' , [T_SEMICOLON ]);
293
+ $ tokenArray = $ tokens [$ token ];
294
+
295
+ $ this ->assertArrayNotHasKey ('scope_condition ' , $ tokenArray , 'Scope condition is set ' );
296
+ $ this ->assertArrayNotHasKey ('scope_opener ' , $ tokenArray , 'Scope opener is set ' );
297
+ $ this ->assertArrayNotHasKey ('scope_closer ' , $ tokenArray , 'Scope closer is set ' );
298
+
299
+ }//end testIssue3326()
300
+
301
+
275
302
}//end class
You can’t perform that action at this time.
0 commit comments