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

Add PHP 8 Support / WIP #486

Open
1 task done
ichiriac opened this issue Jan 19, 2020 · 27 comments
Open
1 task done

Add PHP 8 Support / WIP #486

ichiriac opened this issue Jan 19, 2020 · 27 comments

Comments

@ichiriac
Copy link
Member

ichiriac commented Jan 19, 2020

Prepare the parser to PHP 8 :

Work In Progress as RFC are not yet closed

@Selion05
Copy link
Contributor

https://wiki.php.net/rfc/nullsafe_operator

What is the status about php 8 support?

@Wulfheart
Copy link

What’s new in PHP8?

  • Named arguments
  • Attributes
  • Constructor property promotion
  • Union types
  • Match expression
  • Nullsafe operator

I’d suggest creating an separate issue for each if these features.

Compiled from https://www.php.net/releases/8.0/en.php

@cseufert
Copy link
Collaborator

cseufert commented Mar 22, 2021

There are now patches available for:

so really the work just needs to focus on attributes, however I am not sure the right way to update the lexer to support Attributes.

@czosel
Copy link
Collaborator

czosel commented Mar 24, 2021

Hi @cseufert
Awesome work! #662 has been merged in a temporary php8 branch because I don't know the codebase well enough to just merge stuff into master before @ichiriac took a look as well. If you like, you can point your PRs to the php8 branch as well, and I'll try to find some time for a first review :)

@cseufert
Copy link
Collaborator

cseufert commented Mar 24, 2021

I have changed the following PR's to merge to the php8 branch:

I am going to have a go at getting this stuff working in prettier at some point, and am looking foward to having someone who know the codebase have a review of the code. I feel it could benefit a lot from being ported to typescript, but I guess thats a totally different problem.

@czosel
Copy link
Collaborator

czosel commented Mar 24, 2021

Awesome! As I said before, reviews in the parser are also quite difficult for me - I'm more comfortable on the prettier side. Either way I'll try to do my best to help, it would be awesome to have full php8 support in the prettier plugin :-)

@eldair
Copy link
Contributor

eldair commented Jun 18, 2021

Hello,

There is no tracking for non-capturing catches - } catch (Exception) { Parse Error : syntax error, unexpected ')'
I created a pull request #755

@MasonD
Copy link

MasonD commented Aug 12, 2021

Is this the correct place to remark on an error I noticed with parsing of promoted constructor params? php-parser complains about a syntax error when a promoted constructor param is marked as nullable with a question mark

public function __construct(public ?string $nullable) { }

@cseufert
Copy link
Collaborator

Is this the correct place to remark on an error I noticed with parsing of promoted constructor params? php-parser complains about a syntax error when a promoted constructor param is marked as nullable with a question mark

public function __construct(public ?string $nullable) { }

I have submitted a PR to fix this in the parser:
#785

@jaulz
Copy link

jaulz commented Nov 1, 2021

I also noticed that there seems to be a small issue with Attributes that contain bitwise operators:
image

These lines cause the following error:

Error: Bad terminal sequence "|" at line 7 (offset 87)
    at lexer.matchST_ATTRIBUTE (/foo/node_modules/php-parser/src/lexer/attribute.js:62:11)
    at lexer.next (/foo/node_modules/php-parser/src/lexer.js:443:26)
    at lexer.lex (/foo/node_modules/php-parser/src/lexer.js:363:20)
    at lexer.lex (/foo/node_modules/php-parser/src/lexer.js:363:35)
    at parser.lex (/foo/node_modules/php-parser/src/parser.js:627:29)
    at parser.next (/foo/node_modules/php-parser/src/parser.js:556:8)
    at parser.read_static_getter (/foo/node_modules/php-parser/src/parser/variable.js:99:12)
    at parser.read_variable (/foo/node_modules/php-parser/src/parser/variable.js:80:21)
    at parser.read_expr_item (/foo/node_modules/php-parser/src/parser/expr.js:421:19)
    at parser.read_expr (/foo/node_modules/php-parser/src/parser/expr.js:18:19)

Shall I raise it as a separate issue or do you want to track it here?

@czosel
Copy link
Collaborator

czosel commented Nov 1, 2021

@jaulz I think a separate issue would be better - thanks!

@jaulz
Copy link

jaulz commented Nov 2, 2021

@czosel hm, I noticed that there is a pending issue and PR which talks about merging php8 features into main:
#793
#809

I am using php-parser@3.0.2 right now which already comes with some basic PHP8 features if I understand correctly. Should I rather wait for that before raising the issue?

@czosel
Copy link
Collaborator

czosel commented Nov 2, 2021

Oh, I assumed that you were already working with the php8 branch - sorry! If not, there is a good chance that your issue has already been fixed inside the php8 branch - over the past month several larger features have been merged in this branch, but didn't land in master yet because we still needed the review from @ichiriac. I hope we'll soon be able to merge all of those back into master to avoid future confusion.

@jaulz
Copy link

jaulz commented Nov 2, 2021

Okay, thanks for your quick feedback! 😊 In that case I will just wait for it and come back in case I still notice it afterwards.

@ichiriac
Copy link
Member Author

Hi @czosel, I'll work on pending PR this week-end, if everything is ok then I'll release a new version and publish it on NPM.

@yaegassy
Copy link

yaegassy commented Dec 7, 2021

Hi, any progress on PHP8 support?

@czosel
Copy link
Collaborator

czosel commented May 22, 2022

Further improvements to PHP8 support landed in 3.1.0-beta.6 🎉

@czosel
Copy link
Collaborator

czosel commented Jul 2, 2022

I'd say we could slowly promote the current 3.1.0 release to stable, would you agree? @MaartenStaa @cseufert

@MaartenStaa
Copy link
Collaborator

I'd say we could slowly promote the current 3.1.0 release to stable, would you agree? @MaartenStaa @cseufert

Yes, agreed. Would probably be good to fix #968 first, but things seem to be working well mostly.

I'm going on vacation two weeks as of tomorrow, so during that time I unfortunately won't have time to look at the linked issue.

@czosel
Copy link
Collaborator

czosel commented Jul 7, 2022

👍 enjoy your holiday! 🏝

@cseufert
Copy link
Collaborator

Yes, a 3.1.0 release makes sense to me, which can parse PHP <= 8.1.

It looks like PHP 8.2 has not added much that changes the syntax of the language. From what I can tell it is just the readonly class keyword for proper immutable classes. Is it worth getting this functionality integrated?

@ytetsuro
Copy link
Contributor

ytetsuro commented Aug 9, 2022

@czosel @cseufert @MaartenStaa

Fixed #968.

Are you ready to release 3.1.0 already?

@czosel
Copy link
Collaborator

czosel commented Aug 9, 2022

I’d say we are, I’ll do it soon :-)

@czosel
Copy link
Collaborator

czosel commented Aug 10, 2022

Released v3.1.0 🎉

@briangrider
Copy link

You guys are champions. Thank you for your work maintaining this package!

@ctf0
Copy link

ctf0 commented Dec 14, 2022

am not sure if this is still in WIP or not, but i have the latest release and i still cant read property promotion 😢

@czosel
Copy link
Collaborator

czosel commented Dec 15, 2022

Hi @ctf0, support for promoted properties landed a while ago in #697. Feel free to open an issue with some details if something doesn’t work as expected!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests