Nikita Popov
8eb194ea1f
Add never type
...
This should be recognized as Identifier instead of Name now.
2021-04-25 22:35:28 +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
Nikita Popov
ce91d139b5
Make sure match is one character long
2021-04-25 21:47:07 +02:00
Nikita Popov
33d7c8d3d8
Escape invalid UTF-8 in strings
...
To be friendlier to tooling that expects PHP files to be UTF-8
encoded, escape any sequences that are not legal under UTF-8.
2021-04-25 21:37:01 +02:00
Nikita Popov
6b409b96bb
Use hex escaping for special characters in strings
...
Apart from \0, using the \xHH notation is more typical.
2021-04-25 21:22:15 +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
Iskander (Alex) Sharipov
f767b9fd9f
ParserAbstract: add missing '*' to the phpdoc
...
Otherwise, it's somewhat incompatible with the phpdoc definition.
2021-04-25 12:38:52 +02:00
WhizSid
d46f261ef9
Adding class constant to builder factory ( #765 )
...
* Adding class constant to builder factory
* Fix formatting,doc issues and Tweak returning node from ClassConst
* Fix PHPUnit
2021-03-21 20:58:21 +01:00
Nikita Popov
a8223f228a
Add emulation for enum keyword
2021-03-20 17:49:44 +01:00
Oskar Stark
8165cf69fa
CS fix
2021-02-02 09:57:47 +01:00
Tomas Votruba
46221a0914
Update Use_ builder to return specific type
2021-01-06 14:30:19 +01:00
Tomas Votruba
3b87eb721c
make Namespace_ builder return Namespace_
...
Hi, just a little detail. This should fix invalid return type of docs
2020-12-30 10:13:54 +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
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
Stefano Arlandini
bc7a9bf9c2
Remove useless code left from old implementation
2020-12-02 12:54:15 +01:00
Anders Jürisoo
1d1bc8a364
Upgrade some PrettyPrinter methods to protected
...
I noticed some methods in the Standard PrettyPrinter is private, can they be upgraded to `protected` to ease when extending it?
2020-10-17 22:04:40 +02: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
b9b65a2996
Fix check for token emulation conflicts
2020-09-26 12:29:16 +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
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
75abbbd2d4
Handle flexible heredoc via TokenEmulator
...
Extend the interface to support preprocessing.
2020-09-06 17:05:23 +02:00
Nikita Popov
39b046007d
Refactor token emulator registration
...
Only determine needed emulators based on PHP version once, and
add an adaptor that allows treating forward and reverse emulation
the same.
Previously the isEmulationNeeded() check was too conservative,
as it also considered emulators that are not relevant for the
version. Though possibly that check should just be dropped
altogether.
2020-09-06 15:50:52 +02:00
Nikita Popov
e3872b8906
Improve compatibility with other libs defining compat tokens
2020-09-06 15:00:28 +02:00
Ondřej Mirtes
4a40a84cf6
Fixed PHPDoc typo
2020-09-02 12:33:46 +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
Nikita Popov
4bc82432de
Only special-case brace handling for statement lists
...
Don't interpret the } before a catch clause as a block statement
and trigger a pretty printing fallback.
2020-08-23 20:57:00 +02:00
Nikita Popov
bd722809f7
FPPP: Support removing nodes from start of list
2020-08-23 17:35:37 +02:00
Viktor Szépe
56356e4aec
Remove repeated word from PHPDoc in Name
2020-08-23 08:59:38 +02:00
Nikita Popov
f9d35fe11e
Fix casing of class name
2020-08-10 11:21:16 +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
31be7b4ed9
Update php-yacc, remove unused tokens
2020-08-08 19:22:28 +02:00
Alex
54fc023b25
Update Array_ annotations, items are nullable ( #696 )
...
When used to destructure, items are optional. E.g. `[$a, , $b] = [1, 2, 3];`.
2020-08-08 10:04:21 +02:00
Nikita Popov
303342630d
Fix a token reference
2020-08-01 22:36:49 +02:00
Nikita Popov
1a1300aa2a
Add reverse emulation support
2020-08-01 22:34:36 +02:00