Nikita Popov
1e89658cae
Add PhpVersion class
2022-07-23 17:52:59 +02:00
MathiasReker
050342b5df
Add visibility modifiers to constants
...
Closes GH-848.
2022-07-23 16:04:21 +02:00
Nikita Popov
0ea134a507
Add PHP 8 parser with correct concatenation precedence
...
The PHP 7 and PHP 8 parsers use the same grammar file and only
differ in token precedence.
2022-06-19 20:07:17 +02:00
Nikita Popov
a38a60b7dd
Move Tokens::T_* to Php7::T_*
...
Drop the separate tokens class, move them into the parser.
2022-06-19 18:12:20 +02:00
Nikita Popov
b0469d127e
Rename Expr\ClosureUse -> ClosureUse
...
This is not a real expression, treat it similarly to Node\Arg
or Node\Param.
The old name is retained as an alias for compatibility.
2022-06-12 21:55:56 +02:00
Nikita Popov
d3d1297c0d
Remove PHP 5 parser
2022-06-12 18:18:50 +02:00
Nikita Popov
bdd131d3ec
Add missing strict_types=1 directive to parser
2022-06-05 22:51:45 +02:00
Nikita Popov
aff98bbf16
Use PHP 8.0 token representation
...
Migrate everything to use PhpToken-compatible token representation,
rather than the legacy array/string representation.
2022-06-05 17:44:42 +02:00
Nikita Popov
9c5eb3ccba
Add some missing type annotations
2022-06-04 12:48:12 +02:00
Tomas Votruba
678ccbe072
[PHP 8.2] Add readonly class support ( #834 )
...
RFC: https://wiki.php.net/rfc/readonly_classes
PHP implementation: php/php-src#7305
2022-05-15 23:19:31 +02:00
Tomas Votruba
5d83adcc0e
[String_] Add rawValue attribute ( #831 )
2022-05-15 23:04:59 +02:00
Tomas Votruba
3bf0082455
[DNumber] Add rawValue attribute to hold the original value ( #833 )
2022-05-15 18:12:28 +02:00
Nikita Popov
4bfc4595ed
Support reserved keywords as enum cases
...
Fixes #807 .
2021-10-17 20:20:35 +02:00
Nikita Popov
08501991d4
Don't make VariadicPlaceholder an expression
...
And don't store it in an Arg.
2021-09-12 21:59:26 +02:00
Nikita Popov
13549aa794
Add support for first-class callables
...
I'm somewhat unsure about the AST structure here.
VariadicPlaceholder is not a general expression. Maybe Arg->expr
should be Expr|VariadicPlaceholder? Or possibly the call arguments
should be an array of Arg|VariadicPlaceholder?
2021-09-03 17:18:40 +02:00
Nikita Popov
ace6c67a8a
Add support for intersection types
2021-09-03 15:06:33 +02:00
Nikita Popov
9aebf377fc
Allow multiple modifiers for property promotion
...
Fixes issue #800 .
2021-08-08 19:12:44 +02:00
Máté Kocsis
55c4269232
Add support for new PHP 8.1 modifiers ( #796 )
...
Implement support for readonly properties (https://wiki.php.net/rfc/readonly_properties_v2 ) and
final class contstants (https://wiki.php.net/rfc/final_class_const ).
2021-07-21 12:43:29 +02:00
Nikita Popov
c758510a37
Add support for PHP 8.1
...
With the introduction of intersection types, PHP now lexes the
token '&' either as T_AMPERSAND_(NOT_)FOLLOWED_BY_VAR_OR_VARARG.
This completely breaks parsing of any code containing '&'.
Fix this by canonicalizing to the new token format (unconditionally,
independent of emulation) and adjusting the parser to use the two
new tokens.
This doesn't add actual support for intersection types yet.
2021-07-09 16:52:58 +02:00
Nikita Popov
e03d63cffb
Fix precedence of arrow functions
...
Arrow functions should have lowest precedence.
Fixes #769 .
2021-04-25 22:19:49 +02:00
Tomas Votruba
f68e1a43ff
[PHP 8.1] Add support for enums ( #758 )
...
RFC: https://wiki.php.net/rfc/enumerations
Co-authored-by: Nikita Popov <nikita.ppv@gmail.com>
2021-04-25 21:11:36 +02:00
Nikita Popov
a8223f228a
Add emulation for enum keyword
2021-03-20 17:49:44 +01:00
Nikita Popov
7284a4d019
Remove no longer necessary class parsing workaround
...
This was split to work around the attribute assignment bug fixed
in the previous commit, and as such is no longer necessary.
2020-12-20 10:53:45 +01:00
Nikita Popov
893a5bce3f
Fix #741 incorrect varvar positions
2020-12-19 22:03:43 +01:00
Nikita Popov
8a97fa157f
Recover from missing semicolon after property or class const
...
Fixes #712 .
2020-09-19 23:11:36 +02:00
Tomas Votruba
4c22c62783
[PHP 8.0] Add attributes support ( #661 )
...
Adds support for PHP 8 attributes, represented using `AttrGroup` nodes
containing `Attribute` nodes. The `attrGroup` subnode is added to all
nodes that can have attributes.
This is still missing FPPP support.
Co-authored-by: Nikita Popov <nikita.ppv@gmail.com>
2020-09-13 21:01:17 +02:00
Nikita Popov
f66a32e2df
Emulate PHP 8 attribute syntax
...
Perform emulation by replacing #[ with %[, then patching % back
to # and coalescing #[ into T_ATTRIBUTE if it is a freestanding
token.
2020-09-06 17:42:38 +02:00
Nikita Popov
78e08fc178
Allow keywords in namespace declaration
2020-08-09 21:19:59 +02:00
Nikita Popov
a98350581c
Add support for throw expression
2020-08-09 20:52:55 +02:00
Nikita Popov
7f398769a0
Add support for static return type
2020-08-09 18:52:32 +02:00
Nikita Popov
98f7f39d1c
Add named argument support
...
Not adding any explicit FPPP support, as I don't think add/remove
of names can be handled any better than full reformatting.
2020-08-09 17:37:44 +02:00
Nikita Popov
23d9c17770
Add support for nullsafe operator
2020-08-09 12:08:05 +02:00
Nikita Popov
31be7b4ed9
Update php-yacc, remove unused tokens
2020-08-08 19:22:28 +02:00
Nikita Popov
a63b495fe6
Migrate grammar to use PHP 8 T_NAME_* tokens
...
This will break everything on PHP < 8.
2020-07-23 12:01:50 +02:00
Nikita Popov
2d1998938c
[PHP 8.0] Support trailing comma in closure use list
...
RFC: https://wiki.php.net/rfc/trailing_comma_in_closure_use_list
2020-07-22 18:43:55 +02:00
Tomas Votruba
69c5d48afd
[PHP 8.0] Add match expressions ( #672 )
...
RFC: https://wiki.php.net/rfc/match_expression_v2
Upstream implementation: php/php-src#5371
Closes #671 .
2020-07-15 21:40:05 +02:00
TomasVotruba
b58b19ed1d
Add constructor promotion support
2020-06-27 17:57:47 +02:00
TomasVotruba
244db65dd1
[PHP 8.0] Add trailing comma in parameter list
2020-06-12 20:24:25 +02:00
TomasVotruba
b5f5313d73
[PHP 8.0] Add exception witout variable
2020-06-03 09:18:13 +02:00
Nikita Popov
d86ca0f745
Support arbitrary expressions in new/instanceof
2020-02-22 21:09:03 +01:00
Nikita Popov
c8d1216531
Treat magic constants like normal constants
2020-02-22 21:06:03 +01:00
Nikita Popov
8999a13cb2
Make class constants fully dereferencable
2020-02-22 21:03:53 +01:00
Nikita Popov
c1eaa0d5cd
Unify array and object dereferencability
2020-02-22 20:57:39 +01:00
Nikita Popov
ca5f7c9761
Split productions, unify {} dereferencing
2020-02-22 20:54:55 +01:00
Nikita Popov
ad696ee75d
Make encapsed strings fully dereferencable
2020-02-22 20:49:11 +01:00
Nikita Popov
568236a305
Allow expressions in list()
...
Similar to the previous commit: list() syntactically accepts any
expression and non-variables are compile-time errors. The special
case of ($a) ends up being legal by accident.
2020-02-19 21:29:17 +01:00
Nikita Popov
9dda080a9d
Allow expressions in isset()
...
Partial fix for #653 . PHP 7 allows expressions inside isset(), but
rejects non-variables in the compiler. A side-effect of this is that
isset(($x)) is allowed, though this is not intentional.
2020-02-19 21:14:33 +01:00
Nikita Popov
46cbd9393a
Place Nop nodes more precisely
...
If the Nop is created to collect comments, place it directly after
the comment, instead of at the next non-whitespace character.
2020-02-09 17:10:33 +01:00
Nikita Popov
664c10121e
Add support for union types
...
We definitely need to introduce a general "Type" abstraction in
the next major version.
2019-11-08 14:45:32 +01:00
Nikita Popov
94d93f27a5
Revert "Recover from error inside alternative array deref syntax"
...
This reverts commit 9d44edf85dc5882e45fed37a6c541bf20e7c8495.
2019-05-24 22:58:13 +02:00