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
b6d11da541
Add space after "use" during empty list insertion as well
2022-06-05 22:59:08 +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
Tomas Votruba
7c445bb608
Remove space before return type in insertionMap ( #841 )
...
* remove space before colon in PrettyPrinterAbstract
* update tests
2022-06-04 23:23:07 +02:00
Nikita Popov
27fe7a68c0
Include space after closure use
2022-06-04 13:22:58 +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
Nikita Popov
4122ff3a91
Make NullsafeMethodCall extend from CallLike
2021-11-14 17:43:29 +01:00
Jaroslav Hanslík
99a24b6a55
Added builders for enum and enum case
2021-11-05 22:26:04 +01:00
Nikita Popov
4bfc4595ed
Support reserved keywords as enum cases
...
Fixes #807 .
2021-10-17 20:20:35 +02: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
08501991d4
Don't make VariadicPlaceholder an expression
...
And don't store it in an Arg.
2021-09-12 21:59:26 +02:00
Shalvah
632ead3a82
Print comma before comments for new array item ( #805 )
...
Print comma before rather than after comments. Also switch to multiline mode if inserting an item with comments.
Fixes #804 .
2021-09-12 21:51:25 +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
def24f2224
Add support for explicit octal literals
2021-09-03 16:29:30 +02:00
Nikita Popov
cfeb195205
Add test for new in initializer
...
This already works because we don't validate initializer contents,
everything is accepted from a parser perspective.
2021-09-03 15:10:29 +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
Nikita Popov
9aebf377fc
Allow multiple modifiers for property promotion
...
Fixes issue #800 .
2021-08-08 19:12:44 +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
Nikita Popov
a8b5ed4306
Fix JSON encoding test on PHP 8.1
...
Duplicate the test expectation for a different order.
2021-07-21 11:49:28 +02:00
Nikita Popov
c758510a37
Add support for PHP 8.1
...
With the introduction of intersection types, PHP now lexes the
token '&' either as T_AMPERSAND_(NOT_)FOLLOWED_BY_VAR_OR_VARARG.
This completely breaks parsing of any code containing '&'.
Fix this by canonicalizing to the new token format (unconditionally,
independent of emulation) and adjusting the parser to use the two
new tokens.
This doesn't add actual support for intersection types yet.
2021-07-09 16:52:58 +02:00
Bob Weinand
3fb73520c1
Add handling for Enum(Case)s in NameResolver
2021-07-03 15:09:11 +02:00
simivar
c35cc4b2cb
Add support for "never" type in the BuilderHelpers::normalizeType()
2021-06-18 17:25:28 +02:00
simivar
0b258d9a9e
Add missing tests for methods of BuilderHelpers
2021-06-17 17:55:59 +02:00
simivar
2d193bb0e4
Add attributes to integration Builder test
2021-06-17 09:18:53 +02:00
Krystian Marcisz
49e9951f2c
Add addAttribute() method to Builders with normalizer ( #782 )
...
Adds addAttribute() method to Builders of all nodes supporting attributes with BuilderHelpers::normalizeAttribute() usage inside so we can pass both Node\Attribute and Node\AttributeGroup instances.
2021-06-16 17:47:22 +02:00
Krystian Marcisz
eccf1bf464
Add Attribute builder and support for named args ( #781 )
...
Add BuilderFactory::attribute() and support named args in BuilderFactory::args().
2021-06-14 23:52:57 +02:00
Nikita Popov
4848a0d734
Check for \r as newline in closing tag
...
Fixes #761 .
2021-04-25 22:42:18 +02:00
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
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
38aa0920c9
Add test for UTF-8 in string
...
These should not get escaped.
2021-03-21 17:03:15 +01:00
Nikita Popov
a8223f228a
Add emulation for enum keyword
2021-03-20 17:49:44 +01:00