Php-parser: Add PHP 8 Support / WIP

Created on 19 Jan 2020  路  9Comments  路  Source: glayzzle/php-parser

Prepare the parser to PHP 8 :

Work In Progress as RFC are not yet closed

help wanted good first issue

All 9 comments

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

What is the status about php 8 support?

What鈥檚 new in PHP8?

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

I鈥檇 suggest creating an separate issue for each if these features.

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

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.

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

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.

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

Hello,

There is no tracking for non-capturing catches - } catch (Exception) { Parse Error : syntax error, unexpected ')'
I created a pull request https://github.com/glayzzle/php-parser/pull/755

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) { }

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:
https://github.com/glayzzle/php-parser/pull/785

Was this page helpful?
0 / 5 - 0 ratings

Related issues

alexander-akait picture alexander-akait  路  3Comments

alexander-akait picture alexander-akait  路  9Comments

alexander-akait picture alexander-akait  路  3Comments

nevadascout picture nevadascout  路  3Comments

alexander-akait picture alexander-akait  路  8Comments