Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 3.7.1

Bug #19755 Token of T_CLASS type has no scope_opener and scope_closer keys.
Submitted: 2012-12-17 16:25 UTC
From: awakehl Assigned: squiz
Status: Closed Package: PHP_CodeSniffer (version 1.4.3)
PHP Version: 5.3.6 OS: ubuntu 11.10
Roadmaps: (Not assigned)    

 [2012-12-17 16:25 UTC] awakehl (simon ta)
Description: ------------ Just upgraded from 1.3.3 to 1.4.3 and now have errors with some of my class files. Something like Notice: Undefined index: scope_closer in ../Sniffs/WhiteSpace/FunctionSpacingSniff.php on line 38. There is no scope_closer and scope_opener keys in T_CLASS type token. Test script: --------------- This error reproducing when i'm trying to check this file: <?php class Test { public function test() { if (1) 1; 1 ? (1 ? 1 : 1) : 1; } } Expected result: ---------------- Expected scope_closer and scope_opener keys in token. Actual result: -------------- No scope_closer and scope_opener keys in token. Got php Notice in my sniff.


 [2012-12-19 05:46 UTC] squiz (Greg Sherwood)
-Assigned To: +Assigned To: squiz
This is caused by the fact that the first IF statement has no openers or closers of any kind, and the second has no keyword. So the tokenizer matches the keyword on the first line of the function with the opener on the second.
 [2012-12-19 05:53 UTC] squiz (Greg Sherwood)
-Status: Assigned +Status: Closed
Fix committed to github repo: dd2a9684ad3549