Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PHP 8.2 support #2130

Closed
jirismika opened this issue Jan 12, 2023 · 8 comments
Closed

PHP 8.2 support #2130

jirismika opened this issue Jan 12, 2023 · 8 comments

Comments

@jirismika
Copy link

@prettier/plugin-php v0.19.2
Playground link

Input:

<?php

readonly class MyValueObject {
    public string $myValue;
}

Output:

Invalid phpVersion value. Expected "5.0", "5.1", "5.2", "5.3", "5.4", "5.5", "5.6", "7.0", "7.1", "7.2", "7.3", "7.4", "8.0" or "8.1", but received "8.2".

Expected:
Not fail

Hi,
I would like to ask what are the plans or roadmap to support PHP 8.2

@czosel
Copy link
Collaborator

czosel commented Jan 12, 2023

Readonly class support landed in the parser recentily: glayzzle/php-parser#1046
It should be relatively straight forward to make this work here (bumping the parser, minor changes in the printer). Contributions are welcome 😉

@jirismika
Copy link
Author

Well, the question was more general than only asking about readonly classes, but yes, readonly classes are something I am looking forward to use.
Well, I tried to make it as you've challenged me, but from my attempts (and I haven't tried everything), it looks the parser is also missing support for union and interception types ...

private function foo((Countable&Iterator)|array $values) : void {
    // ...
}
... SyntaxError: Parse Error : syntax error, unexpected '(', expecting T_VARIABLE on line 10
[error]    9 | 
[error] > 10 |   private function foo((Countable&Iterator)|array $values) : void {

Anyway, I gave it a try, but I failed terribly almost on each step as the contribution manual is not too detailed for me and prepared scripts doesn't work as expected (probably because expects global installations of some packages, while IMO it should use and install them locally) ...
yarn - OK, yarn test - failed, because I dont have jest installed globally
Similar with yarn prettier file.php which wasn't found, but I was able to solve it with ./node_modules/.bin/prettier --plugin=. --parser=php file.php

And about the printer, I am not able to debug it easily and I am lost in it.

I've invested some time into it, but most of the time was solving problems with the environment. The entry barrier is too high for me, sorry.

@genintho
Copy link
Contributor

Readonly class support #2131

(jest does not need to be installed globally, yarn should pick the folder version)

@czosel
Copy link
Collaborator

czosel commented Jan 19, 2023

Readonly class support landed in v0.19.3 🎉

@Timbuktu1982
Copy link

Hi there,
i have installed the latest version of plugin-php (0.19.4), but i see the same message, if i use "8.2." for "phpVersion" in .prettierrc.js.
What can i do?
THX

@tomb1n0
Copy link

tomb1n0 commented May 17, 2023

I've ran into the same issue as @Timbuktu1982 with updating the phpVersion in my .prettierrc.json

@czosel
Copy link
Collaborator

czosel commented May 21, 2023

This should be fixed by #2179 - until it is released, you can just use "8.1" as phpVersion (which has the same behavior).

@czosel
Copy link
Collaborator

czosel commented May 22, 2023

@Timbuktu1982 @tomb1n0 v0.19.5 has just been released 🎉

@czosel czosel closed this as completed Sep 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants