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

String text with params issue #54

Closed finalblast closed 1 year ago

finalblast commented 1 year ago

Before

<?php

class Test
{
    public function test()
    {
        $item = [
            'id' => 1,
            'type' => 'x',
            'name' => 'Test'
        ];
        $suffix = 'Blah';
        $test = "{$item['name']} ({$item['id']}) | {$item['type']} {$suffix}";

        return $test;
    }
}

After

<?php

class Test
{
    public function test()
    {
        $item = [
            'id' => 1,
            'type' => 'x',
            'name' => 'Test'
        ];
        $suffix = 'Blah';
        $test = "{$item['name'];} ({$item['id'];}) | {$item['type'];} {$suffix}";

        return $test;
    }
}

Configs:

{
    "version": 4,
    "php_bin": "/opt/homebrew/opt/php@7.4/bin/php",
    "format_on_save": false,
    "autocomplete": true,
    "autoimport": true,
    "disable_auto_align": true,
    "indent_with_space": true,
    "passes":
    [
        "StripExtraCommaInArray",
        "RemoveSemicolonAfterCurly",
        "NewLineBeforeReturn",
        "AddMissingParentheses",
        "ReindentSwitchBlocks",
        "OrderAndRemoveUseClauses",
        "DocBlockToComment",
        "PSR2EmptyFunction",
        "StripSpaceWithinControlStructures",
        "ShortArray",
        "AutoSemicolon",
        "OrderMethod", // 2023-06-05
        "OrganizeClass", // 2023-06-05
        "OrderMethodAndVisibility", // 2023-06-05
        "SortUseNameSpace", // 2023-06-05
        "SpaceBetweenMethods", // 2023-06-05
        "TrimSpaceBeforeSemicolon", // 2023-06-05
        "DoubleToSingleQuote"
    ],
    "psr1": false,
    "psr2": true,
    "smart_linebreak_after_curly": true,
    "visibility_order": true,
    "yoda": false,
}
driade commented 1 year ago

Thanks @finalblast, may you please confirm?

finalblast commented 1 year ago

@driade Worked perfect. Thank you.