kokororin / vscode-phpfmt

Integrates phpfmt into VS Code
https://marketplace.visualstudio.com/items?itemName=kokororin.vscode-phpfmt
BSD 3-Clause "New" or "Revised" License
129 stars 30 forks source link

PHP8 enums with names that resemble Access Modifiers #120

Closed ili101 closed 10 months ago

ili101 commented 10 months ago

Hi (: Before:

<?php

enum Status {
    case public;
    case protected;
    case private;
}

enum Status: int {
    case public = 0;
    case foo = 1;
    case protected = 2;
    case private = 3;
}

After:

<?php

enum Status {
    case ;case;case;}enum:{case=0;case=1;case=2;case=3;}

Expected: no change

driade commented 10 months ago

There we go, this one was easy :)

ili101 commented 10 months ago

Almost, now they aren't removed but it's changing them to lowercase

<?php

enum Status {
    case PUBLIC;
    case PROTECTED;
    case PRIVATE;
}

enum Status: int {
    case Public = 0;
    case Foo = 1;
    case Protected = 2;
    case Private = 3;
}
<?php

enum Status {
    case public;
    case protected;
    case private;
}

enum Status: int {
    case public = 0;
    case Foo = 1;
    case protected = 2;
    case private = 3;
}
ili101 commented 10 months ago

Also in here space removed public=>

<?php

enum Status: int {
    case public = 0;
    case foo = 1;

    public function getStr(): string
    {
        return match ($this) {
            self::public => 'a',
            self::foo => 'b',
            default => null,
        };
    }
}
<?php

enum Status: int {
    case public = 0;
    case foo = 1;

    public function getStr(): string
    {
        return match ($this) {
            self::public=> 'a',
            self::foo => 'b',
            default => null,
        };
    }
}
driade commented 10 months ago

Thanks @ili101 , new version uploaded

ili101 commented 10 months ago

LGTM🙏