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.

Bug 248496

Summary: Incorrect wrapping of anonymous functions in PHP when Wrapping/Method Call Arguments set to IF_LONG
Product: php Reporter: t.link
Component: Formatting & IndentationAssignee: Ondrej Brejla <obrejla>
Status: NEW ---    
Severity: normal    
Priority: P3    
Version: 8.0.1   
Hardware: PC   
OS: Linux   
Issue Type: DEFECT Exception Reporter:

Description t.link 2014-11-07 16:23:07 UTC
Overview:
Wrapping of anonymous functions in PHP is incorrect in NetBeans 8.0.1 when Formatting/Wrapping/Method Call Arguments is set to IF_LONG.

Steps to Reproduce:
1) Set right margin to 120 and wrapping for Method Call Arguments to IF_LONG.
2) Type in the following code:
<?php
$list = [1, 2, 3];
array_map($list, function ($item) {
  return $item.' add some text to the result and generally make it very very long so that the bug in wrapping occurs';
});
?>
3) Reformat the code (Source->Format).

Actual Results:
<?php
$list = [1, 2, 3];
array_map($list,
        function ($item) {
  return $item.' add some text to the result and generally make it very very long so that the bug in wrapping occurs';
});
?>

Expected Results:
No change in formatting.

Build Date & Hardware:
NetBeans IDE 8.0.1 (Build 201408251540) on Debian 7.7

Additional Information:
It seems that NetBeans takes into account the length of the whole anonymous function, while only the first line (until the opening brace) should be accounted for. For example, if in the above scenario we type in the following code:

<?php
$list = [1, 2, 3];
array_map($list, function ($item) {
  return $item;
});
?>

and reformat the code, nothing is changed (correct behavior).