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 189719 - Implement preserve-existing for most formatting options
Summary: Implement preserve-existing for most formatting options
Status: NEW
Alias: None
Product: php
Classification: Unclassified
Component: Formatting & Indentation (show other bugs)
Version: 8.1
Hardware: All All
: P3 normal with 4 votes (vote)
Assignee: Ondrej Brejla
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-08-20 14:00 UTC by Trii
Modified: 2016-09-23 11:18 UTC (History)
4 users (show)

See Also:
Issue Type: ENHANCEMENT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Trii 2010-08-20 14:00:05 UTC
First off, the php formatting is GREAT! I love it, my only request would be for certain code you add extra white space to align bulk assignments, or a large associative array initialization.

It would be great to add a preserve-existing option to these boolean flags. Then I could keep code like the following when running the formatter:

<?php
$myArray = array(
    'val1'          => 1,
    'another_value' => 2,
    'short'         => 3
);


$firstname = $_POST['fname'];
$age       = $_POST['age']; // etc
?>
Comment 1 mcrawford620 2010-10-06 16:27:31 UTC
Definitely agree. Really like all the new options. But I especially want a "Preserve" option for the Wrapping category. I often write statements (usually printf stuff) with many arguments like

<?php
$out = sprintf("This %s will be %s. %s",
              $toyName,
              $status,
              (!empty($t['property_statement']) ? $t['property_statement'] : '')
	);

?>

When there are many arguments, and each argument can be complicated, I prefer to have them on separate lines as above. But setting the option for Method Call Arguments to "If Long" doesn't preserve the new lines for each argument. And if I set it to "Always" then it's silly for normal, small method calls.
Comment 2 SebastianZ 2015-10-09 09:01:24 UTC
The option should work the same as the 'Preserve Existing' option within the 'Braces' category.

Sebastian
Comment 3 riksoft 2015-12-16 17:53:48 UTC
This problem is still existing in v. 8.0.2.

It's particularly nasty with bind_param() because it's a generally long method and the 3 choices given by the formatting option are all bad.

Never: unprintable 2 Km line
Always: eats an entire page
If long: is the only acceptable one but it doesn't honor perfectly the right margin.
Moreover it doesn't work properly if the code is alredy formatted the JS way such as

$stm->bind_param(
	'isissiisiiiiissssssddssis', $u...

)

In any case, none of the above format the code the way I would do.

I don't understand why the simplest of the choices "Preserve" doesn't exist! It would only have to do NOTHING! It's so difficult doing nothing? :-)
Comment 4 riksoft 2015-12-29 11:11:18 UTC
Same problem on NB version 8.1