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

statement_indentation is indenting already correct line #7884

Open
VincentLanglet opened this issue Mar 14, 2024 · 2 comments · May be fixed by #7901
Open

statement_indentation is indenting already correct line #7884

VincentLanglet opened this issue Mar 14, 2024 · 2 comments · May be fixed by #7901
Labels
kind/bug topic/whitespace Indentation, spacing, new lines

Comments

@VincentLanglet
Copy link
Contributor

VincentLanglet commented Mar 14, 2024

Bug report

Description

When running statement_indentation on a multiline if, if the first line is missing indentation, the following lines are getting useless extra indentation. This is especially a blocking point for #7813 since

if (true
    || false
) {
    // foo
}

is fixed to

if (
true
    || false
) {
    // foo
}

and then to

if (
    true
        || false // This line is indented for no reason
) {
    // foo
}

When I expect

if (
    true
    || false // This line is untouched
) {
    // foo
}

Runtime version

3.51.0

Configuration file

'statement_indentation' => true

Code snippet that reproduces the problem

<?php
if (
true
  || false
) {
  // foo
}
@Wirone Wirone added the topic/whitespace Indentation, spacing, new lines label Mar 14, 2024
@VincentLanglet
Copy link
Contributor Author

VincentLanglet commented Mar 15, 2024

In the same way, I would expect

if (
    true
|| false
) {
    // foo
}

to be fixed to

if (
    true
    || false
) {
    // foo
}

but the code is unchanged.

@julienfalque, I see your name on every line of the StatementIndentationFixer.
Are you familiar with this fixer ? It seems complex to me, so far I dunno if the fix can be "easy".

@julienfalque
Copy link
Member

Yes, I introduced it and made most of the bugfixes since then. I should take time to add comments and maybe refactor things to make it more clear. I'm having a look at this bug for now :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug topic/whitespace Indentation, spacing, new lines
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants