plugin-php icon indicating copy to clipboard operation
plugin-php copied to clipboard

prettier-ignore breaking class private/public/protected accessors

Open MarekGogol opened this issue 2 years ago • 3 comments

Hello,

Same issue like #1798, but instead of consts, it breaks protected/public/private definition.

Thanks,

@prettier/plugin-php v0.18.3 Playground link

Input:

<?php

class ClassA {
	protected $test = 1;
  
	// prettier-ignore
  	protected $test = 2;
}

Output:

<?php

class ClassA
{
    protected $test = 1;

    // prettier-ignore
    $test = 2
}

MarekGogol avatar Mar 24 '22 18:03 MarekGogol

Any update? Same issue here.

And also static is removed.

class A
{
    // prettier-ignore
    static $test = 1;
}

becomes

class A
{
    // prettier-ignore
    $test = 1
}

Tietew avatar Apr 15 '22 08:04 Tietew

This is caused by a bug in the parser: https://github.com/glayzzle/php-parser/issues/511

czosel avatar Apr 15 '22 08:04 czosel

Thank you @czosel

Workaround: https://github.com/prettier/plugin-php/issues/1222#issuecomment-924452644

Tietew avatar Apr 15 '22 08:04 Tietew