Skip to content

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

@Jeroeny

Description

@Jeroeny

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions