Nikita Popov
03caf4cc99
[8.4] Add support for property hooks
...
Add hooks subnode to Stmt\Property and Param, which contains an
array of PropertyHook.
The property hook support is considered experimental and subject
to change.
RFC: https://wiki.php.net/rfc/property-hooks
2024-07-28 19:02:18 +02:00
Nikita Popov
b4183c2b09
Remove Stmt\Throw
...
This was a backwards-compatibility shim for Expr\Throw.
2023-09-25 18:37:07 +02:00
Nikita Popov
a1ccf57727
Introduce Stmt\Block
...
Stmt\Block will be created for { $a; } style blocks, unless these
occur directly inside some structure that is usually combined
with a block.
For example if ($a) { $b; } will continue to use the old
representation (plain array in in If_::$stmts), but a free-standing
{ $b; } will become a Stmt\Block.
Fixes #590 .
2023-09-24 21:13:01 +02:00
Nikita Popov
ab51e9d35a
Remove superfluous phpdoc tags
...
These just specify a type that is already specified as a real PHP
type.
2023-09-17 18:24:05 +02:00
Nikita Popov
2d3dd4e23e
Don't align phpdoc tags
...
I did this to start with, but then alignment kept being broken
during refactorings, and at some point I switched to not aligning,
and now we have a big mess.
Add a php-cs-fixer rule to consistently not align phpdoc tags.
2023-09-17 16:00:10 +02:00
Markus Staab
263fa80b81
Use more precise Use_::TYPE_* types ( #945 )
...
For better static analysis support in consuming projects.
2023-09-14 10:03:42 +02:00
Nikita Popov
ea77807592
Add more property types
...
Some of these are not maximally accurate due to lack of union
types.
2023-08-17 21:36:07 +02:00
Nikita Popov
502b090900
Add property types
...
Types omitted in two places where we violate them currently:
Namespace_::$stmts can be null during parsing, and Enum_::$scalarType
can be a complex type for invalid programs.
2023-08-16 21:37:02 +02:00
Nikita Popov
c23976a299
Stop accepting strings as types
...
For types the use of a string is ambiguous -- it could be either
an Identifier or a Name. Don't guess.
Retain the implicit promotion to Identifier in places where only
Identifier is legal, e.g. various symbol names.
2023-05-20 22:13:04 +02:00
Nikita Popov
a9dad5c54e
Fix type of ClassConst::$type
2023-05-20 22:01:01 +02:00
Nikita Popov
a5d4c1005c
Remove some unused symbols
2023-05-20 21:40:55 +02:00
Nikita Popov
5c267f55c9
Add support for typed constants
...
RFC: https://wiki.php.net/rfc/typed_class_constants
2023-05-20 21:02:03 +02:00
Markus Staab
8ad4129442
Declare list types ( #907 )
...
Closes #905
2022-12-14 22:59:53 +01:00
Nikita Popov
b3ad14b938
Fix some types
2022-09-17 20:33:04 +02:00
Nikita Popov
f98341f688
Specify more types
2022-09-17 18:48:56 +02:00
Nikita Popov
a099803d01
Use array<string, mixed> type for $attributes
...
Slightly more accurate, and stops PHPStan from complaining about
the missing array type information.
2022-09-11 20:51:31 +02:00
Nikita Popov
031c5e6ed0
Move verifyModifier/verifyClassModifier to Modifiers class
...
Now that the Modifiers are in a separate class, these *internal*
verification methods should also be moved there.
2022-09-11 16:05:21 +02:00
Nikita Popov
b9fe3449e8
Add missing parameter types
2022-09-11 15:22:23 +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
2b562b72a8
Update default of ClassMethod::$flags in docs
...
This defaults to 0, not Modifiers::PUBLIC.
2022-09-03 11:02:16 +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
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
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
MathiasReker
050342b5df
Add visibility modifiers to constants
...
Closes GH-848.
2022-07-23 16:04:21 +02:00
Anton
a3f2bb634d
Add __serialize/__unserialize to ClassMethod::$magicNames
2022-07-23 12:58:49 +02:00
MathiasReker
653757bec6
Nullable type declaration for default null value
...
Adds ? before type declarations for parameters with a default null value
2022-07-04 20:34:31 +02:00
Nikita Popov
9c5eb3ccba
Add some missing type annotations
2022-06-04 12:48:12 +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
Ondrej Mirtes
f4b835f7d8
Fix PHPDoc type of namespacedName properties
2021-12-06 21:33:02 +01: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
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
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
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
a98350581c
Add support for throw expression
2020-08-09 20:52:55 +02:00
TomasVotruba
b5f5313d73
[PHP 8.0] Add exception witout variable
2020-06-03 09:18:13 +02:00
Ruud Kamphuis
64f4d5b619
Add getProperty
to ClassLike
2020-02-09 22:43:42 +01: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
Tomas Votruba
006acba066
add getTraitUses() method to ClassLike
2019-08-31 09:26:51 +02:00
Tomas Votruba
005bb1dba7
add getProperties() and getConstants() to ClassLike
2019-08-30 20:47:14 +02:00
Tyson Andre
a1f72690ef
Fix harmless typos in documentation
2019-07-23 12:32:37 +02:00
Nikita Popov
993f29906b
Avoid parent constructor call during node construction
...
Instead explicitly assign the attributes. This is a minor
performance improvement.
2019-05-12 14:55:21 +02:00
Tomas Votruba
af8c729603
Add PHP 7.4 typed properties support
2019-01-05 21:34:25 +01:00
Tomas Votruba
a74b54ce8b
[cs] remove unused @var name
2018-11-20 20:31:31 +01:00
Gabriel Caruso
7f72c84122
[CS] Open class brackets in new line
2018-01-13 16:03:55 +01:00
Gabriel Caruso
a8968caa5b
[CS] Remove extra lines
2018-01-13 16:03:53 +01:00
Gabriel Caruso
248b29ecf6
Add public visibility to getType method ( #463 )
2018-01-10 18:57:48 +01:00
Gabriel Caruso
e6e8791848
Missing # in method description
2017-12-25 14:28:33 +01:00