1
0
mirror of https://github.com/danog/PHP-Parser.git synced 2024-11-26 11:54:52 +01:00
Commit Graph

592 Commits

Author SHA1 Message Date
f00092bfee
Update tests 2021-01-09 18:38:34 +01:00
Nikita Popov
d3d1ee470a Fix #738 incorrect start line for traits
Empty productions are supposed to be assigned the start attributes
of the lookahead token. Currently, this happens by assigning above
the current stack position when the token it read.

This fails in a situation where we first reduce an empty production
higher up in the stack, and then again reduce an empty production
lower in the stack, without consuming the lookahead token in the
meantime.

Fix this by moving the assignment into the reduction phase. We
also need to do this for error productions, which are effectively
empty.
2020-12-20 10:52:47 +01:00
Nikita Popov
893a5bce3f Fix #741 incorrect varvar positions 2020-12-19 22:03:43 +01:00
Tommy Quissens
c64986fa55
Allow both '{' and T_CURLY_OPEN as curly bracket (#732) 2020-12-03 18:42:00 +01:00
Nikita Popov
eff72eeffa Fix #718: PrettyPrinter breaks nested ternaries
Mark ternary as non-associative operator, as left-associative use
is deprecated in PHP 7.4 and removed in PHP 8.0.
2020-09-30 20:42:58 +02:00
Nikita Popov
b5351f883a Make keyword emulation check case-insensitive 2020-09-23 20:19:40 +02:00
Nikita Popov
88be6127fa FPPP: Fix remove + add at start of list 2020-09-22 22:41:02 +02:00
Nikita Popov
8a97fa157f Recover from missing semicolon after property or class const
Fixes #712.
2020-09-19 23:11:36 +02:00
Nikita Popov
c7dc3ce552 Add basic FPPP support for attributes 2020-09-19 16:43:45 +02:00
Nikita Popov
1899471f80 Update test for PHP 8 error behavior
Replace division by zero with a different error condition that
still warns, and adjust the expected message based on PHP version.
2020-09-19 15:52:05 +02:00
Nikita Popov
8505acd151 Correctly handle ?-> in encapsed strings
Followup upstream change.
2020-09-19 15:47:14 +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
35306de32f Support visibility modifiers in namespaced names
Fixes #704.
2020-08-29 16:35:31 +02:00
Nikita Popov
ad365b1beb FPPP: Fix code block detection during removal
Instead of checking whether there is a {/} before/after the removed
note, check whether {/} occurs in the between-node range. Dropping
that is what we're really concerned about here.
2020-08-29 16:28:28 +02:00
Ondrej Mirtes
fd6052e37d FPPP failing tests 2020-08-23 20:54:01 +02:00
Nikita Popov
bd722809f7 FPPP: Support removing nodes from start of list 2020-08-23 17:35:37 +02:00
Nikita Popov
8bcaa4261e Add parens for new/instanceof with complex expression
This is not fully accurate because the rules for "new variables"
are different than the rules for dereferenceable LHS.
2020-08-09 22:07:33 +02:00
Nikita Popov
feb6bf7a0c Wrap class const LHS in parens if necessary
This looks like a very old bug in the pretty printer that showed
up in PHP 8 tests.
2020-08-09 21:41:30 +02:00
Nikita Popov
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
Nikita Popov
78e08fc178 Allow keywords in namespace declaration 2020-08-09 21:19:59 +02:00
Nikita Popov
3aadc15e2e Support keywords in namespaced names 2020-08-09 21:11:49 +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
f6bf041583 Remove last uses of MockBuilder 2020-08-08 11:58:00 +02:00
Nikita Popov
1bf073a76c Avoid most MockBuilder uses in NodeVisitor testing
This removes all the warnings about at() usage ... even though
it is still used. Apparently warnings don't get emitted if the
at() usage is inside a data provider?
2020-08-08 11:49:05 +02:00
Nikita Popov
1721ae155c Avoid one use of MockBuilder
We can just use anon classes here and avoid PHPUnits unreliable
MockBuilder.
2020-08-08 11:49:05 +02:00
Nikita Popov
f845568e1d Remove an unnecessary use of at() 2020-08-07 10:19:39 +02:00
Nikita Popov
1a1300aa2a Add reverse emulation support 2020-08-01 22:34:36 +02:00
Nikita Popov
acaf3fecad Implement emulation of PHP 8 T_NAME_* tokens
Like comment emulation, this is unconditional, as it is required
for core functionality.
2020-07-23 12:28:13 +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
Nikita Popov
739b4b4c60 Fix handling of unterminated comment with trailing newline
Fixes #688.
2020-07-22 18:35:55 +02:00
Nikita Popov
17f478107a Fix file name 2020-07-22 18:30:00 +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
Sebastian Bergmann
f545f18a87
Add ParentConnectingVisitor and NodeConnectingVisitor (#681) 2020-07-11 11:31:43 +02:00
Nikita Popov
4abc531213 Canonicalize to PHP 8 comment token format
The trailing newline is no longer part of the comment token.
2020-06-27 18:53:09 +02:00
TomasVotruba
b58b19ed1d Add constructor promotion support 2020-06-27 17:57:47 +02:00
Nikita Popov
0d2d8f95a1 FPPP: Support catch without variable 2020-06-27 17:42:46 +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
Máté Kocsis
32f89662f3 Add support for the mixed type 2020-05-28 23:39:04 +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