This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.
Product Version: NetBeans IDE Dev (Build 091110-1c3b2021de36) Java: 1.6.0_16; Java HotSpot(TM) 64-Bit Server VM 14.2-b01 for more info about anonymous functions see http://us2.php.net/manual/en/functions.anonymous.php code: <?php echo preg_replace_callback('~-([a-z])~', function ($match) { return strtoupper($match[1]); }, 'hello-world'); // outputs helloWorld ?> results into: <?php echo preg_replace_callback('~-([a-z])~', function ($match) { return strtoupper($match[1]); } , 'hello-world'); // outputs helloWorld ?> code <?php $greet = function($name) { printf("Hello %s\r\n", $name); }; $greet('World'); $greet('PHP'); ?> results into <?php $greet = function($name) { printf("Hello %s\r\n", $name); } ; $greet('World'); $greet('PHP'); ?>
I understand that the problem is about the unwanted breaks between '}' and ','
the first example has problem with new line after '}' followed by ',' the second example has problem with new line after '}' followed by ';' as well as with closing bracket that is not formatted correctly. Should be below $greet I guess.
Fixed. http://hg.netbeans.org/web-main/rev/16b27b89909a
verified Product Version: NetBeans IDE Dev (Build 091119-840bbe3ddcb3) Java: 1.5.0_17-ea; Java HotSpot(TM) 64-Bit Server VM 1.5.0_17-ea-b01
Integrated into 'main-golden', will be available in build *200911200201* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress) Changeset: http://hg.netbeans.org/main/rev/16b27b89909a User: Tomasz Slota <tslota@netbeans.org> Log: #176453 - [formatting ]wrong formatting of anonymous functions
I've been asked for a code review. http://hg.netbeans.org/web-main/rev/16b27b89909a 1.24 + if (tokenSequence.token().id() == PHPTokenId.WHITESPACE){ 1.25 + tokenSequence.moveNext(); 1.26 + } 1.27 + 1.28 + PHPTokenId id = tokenSequence.token().id(); the code is potentially errorneous - if the condition on 1.24 is true and then tokenSequence.moveNext() returns false, the subsequent code on 1.28 may fail. I let the decision whether a subsequent fix if necessary or not no Tomasz, but as the fix is now, I CANNOT approve it.
I can actually tell that in this case tokenSequence.moveNext() will be always true, but you are right, an explicit check will make the maintenance easier.. I will commit it right away