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
ichiriac opened this issue Jan 19, 2020 · 16 comments
Open
1 task

Add PHP 8 Support / WIP #486

ichiriac opened this issue Jan 19, 2020 · 16 comments

Comments

@ichiriac
Copy link
Member

@ichiriac ichiriac commented Jan 19, 2020

Prepare the parser to PHP 8 :

Work In Progress as RFC are not yet closed

@Selion05
Copy link
Contributor

@Selion05 Selion05 commented Jan 10, 2021

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

What is the status about php 8 support?

@Wulfheart
Copy link

@Wulfheart Wulfheart commented Feb 5, 2021

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 cseufert commented Mar 22, 2021

There are now patches available for:

  • named arguments #673
  • property promotion c1 #697
  • union types #656 (merged in php8 staging branch)
  • match expression #686
  • nullsafe operator #662 (merged in php8 staging branch)

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 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 cseufert commented Mar 24, 2021

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

  • #686 Match expression
  • #697 Promoted properties v2

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 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 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 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

@cseufert cseufert commented Aug 16, 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) { }

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

@jaulz
Copy link

@jaulz 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 czosel commented Nov 1, 2021

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

@jaulz
Copy link

@jaulz 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 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 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

@ichiriac ichiriac commented Nov 10, 2021

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 yaegassy commented Dec 7, 2021

Hi, any progress on PHP8 support?

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

9 participants