vscode-phpfmt icon indicating copy to clipboard operation
vscode-phpfmt copied to clipboard

Constant names incorrectly reformatted to lowercase when named after keyword

Open wosevision opened this issue 6 years ago • 0 comments

Hey!

I've noticed some incorrect lowercasing when constant names match certain PHP keywords. The casing-changes keep accidentally slipping into my commits and it's driving me crazy! I couldn't find a supported way to disable this 'rule' (not sure if it is even a rule) so I figured I'd raise an issue since a const shouldn't really be renamed by a formatter!

To see this, run phpfmt on a class with constants whose names match keywords, for example, print or list in uppercase:

abstract class MyConstants
{
    const EXAMPLE = 'example';
    const LIST = 'list';
    const PRINT = 'print';
    const TESTING = 'testing';
    const ECHO = 'echo';
}

The const names get changed upon formatting:

abstract class MyConstants
{
    const EXAMPLE = 'example';
    const list = 'list';    // <<<
    const print = 'print';    // <<<
    const TESTING = 'testing';
    const echo = 'echo';    // <<<
}

Is there some way to disable this?

Thanks for the great formatter!

wosevision avatar May 24 '19 19:05 wosevision