driade / phpfmt8

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

Switch statement #81

Closed Tomirad closed 1 month ago

Tomirad commented 1 month ago

Hello,

I have code:

switch ($role) {
    case Role::SUPER_ADMIN:
    case Role::ADMIN:
        $url = '/admin-panel';
        break;
    case Role::DIRECTOR:
        $url = '/director-panel';
        break;
    case Role::ACCOUNTANT:
        $url = '/billing-panel';
        break;
    default:
        $url = '/guest-panel';
}

but after using this package I have removed indentation.

switch ($role) {
case Role::SUPER_ADMIN:
case Role::ADMIN:
    $url = '/admin-panel';
    break;
case Role::DIRECTOR:
    $url = '/director-panel';
    break;
case Role::ACCOUNTANT:
    $url = '/billing-panel';
    break;
default:
    $url = '/guest-panel';
}

What can I do to prevent it from removing indents?

Tomirad commented 1 month ago

enum { case; } also too.

driade commented 1 month ago

Hi @Tomirad This is quite strange. May you please share your config (what rules are you using)?

Tomirad commented 1 month ago

My conf for phpftm is it: { "php_bin": "W:\\WebServer\\php\\php8.3\\php.exe" } That is, the basic thing.

I'm using this in Sublime Text 4169 - no license, Windows 11

Other package is: ApacheConf, Folder Aliaser, FTPSync, Function Name Display, Git, GitStatus, Goto-CSS-Declaration, GoToClass, hex to Int Preview, HexViewer, HTMLBeautify, JavaScript Beautify, Json Colors And Navigation, MikrotikScript, Minifi, nginx, Paradox, PHP Codebeautyfier, phpfmt, PHPIntel, Pretty JSON, Print to HTML, SFTP, SideBarEnhancements, SqlBeautyfier, Squirrel, Status Bar JsonPath, StatusMessage, Theme - Monokai Pro, WakaTime, xml2json.

But, on other PC with fewer add-ons this also occurs. Practically only SFTP, Wakatime and phpfmt and PHPIntel.

When I disabled phpfmt, this problem did not occur.

driade commented 1 month ago

Hi. Could you please activate try with this config and see if it still happens? Thank you

{
    "autocomplete": false,
    "autoimport": false,
    "excludes": [
        "SpaceBetweenMethods"
    ],
    "format_on_save": true,
    "passes":
    [
        "AlignDoubleArrow",
        "AlignPHPCode",
        "SpaceAfterExclamationMark",
        "AlignConstVisibilityEquals",
        "AutoSemicolon",
        "ConvertOpenTagWithEcho",
        "AlignEquals",
        "MergeNamespaceWithOpenTag",
        "RemoveSemicolonAfterCurly",
        "RestoreComments",
        "ShortArray",
        "ExtraCommaInArray",
        "AlignDoubleSlashComments"
    ],
    "php_bin": "YOUR_PHP_PATH",
    "psr1": false,
    "psr1_naming": true,
    "psr2": true,
    "readini": true,
    "smart_linebreak_after_curly": false,
    "version": 4,
    "wp": false,
}

Please check for the "php_bin" path

Tomirad commented 1 month ago

I activated it. Now the indentation does not go back.

I found that "psr2": false caused the lines to lose indentation.

Thanks!