#474 closed Bugs (None)
code formatter: bad result for array() embedding func calls
| Reported by: | mdhooge | Owned by: | nobody |
|---|---|---|---|
| Priority: | 5 | Milestone: | |
| Component: | PHP Editor | Version: | None |
| Keywords: | Cc: |
Description
When I ask to reformat the following expression:
$example = array(substr('abcdef', 2), substr('zyxw',
2));
I get this result:
$example = array (
substr('abcdef',
2
), substr('zyxw', 2));
While I would expect this one:
$example = array (
substr('abcdef', 2),
substr('zyxw', 2)
);
Analysis: The code formatter ignores opening
parentheses when looking for commas. And the first
closing parenthese is used to close the array.
Change History (6)
comment:1 Changed 7 years ago by mdhooge
- Summary changed from code formatter with function calls in array() to code formatter: bad result for array() embedding func calls
comment:2 Changed 7 years ago by mdhooge
comment:3 Changed 7 years ago by adie
Logged In: YES user_id=947582 Here another example: /****SOURCE*****/ $primaryFields = array ( array ( 'title' => $tran->getLabel(3147), 'value' => $oferta['numer_oferty'] ), array ( 'title' => $tran->getLabel(54), 'value' => $lokalicazja['gmina'] ), array ( 'title' => $tran->getLabel(55), 'value' => $lokalizacja['miejscowosc'] ) ); /****RESULT********/ $primaryFields = array ( array ( 'title' => $tran->getLabel(3147 ), 'value' => $oferta['numer_oferty'] ), array ( 'title' => $tran->getLabel(54 ), 'value' => $lokalicazja['gmina']), array ( 'title' => $tran->getLabel(55 ), 'value' => $lokalizacja['miejscowosc']));
comment:4 Changed 7 years ago by mdhooge
Logged In: YES
user_id=166420
Formatting the following array definition:
$datasource_options = array (
//'formbuilder_integration' => true
);
gives the result:
$datasource_options = array (
//'formbuilder_integration' => true);
which is totally wrong since the closing parenthesis is now
in the comment.
comment:5 Changed 6 years ago by toshihiro
Logged In: YES user_id=1527096 Originator: NO Fixed in CVS.
comment:6 Changed 6 years ago by sf-robot
- Status changed from assigned to closed
Logged In: YES user_id=1312539 Originator: NO This Tracker item was closed automatically by the system. It was previously set to a Pending status, and the original submitter did not respond within 14 days (the time period specified by the administrator of this Tracker).
Note: See
TracTickets for help on using
tickets.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/eclipsebutton_med.png)
Logged In: YES user_id=166420 I tested the following java code that is more or less equivalent and the result is correct. So maybe it is not too difficult to correct this... public class Test { public int[] arraydfsd = { 1, 2, 3, test(45, 67, 89) }; public static int test(int a, int b, int c) { return a + b + c; } }