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

Two passes needed for array_syntax+ single_space_around_construct #7292

Closed
mlocati opened this issue Sep 12, 2023 · 0 comments · Fixed by #7324
Closed

Two passes needed for array_syntax+ single_space_around_construct #7292

mlocati opened this issue Sep 12, 2023 · 0 comments · Fixed by #7324
Labels
kind/bug topic/priority Problems related to fixers' priority

Comments

@mlocati
Copy link
Contributor

mlocati commented Sep 12, 2023

Bug report

Description

Two passes may be required if we use both ArraySyntaxFixer and SingleSpaceAroundConstructFixer.

Runtime version

PHP CS Fixer 3.26.1 Crank Cake by Fabien Potencier and Dariusz Ruminski.
PHP runtime: 7.4.33

Configuration file

<?php

$config = new PhpCsFixer\Config();

return $config
    ->setRules([
        'array_syntax' => true,
        'single_space_around_construct' => true,
    ])
    ->setFinder(PhpCsFixer\Finder::create()
        ->in(__DIR__)
    )
;

Code snippet that reproduces the problem

Let's assume we have this file:

<?php

function foo()
{
    return array // bar
    (
        1,
    );
}

At the first pass, ArraySyntaxFixer changes it to

<?php

function foo()
{
    return  // bar
    [
        1,
    ];
}

(please remark that there are two spaces before the comment)

At the second pass, SingleSpaceAroundConstructFixer changes it to

<?php

function foo()
{
    return // bar
    [
        1,
    ];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug topic/priority Problems related to fixers' priority
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants