Skip to content

PHP baseline contains 3 extra spaces per start of the line  #8952

@ruudk

Description

@ruudk

Bug report

PHPStan 1.10.2

I just generated the baseline as PHP file and noticed that every line is prepended with 3 spaces.

Code snippet that reproduces the problem

<?php declare(strict_types = 1);

$ignoreErrors = [];
   $ignoreErrors[] = [
	'message' => '#^Cannot call method isGivenKind\\(\\) on PhpCsFixer\\\\Tokenizer\\\\Token\\|null\\.$#',
	'count' => 1,
	'path' => __DIR__ . '/src-dev/CodeStyle/SimpleBusCommandBusFixer.php',
];
   $ignoreErrors[] = [
	'message' => '#^Cannot call method isGivenKind\\(\\) on PhpCsFixer\\\\Tokenizer\\\\Token\\|null\\.$#',
	'count' => 1,
	'path' => __DIR__ . '/src-dev/CodeStyle/SimpleBusCommandSeeFixer.php',
];

Expected output

<?php declare(strict_types = 1);

$ignoreErrors = [];
$ignoreErrors[] = [
	'message' => '#^Cannot call method isGivenKind\\(\\) on PhpCsFixer\\\\Tokenizer\\\\Token\\|null\\.$#',
	'count' => 1,
	'path' => __DIR__ . '/src-dev/CodeStyle/SimpleBusCommandBusFixer.php',
];
$ignoreErrors[] = [
	'message' => '#^Cannot call method isGivenKind\\(\\) on PhpCsFixer\\\\Tokenizer\\\\Token\\|null\\.$#',
	'count' => 1,
	'path' => __DIR__ . '/src-dev/CodeStyle/SimpleBusCommandSeeFixer.php',
];

The weird thing is, this is not reflected in the phpstan-src:
https://github.com/phpstan/phpstan-src/blob/8260032bc6b3641ec80a4b11526869b53d250ac6/src/Command/ErrorFormatter/BaselinePhpErrorFormatter.php#L62-L69

But it is in the generated Phar file:

            foreach ($fileErrorsCounts as $message => $count) {
                $template = <<<'PHP'
   $ignoreErrors[] = [
	'message' => %s,
	'count' => %d,
	'path' => __DIR__ . %s,
];
PHP;

So something goes wrong with the conversion to Phar.

Did PHPStan help you today? Did it make you happy in any way?

As always, one of the best things that happened to the PHP ecosystem!

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions