Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dumping an array variable does not use the Printer's overridden indentation #41

Closed
Jeroeny opened this issue Jan 2, 2019 · 2 comments
Closed

Comments

@Jeroeny
Copy link

@Jeroeny Jeroeny commented Jan 2, 2019

php version: 7.3.0
nette/php-generator version: 3.2.1

Bug Description

When adding a constant to a class as below

$map = [
    'foo' => 'bar',
    'example' => 'value',
];

$class
    ->addConstant('MAP', $map)
    ->setVisibility(ClassType::VISIBILITY_PROTECTED);

it results in:

    protected const MAP = [
	'foo' => 'bar',
	'example' => 'value',
    ];

When printing with Nette\PhpGenerator\PsrPrinter.

Expected Behavior

The constant printed with PsrPrinter's 4 spaces indentation instead of tabs.

Possible Solution

The tab is hardcoded at https://github.com/nette/php-generator/blob/master/src/PhpGenerator/Helpers.php#L74. Could we change it so that we can pass the indentation to the helper?

@zeleznypa

This comment has been minimized.

Copy link
Contributor

@zeleznypa zeleznypa commented Jun 21, 2019

I also have this issue.

@Jeroeny

This comment has been minimized.

Copy link
Author

@Jeroeny Jeroeny commented Jun 21, 2019

@zeleznypa I've worked around this with:

Nette\PhpGenerator\Helpers::tabsToSpaces($contents);
@dg dg closed this in aea6e81 Jul 5, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.