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
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
d3d1297c0d
Remove PHP 5 parser
2022-06-12 18:18:50 +02:00
4122ff3a91
Make NullsafeMethodCall extend from CallLike
2021-11-14 17:43:29 +01:00
08501991d4
Don't make VariadicPlaceholder an expression
...
And don't store it in an Arg.
2021-09-12 21:59:26 +02:00
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
e03d63cffb
Fix precedence of arrow functions
...
Arrow functions should have lowest precedence.
Fixes #769 .
2021-04-25 22:19:49 +02:00
893a5bce3f
Fix #741 incorrect varvar positions
2020-12-19 22:03:43 +01:00
8505acd151
Correctly handle ?-> in encapsed strings
...
Followup upstream change.
2020-09-19 15:47:14 +02:00
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
35306de32f
Support visibility modifiers in namespaced names
...
Fixes #704 .
2020-08-29 16:35:31 +02:00
0cee2088ea
Remove self/parent/static restriction for namespace names
...
This no longer applies as of PHP 8.0.
2020-08-09 21:21:22 +02:00
78e08fc178
Allow keywords in namespace declaration
2020-08-09 21:19:59 +02:00
3aadc15e2e
Support keywords in namespaced names
2020-08-09 21:11:49 +02:00
a98350581c
Add support for throw expression
2020-08-09 20:52:55 +02:00
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
23d9c17770
Add support for nullsafe operator
2020-08-09 12:08:05 +02:00
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
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
b58b19ed1d
Add constructor promotion support
2020-06-27 17:57:47 +02:00
d86ca0f745
Support arbitrary expressions in new/instanceof
2020-02-22 21:09:03 +01:00
c8d1216531
Treat magic constants like normal constants
2020-02-22 21:06:03 +01:00
8999a13cb2
Make class constants fully dereferencable
2020-02-22 21:03:53 +01:00
c1eaa0d5cd
Unify array and object dereferencability
2020-02-22 20:57:39 +01:00
ca5f7c9761
Split productions, unify {} dereferencing
2020-02-22 20:54:55 +01:00
ad696ee75d
Make encapsed strings fully dereferencable
2020-02-22 20:49:11 +01:00
6770deda3d
Check that ::class on object works
2020-02-22 20:42:11 +01:00
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
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
8012faea54
[PHP 7.4] Add array spread
2019-05-09 19:15:35 +02:00
f3b19c19ef
[PHP 7.4] Add support for arrow functions ( #602 )
...
Per RFC https://wiki.php.net/rfc/arrow_functions_v2 .
2019-05-09 14:17:28 +02:00
9de96821f7
Add support for ??= operator
...
Introduced in PHP 5.4, represented using an AssignOp\Coalesce node.
2019-02-09 11:16:26 +01:00
7f8ff1b9a4
Add support for list reference assignments
...
RFC: https://wiki.php.net/rfc/list_reference_assignment
2018-03-10 16:48:20 +01:00
91a462ce76
PHP 7.3: Add support for trailing commas in calls
...
RFC: https://wiki.php.net/rfc/trailing-comma-function-calls
2018-03-10 16:41:20 +01:00
4392a7b164
Fix PHP5 static call fixup
...
Variable nodes directly store the variable name as a string, they
don't use VarLikeIdentifier. So remove this wrapper if it exists.
2017-11-11 12:23:14 +01:00
a6846e3b71
Always use Identifier nodes
...
The parser will now always generate Identifier nodes (for
non-namespaced identifiers). This obsoletes the useIdentifierNodes
parser option.
Node constructors still accepts strings and will implicitly create
an Identifier wrapper. Identifier implement __toString(), so that
outside of strict-mode many things continue to work without changes.
2017-04-28 20:57:32 +02:00
b5935a4aff
Fix a typo in NodeDumper for REQUIRE_ONCE ( #367 )
2017-03-17 11:35:48 +01:00
9f5ec5a69a
Merge branch '3.x'
...
Conflicts:
lib/PhpParser/Parser/Php5.php
lib/PhpParser/Parser/Php7.php
test/code/parser/stmt/class/name.test
2017-02-09 20:38:33 +01:00
a8eb2fc675
Support recovery from invalid trailing commas
2017-02-09 00:35:12 +01:00
865bfb2acf
Merge branch '3.x'
...
Conflicts:
grammar/php7.y
lib/PhpParser/Parser/Php7.php
test/code/parser/expr/uvs/globalNonSimpleVarError.test
test/code/parser/stmt/namespace/groupUseErrors.test
2017-02-05 17:50:54 +01:00
62877b5d14
Recover from missing semicolons on statements
2017-02-05 17:47:56 +01:00
d7f3c4f9d3
Renamve Param::$name to Param::$var
...
As it now contains a Variable node.
2017-01-19 23:39:15 +01:00
67274b9594
Enforce useConsistentVariableNames
2017-01-19 23:24:43 +01:00
953f8c9631
Perform automated test update
2017-01-19 22:25:22 +01:00
3e158a2313
Wrap List_ in ArrayItem
...
This was correctly done for the 'key'=>list() form, but not for
unkeyed nested lists.
2016-12-01 13:32:37 +01:00
c0630f8169
Support recovery for new without class name
2016-11-21 16:51:53 +01:00
d0cfb98133
Merge branch '2.x'
...
Conflicts:
lib/PhpParser/Parser/Php7.php
2016-08-30 22:14:09 +02:00
13f7321def
Forbid "=& new" in PHP 7 mode
2016-08-30 22:12:01 +02:00
1dea9111a2
NodeDumper: Resolve type for include/use as well
2016-07-25 14:04:04 +02:00
574665b45b
PHP 7.1: list() with keys
...
Expr\List will now contain ArrayItems instead of plain variables.
I'm reusing ArrayItem, because code handling list() must also handle
arrays, and this allows both to go through the same code path.
This also renames Expr\List->vars to ->items.
TODO: Should Expr\List be dropped in favor of Expr\Array with an
extra flag?
2016-07-09 21:55:55 +02:00