driade / phpfmt8

PHP formatter for Sublime Text 4, with PHP 8 support.
BSD 3-Clause "New" or "Revised" License
45 stars 2 forks source link

Add auto semicolon after anonymous class #44

Closed driade closed 1 year ago

driade commented 1 year ago
$instance = new class {}

should become

$instance = new class {};
arcanisgk commented 1 year ago

yes i can confirm that

driade commented 1 year ago

I'm going to close this one because I'm unable to reproduce it now. @arcanisgk could you please double check on your side? With AutoSemicolon I see it's working fine on my side.

arcanisgk commented 1 year ago

This happens when you implement:

"passes":
    [
        "RemoveSemicolonAfterCurly",
    ],

In the sublime text, I'm using the phpfmt extension, and I see that something called "passes" can be implemented with the argument "RemoveSemicolonAfterCurly". What does this mean?

The "RemoveSemicolonAfterCurly" option in the PHP Formatter (phpfmt) extension indicates that semicolons (;) appearing after closing curly braces (}) in PHP code should be removed.

In PHP, semicolons are used to separate statements and terminate declarations. However, in some cases, an unnecessary semicolon is placed after a closing brace that ends a code block (such as a loop, condition, or function). For example:

if ($condition) {
    // code...
};

In this case, the semicolon after the closing brace is not necessary and can be removed without affecting the code's functionality. The "RemoveSemicolonAfterCurly" option in phpfmt automates this removal to make the code cleaner and follow preferred style conventions.

After applying this option, the above code would be formatted as follows:

if ($condition) {
    // code...
}

In summary, "RemoveSemicolonAfterCurly" is a configuration in the phpfmt extension that indicates semicolons after closing braces should be removed to improve the style and readability of PHP code.