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

Formatting error when type hinting class properties in PHP 8 #91

Closed murugappanrm closed 1 year ago

murugappanrm commented 2 years ago

This is my code:

<?php

declare (strict_types = 1);

class Transaction
{
  public int $test = 10;
}

After saving the file, the formatter formats the$test property wrongly:

<?php

declare (strict_types = 1);

class Transaction
{
 intpublic $test = 10;
}
murugappanrm commented 2 years ago

Hi, Is there any resolution to the problem? This bug is making the usefulness of VS Code Editor to become less.

Jphn commented 2 years ago

The current version of phpfmt does not support class property type hinting. You will need to use a different PHP formatter. I recommend trying PHP Tools extension by DEVSENSE, it provides basic code formatting, IntelliSense and some more features.

cobraprojects commented 1 year ago

Just add "phpfmt.psr2": false, in your settings.json file

murugappanrm commented 1 year ago

@cobraprojects I have set the setting as in the attached screen cap. Is that ok?

Screenshot_1

murugappanrm commented 1 year ago

Hi, Thank you for the update. I did that already but the only trouble is Devsense seems to have lots of problems with Codeigniter 4. So sad.

Regards from, Murugappan Ramanathan

On Monday, 13 June 2022 at 10:14:13 am MYT, João Pedro Holanda Neves ***@***.***> wrote:  

The current version of phpfmt does not support class property type hinting. You will need to use a different PHP formatter. I recommend trying PHP Tools extension by DEVSENSE, it provides basic code formation, IntelliSense and some more features.

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: @.***>

TysiacSzescset commented 1 year ago

For me issue was resolved by adding this to settings.json:

"phpfmt.exclude": [
    "PSR2ModifierVisibilityStaticOrder"
]

No need to disable whole PSR2 formatting.

murugappanrm commented 1 year ago

@TysiacSzescset after making changes as you suggested, it seems to be working now. Thank you.

lucasferreira commented 1 year ago

Hi folks,

I've made some PR to update PHPFMT package to a fresh version AND get oficial support to PHP8 https://github.com/kokororin/vscode-phpfmt/pull/101