Nikita Popov
4917c71a91
Rename Stmt\UseUse to UseItem
2022-09-03 18:59:48 +02:00
Nikita Popov
e1345f0c09
Rename Stmt\PropertyProperty to PropertyItem
2022-09-03 18:55:22 +02:00
Nikita Popov
03ccfa3dd4
Rename Stmt\DeclareDeclare to DeclareItem
2022-09-03 18:45:28 +02:00
Nikita Popov
a44faa6328
Rename Scalar\Encapsed to Scalar\InterpolatedString
2022-09-03 15:14:04 +02:00
Nikita Popov
f4ec6a1e53
Rename Scalar\EncapsedStringPart to InterpolatedStringPart
...
It is no longer an expression node, which unfortunately does
require a more awkward type for the Encaps node.
2022-09-03 13:25:23 +02:00
Nikita Popov
23835d20ef
Rename Scalar\LNumber to Scalar\Int_
2022-09-03 12:07:38 +02:00
Nikita Popov
66b20bd6bc
Rename Scalar\DNumber to Scalar\Float_
2022-09-03 11:56:06 +02:00
Nikita Popov
035c1c7cd2
Rename Stmt\StaticVar to StaticVar
...
This is part of a statement, not a statement by itself.
2022-09-02 22:51:13 +02:00
Nikita Popov
8be56afd2d
Rename Expr\ArrayItem to ArrayItem
...
Array items are not expressions by themselves.
2022-09-02 22:41:10 +02:00
Nikita Popov
dd63ddbc24
Add php-cs-fixer config and reformat
...
The formatting in this project has become something of a mess,
because it changed over time. Add a CS fixer config and reformat
to the desired style, which is PSR-12, but with sane brace placement.
2022-08-28 22:57:06 +02:00
Nikita Popov
68fc1ba4cb
Always use List_ node for array destructuring
...
Fixes #471 .
2022-08-28 18:48:26 +02:00
George Peter Banyard
9b2a01aa0c
Add support for DNF types ( #862 )
2022-08-07 17:10:11 +02:00
Nikita Popov
652fb0c6c1
Print trailing comma in param list if supported
2022-08-07 16:43:53 +02:00
Anton
ea9d6b2238
Always use pMaybeMultiline() for function parameters
...
Closes GH-861.
2022-08-07 16:34:26 +02:00
Nikita Popov
cf0cd6003e
Improve heuristic for escaping in single quoted strings
...
It is idiomatic to not escape backslashes if they are followed by
a non-special character.
2022-07-24 22:56:44 +02:00
Nikita Popov
59145a4443
Treat assignments as unary operators
...
Assignment expressions can be viewed as unary operators where
the whole "$x =" part is the operator.
2022-07-23 21:53:48 +02:00
Nikita Popov
7bf6348240
Remove inc/dec from precedence map
...
Inc/dec are primitive expressions that only accept a variable
operand, rather than a general expression operand.
2022-07-23 21:48:10 +02:00
Nikita Popov
a73c8ee03b
Add a phpVersion option to the pretty printer
...
This is currently just used to initialize the default for short
array syntax.
The default target version in 7.0, which also means that the
default for short arrays is flipped to on.
2022-07-23 18:23:39 +02:00
MathiasReker
4021a63cef
No superfluous elseif
...
Replaces superfluous elseif with if.
2022-07-04 20:36:22 +02:00
MathiasReker
0086a261d0
Short scalar cast
...
Cast (boolean) and (integer) should be written as (bool) and (int), (double) and (real) as (float), (binary) as (string).
2022-07-04 17:50:40 +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
27fe7a68c0
Include space after closure use
2022-06-04 13:22:58 +02:00
Nikita Popov
87387caf8f
Remove space before return type in pretty printer
2022-06-04 13:01:02 +02:00
Nikita Popov
9c5eb3ccba
Add some missing type annotations
2022-06-04 12:48:12 +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
Bob Weinand
3fb73520c1
Add handling for Enum(Case)s in NameResolver
2021-07-03 15:09:11 +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
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
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
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
a98350581c
Add support for throw expression
2020-08-09 20:52:55 +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
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
b5f5313d73
[PHP 8.0] Add exception witout variable
2020-06-03 09:18:13 +02: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
Tyson Andre
2e2954ccdf
Avoid notices in php 7.4 with hexdec/base_convert ( #619 )
...
This is made to avoid notices caused by
https://wiki.php.net/rfc/base_convert_improvements
(seen with `php -d error_reporting=E_ALL vendor/bin/phpunit`)
2019-07-14 10:56:13 +02:00
Tomas Votruba
8012faea54
[PHP 7.4] Add array spread
2019-05-09 19:15:35 +02:00
Tomáš Votruba
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
Tomas Votruba
9de96821f7
Add support for ??= operator
...
Introduced in PHP 5.4, represented using an AssignOp\Coalesce node.
2019-02-09 11:16:26 +01:00
Tomas Votruba
af8c729603
Add PHP 7.4 typed properties support
2019-01-05 21:34:25 +01:00
Tomas Votruba
0ef61b49bb
add float/double/real KIND support to Cast\Double node
2019-01-05 19:23:00 +01:00