Skip to content
This repository was archived by the owner on Jan 29, 2020. It is now read-only.

ValueGenerator recursive setIndentation #163

Closed
hxss opened this issue Oct 23, 2018 · 9 comments
Closed

ValueGenerator recursive setIndentation #163

hxss opened this issue Oct 23, 2018 · 9 comments
Assignees
Labels
Milestone

Comments

@hxss
Copy link
Contributor

hxss commented Oct 23, 2018

On 363 line ValueGenerator creates childs but dont pass to them self indentation. So when I create new ValueGenerator and use setIndentation method I can set only first level childs indentation.

@Ocramius
Copy link
Member

Ref:

$curValue = new self($curValue, $newType, self::OUTPUT_MULTIPLE_LINE, $this->getConstants());

@Ocramius
Copy link
Member

@hxss you mean that multiline-dumped values are not aligned? Doesn't sound like a big deal to me...

@hxss
Copy link
Contributor Author

hxss commented Oct 23, 2018

@Ocramius please see this example:

$generator = new Zend\Code\Generator\ValueGenerator([
	'a' => [
		'b' => [
			'c' => 'd',
		]
	],
]);
$generator->setIndentation("\t");

echo $generator->generate();

output:

array(
	'a' => array(
        'b' => array(
            'c' => 'd',
        ),
    ),
)

We have 1 tab before 'a' and 4 spaces as indentation on other levels of tree.

@Ocramius
Copy link
Member

Yeah, this is not fixable, unless we touch the var_export() output, which we shouldn't do.

This is too much risk (really, it's not that trivial) for a problem in alignment, so I'm going to close it as "won't fix", sorry.

@Ocramius Ocramius self-assigned this Oct 23, 2018
@hxss
Copy link
Contributor Author

hxss commented Oct 23, 2018

after 363 line need to append $curValue->setIndentation($this->indentation);

$curValue = new self($curValue, $newType, self::OUTPUT_MULTIPLE_LINE, $this->getConstants());

@hxss
Copy link
Contributor Author

hxss commented Oct 23, 2018

@Ocramius in my test $curValue->setIndentation($this->indentation); solve the problem.

@Ocramius
Copy link
Member

@hxss send a patch then: re-opening (also: didn't know the value generator could already do that, thanks for checking!)

@Ocramius Ocramius reopened this Oct 23, 2018
@Ocramius Ocramius assigned hxss and unassigned Ocramius Oct 23, 2018
@Ocramius Ocramius added this to the 3.4.0 milestone Oct 23, 2018
@Ocramius
Copy link
Member

Please remember to add a test case, if yo do

@Ocramius
Copy link
Member

Handled in #164

@michalbundyra michalbundyra modified the milestones: 3.4.0, 3.3.2 Aug 29, 2019
michalbundyra added a commit that referenced this issue Aug 29, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

3 participants