prettier / plugin-php

Prettier PHP Plugin

Home Page:https://loilo.github.io/prettier-php-playground/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Prettier 3 support

erropix opened this issue ยท comments

The @prettier/plugin-php requires prettier@"^1.15.0 || ^2.0.0" and I couldn't update to prettier 3

Can you bump the required version?

Working with prettier 3 would be amazing

Kindly fix this ASAP ๐Ÿ™

with node v20.5.0

i forced install of prettier 3 and this plugin with :
npm install -D prettier@latest
npm install -D --force @prettier/plugin-php

i have type: module in package.json

when running prettier it said
[error] No parser could be inferred for file "src/Controller/ControlController.php"

so i added the following in .prettierrc.js
{
...
plugins: ["@prettier/plugin-php"],
}

and now it says :
[error] src/Controller/ControlController.php: TypeError: Invalid value used as weak map key
[error] at WeakMap.set ()
[error] at getSortedChildNodes (file://node_modules/prettier/index.mjs:17581:19)
[error] at file://node_modules/prettier/index.mjs:17576:52
[error] at Array.flatMap ()
[error] at getSortedChildNodes (file://node_modules/prettier/index.mjs:17575:6)
[error] at decorateComment (file://node_modules/prettier/index.mjs:17588:22)
[error] at decorateComment (file://node_modules/prettier/index.mjs:17599:14)
[error] at file://node_modules/prettier/index.mjs:17655:8
[error] at Array.map ()
[error] at attachComments (file://node_modules/prettier/index.mjs:17654:38)

@czosel, Do you have any information on when this plugin will be supporting prettier@3?

@erropix Ill take a look at #2197 and make a new release next week, currently on vacation ๐Ÿ๏ธ

@czosel thanks for the reply, that's good news ๐Ÿ˜„

Prettier's plugin migration guidance: How to migrate my plugin to support Prettier v3?

More from the Prettier v3 changelog:

In order to support async parsers for embedded languages, we had to introduce a breaking change to the plugin API. Namely, the embed method of a printer has now to match a completely new signature, incompatible with previous versions. If you're a plugin author and your plugins don't define embed, you have nothing to worry about, otherwise see the docs for details.

Thanks for posting the reference @joemaller! AFAIK weโ€™re currently not implementing embed. There might be a few tweaks we should do though - PRs are more than welcome!

I gave the upgrade a try in #2200, but got stuck in the process. Turns out that several changes are needed to make this plugin compatible with prettier v3. Since I'm short on time, I'd be happy for any help with completing the upgrade.

Basic prettier 3 support landed in #2200 (thanks again @fisker!). Only thing that is blocking a release now are some failing tests in standalone mode (RUN_STANDALONE_TESTS=true yarn test). I can try to investigate further tomorrow, but I'll also ping @loilo ๐Ÿ˜‰

Do we have plan to migrate to ESM?

Definitely! Thanks for all your contributions @fisker, Iโ€™ll review and merge them tonight (CET)!

Prettier 3 support landed in v0.20.0 ๐Ÿฅณ

Thanks you @czosel ๐Ÿ‘

Updated playground to Prettier 3 and Plugin version v0.20. ๐ŸŽ‰

Nice, thanks @loilo! ๐Ÿ’ฏ