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 168396 - Incorrect formatting of nested arrays
Summary: Incorrect formatting of nested arrays
Status: VERIFIED FIXED
Alias: None
Product: php
Classification: Unclassified
Component: Formatting & Indentation (show other bugs)
Version: 6.x
Hardware: PC Linux
: P3 blocker with 1 vote (vote)
Assignee: Petr Pisl
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-07-10 12:41 UTC by the_noid
Modified: 2010-04-07 04:39 UTC (History)
2 users (show)

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 the_noid 2009-07-10 12:41:26 UTC
Create a nested array in php:
$testArray = array(
	'subarray1' => array(
		'field1' => 1,
		'field2' => 2
	),
	'subarray2' => array(
		'field3' => 3,
		'field4' => 4
	)
);

Activating reformat results in:
$testArray = array(
	'subarray1' => array(
	'field1' => 1,
	'field2' => 2
	),
	'subarray2' => array(
	'field3' => 3,
	'field4' => 4
	)
);
In case the tabs are not properly transmitted: the four lines containing the 'fieldx' elements are only indented 1 tab,
not two as expected, thus the sub-arrays are not indented. The expected behaviour is to have the four lines with the
'fieldx' elements indented two tabs, one for the outer array, the second for the inner array.
Comment 1 Tomasz Slota 2009-07-23 12:58:09 UTC
confirmed
Comment 2 mcrawford620 2009-08-21 20:47:33 UTC
For what it's worth, this feature works in 6.5 and 6.5.1.
Comment 3 Filip Zamboj 2009-10-07 14:54:46 UTC
oen more use case: 
<?php
$this->getParser()->registerKeys(
    array(
    "test1" => "passed"
));
?>

invoke formatting and the code won't change. Expected result is: 
<?php
$this->getParser()->registerKeys(
    array(                         //4 spaces 
        "test1" => "passed"        //8 spaces 
));
?>

i reproduced this issue in 6.5 so I don't think it's a regression. However, mcrawford620, could you describe a bit more
what exactly works in 6.5 and 6.5.1? It still might be a regression. Thanks


a unit test created indent/qa/issues/168396
Comment 4 mcrawford620 2009-10-07 17:05:19 UTC
Sorry, I guess I was being optimistic. It looks like in 6.5.1, the formatting simply does not touch the arrays. If I
already have a properly nested array, like:

	var $test = array(
		'one' => 10,
		'two' => 5,
		'three' => 2,
		'nested' => array(
			'one',
			'two',
			'three',
			'four',
		)
	);

Then it remains properly nested after a format. (This is what I was seeing when I said it works in 6.5.1.) But an
improperly formatted array like:

	var $test = array(
		'one' => 10,
'two' => 5,
					'three' => 2,
		'nested' => array(
						'one',
		'two',
		'three',
						'four',
		)
	);

also just stays the same.
Comment 5 xantiva 2009-10-31 01:36:34 UTC
In Version 6.8beta ...

If I enter a nested array, the indention is correct. But the formatting does not use this intention.

$test = array(
	'key1' => '123',
	'level1' => array(  <- Press Enter here
		|  <- correct position

This is the formatted code:
$test = array(
	'key1' => '123',
	'level1' => array(
	'key2' => '456'));
Comment 6 Tomasz Slota 2010-02-04 10:11:50 UTC
ppisl is the new owner of formatting/indentation area
Comment 7 Petr Pisl 2010-04-06 15:01:53 UTC
I did some fixes around formatting and indenting arrays. Now it seems to be fixed. Filip please verify.
Comment 8 Filip Zamboj 2010-04-06 17:27:06 UTC
verified 
Product Version: NetBeans IDE Dev (Build 100406-589c3c75a4ea)
Comment 9 Quality Engineering 2010-04-07 04:39:34 UTC
Integrated into 'main-golden', will be available in build *201004070201* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main/rev/a47b814da26c
User: Petr Pisl <ppisl@netbeans.org>
Log: #168396 -  Incorrect formatting of nested arrays