Nikita Popov
9b5a2c8991
Use PHPStan level 5
2022-09-11 12:40:08 +02:00
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
a3b0541c71
Support array return from enterNode()
...
This uses the same semantics as arrays from leaveNode(), i.e. the
returned nodes will not be visited by other visitors. This is open
to change though (but probably should change for both enterNode()
and leaveNode() if it does change?)
2022-09-03 18:38:22 +02:00
Nikita Popov
c42290ae42
Support REMOVE_NODE from enterNode()
2022-09-03 18:15:36 +02:00
Nikita Popov
a44faa6328
Rename Scalar\Encapsed to Scalar\InterpolatedString
2022-09-03 15:14:04 +02:00
Nikita Popov
11caa3b9cc
Add compat shim for EncapsedStringPart
2022-09-03 15:08:39 +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
9dca6f1d37
Add test for StaticVar rename
...
Also run these in separate processes, they're not really meaningful
if the classes are already loaded.
2022-09-02 22:54:29 +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
892b07c428
Add some test coverage for Token class
2022-08-29 22:21:50 +02:00
Nikita Popov
a5033e3860
Format tests as well
...
The unnecessary parentheses for "new" are a bit annoying, but I
can live with it...
2022-08-29 21:52:53 +02:00
Nikita Popov
f62b2bfdec
Introduce separate Modifiers class
...
Use PhpParser\Modifiers::PUBLIC instead of
PhpParser\Node\Stmt\Class_::MODIFIER_PUBLIC, etc. Old constants
of course remain available.
Fixes #476 .
2022-08-28 21:20:26 +02:00
Nikita Popov
68fc1ba4cb
Always use List_ node for array destructuring
...
Fixes #471 .
2022-08-28 18:48:26 +02:00
Nikita Popov
53b907d405
Fix length bounds check in Name::slice()
...
The length check did not take into account that there may be a
non-zero offset at this point.
Fixes #875 .
2022-08-28 14:55:57 +02:00
Nikita Popov
1f504d2c7d
Don't trim in Comment::getReformattedText()
...
In the past, single-line comments were stored together with the
trailing newline. Later we switched to the PHP8 comment
representation, where the trailing newline is not part of the
comment anymore. As such, there is also no need to trim here.
This is split out from GH-867.
2022-08-07 16:19:39 +02:00
Nikita Popov
646b490735
Don't force newline after doc string when targeting PHP >= 7.3
2022-07-24 22:15:42 +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
Nikita Popov
1e89658cae
Add PhpVersion class
2022-07-23 17:52:59 +02:00
Nikita Popov
5aae65e627
Add Parser::getLexer() method
...
Not sure if this is going to stick, but for now this makes it
easier to obtain the Lexer instance when creating the parser via
ParserFactory.
2022-06-19 21:05:31 +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
c878d7195d
Move token mapping from lexer to parser
...
This allows a different token mapping per parser.
2022-06-19 18:05:52 +02:00
Nikita Popov
71ed641cd4
Handle true/false/null types in builder APIs
2022-06-19 11:10:43 +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
3fd30f64bc
Remove deprecated param builder method
2022-06-12 21:14:22 +02:00
Nikita Popov
55f29b152c
Improve ParserFactory version targeting
...
Most users will want to pick createForNewestSupportedVersion()
or getForHostVersion(). The currently default is the former,
which can lead to unwanted surprised due to PHP BC breaks for
users that actually want the latter. Make this choice more
explicit.
2022-06-12 18:56:18 +02:00
Nikita Popov
d3d1297c0d
Remove PHP 5 parser
2022-06-12 18:18:50 +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
Dominik Peters
6c0b63d9af
Change print order of modifiers
...
Print abstract/final before visibility modifiers, in line with
PSR-12.
Closes #826 .
2022-06-04 13:19:07 +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
e727475d08
Support readonly as function name
...
This special case was added after the PHP 8.1 release.
2022-05-31 23:18:52 +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
Tomas Votruba
d3eb10aca1
[LNumber] Add rawValue attribute to LNumber to allow numeric separator etc. ( #832 )
2022-05-15 18:09:05 +02:00
Nikita Popov
f09f22760e
Declare namespacedName property
...
For historical reasons, this property is used by the NameResolver
(in default mode). Declare it explicitly, rather than using a doc
comment.
2021-11-27 21:02:58 +01:00
Nikita Popov
d4cb98ae38
Fix typo in property name
...
This test was working on a dynamic "subNode" property, rather
than an actual subnode (either subNode1 or subNode2).
This test is generally not very valuable, I think it dates back
to a time where __get()/__set() were used.
2021-11-27 20:57:41 +01:00
Nikita Popov
68d2a52b42
Avoid creation of dynamic property in test
...
This test requires a property that is not a subnode -- but it does
not need to be dynamic, a declared property works just as well.
2021-11-27 20:53:55 +01:00
Nikita Popov
63f8699143
Add CallLike test for NullsafeMethodCall
2021-11-14 17:44:47 +01:00
Jaroslav Hanslík
99a24b6a55
Added builders for enum and enum case
2021-11-05 22:26:04 +01:00
Jaroslav Hanslík
54f19a0a66
Fixed array value evaluation with unpacked array
2021-10-11 21:35:21 +02:00
Nikita Popov
a45fb2a621
Add CallLike parent class
...
This provides a helper to determine whether a call is a first-class
callable, and a way to strip the args type to Arg[] if it isn't.
2021-09-12 22:29:08 +02:00
Nikita Popov
def24f2224
Add support for explicit octal literals
2021-09-03 16:29:30 +02:00
Nikita Popov
ace6c67a8a
Add support for intersection types
2021-09-03 15:06:33 +02:00
Nikita Popov
0483391aca
Introduce ComplexType base class
...
With the upcoming addition of intersection types, a type can
be Identifier|Name|NullableType|UnionType|IntersectionType, which
is quite the mouthful. Give NullableType and UnionType a common
base class ComplexType, which does not have any behavior, but
allows to write these types (and check them in instanceof) more
easily.
2021-09-02 18:35:05 +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