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

Indenting not fixed #405

Closed
adam-nielsen opened this issue Mar 18, 2024 Discussed in #399 · 1 comment
Closed

Indenting not fixed #405

adam-nielsen opened this issue Mar 18, 2024 Discussed in #399 · 1 comment

Comments

@adam-nielsen
Copy link

Discussed in #399

Converting to an issue as requested.

Originally posted by adam-nielsen March 15, 2024
I have a bunch of poorly formatted code, but I can't figure out how to get basic stuff like the indenting fixed. For example this file:

if (!$a) {
    if ($b) {
                    // Single line comment indented too far.
                     $a = $b;
    } 
else {
                   /* Comment indented too far. */
                 $x = true;

          /* Another comment indented incorrectly. */
                       $y = true;
    }
}

When I run it, it says:

$ php phpcbf.phar --standard=PSR12 test.php 

PHPCBF RESULT SUMMARY
----------------------------------------
FILE                    FIXED  REMAINING
----------------------------------------
test.php                4      0
----------------------------------------
A TOTAL OF 4 ERRORS WERE FIXED IN 1 FILE
----------------------------------------

Time: 65ms; Memory: 8MB

But all it has done is put that else back on the same line, it hasn't fixed the indenting of any statements or of the comments inside the curly braces.

What am I doing wrong?

@adam-nielsen
Copy link
Author

Closing issue - per the linked discussion, the issue was that unlike linters in other languages, the default rules in phpcs don't enforce any indenting rules. Manually turning them on makes it work as expected.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant