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 - Incorrect wrapping of anonymous functions in PHP when Wrapping/Method Call Arguments set to IF_LONG
Summary: Incorrect wrapping of anonymous functions in PHP when Wrapping/Method Call Ar...
Status: NEW
Alias: None
Product: php
Classification: Unclassified
Component: Formatting & Indentation (show other bugs)
Version: 8.0.1
Hardware: PC Linux
: P3 normal (vote)
Assignee: Ondrej Brejla
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-11-07 16:23 UTC by t.link
Modified: 2016-08-29 06:06 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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).