Nikita Popov
b493c51cce
[8.4] Add support for asymmetric visibility modifiers
...
Represented using new PRIVATE_SET, PROTECTED_SET and PUBLIC_SET
bits in Modifiers.
RFC: https://wiki.php.net/rfc/asymmetric-visibility-v2
2024-09-05 21:38:16 +02:00
Nikita Popov
514f71024e
Fix for new php-cs-fixer version
2024-08-11 17:03:56 +02:00
Ruud Kamphuis
6a97061265
Normalize enum value to ClassConstFetch
...
Fixes #930
(cherry picked from commit 8a21ec3182533ee6448a4efb8d238a4163b89297)
2024-08-11 16:58:28 +02:00
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
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
5c267f55c9
Add support for typed constants
...
RFC: https://wiki.php.net/rfc/typed_class_constants
2023-05-20 21:02:03 +02:00
Nikita Popov
b68fb76f14
Add makeReadonly() to param builder
...
(cherry picked from commit 11e2dcd96c830ee934fa7b0243f4d67d8a8821ab)
2023-05-19 22:17:50 +02:00
Cees-Jan Kiewiet
36a6dcd04e
[5.x] Add constructor property promotion
...
By making flags on the Param builder configurable by providing make(Public|Protected|Private) methods we can promote parameters to properties from the constructor
2023-03-06 23:12:51 +01:00
Markus Staab
8ad4129442
Declare list types ( #907 )
...
Closes #905
2022-12-14 22:59:53 +01:00
Markus Staab
4c4af21df8
Rewrote overly magic code to make it readable ( #906 )
...
New code inspired by 950bf8f1d1/lib/PhpParser/Builder/Trait_.php (L43)
2022-12-14 22:58:37 +01:00
Nikita Popov
21a3e8cac5
Fix attrGroups/attributes confusion in EnumCase builder
...
Found by staabm in #907 .
2022-12-14 21:50:11 +01:00
Nikita Popov
b3ad14b938
Fix some types
2022-09-17 20:33:04 +02:00
Nikita Popov
c595989e4d
Support adding class constants in trait builder
...
These are allowed as of PHP 8.2.
2022-09-11 19:34:27 +02:00
Nikita Popov
6af204467c
Add some missing property types
2022-09-11 19:30:14 +02:00
Nikita Popov
48f470eac7
Add missing return types
2022-09-11 18:17:05 +02:00
Nikita Popov
b9fe3449e8
Add missing parameter types
2022-09-11 15:22:23 +02:00
Nikita Popov
f59f226f65
Fix some phpstan warnings
2022-09-11 12:16:12 +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
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
Nikita Popov
3fd30f64bc
Remove deprecated param builder method
2022-06-12 21:14:22 +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
Jaroslav Hanslík
99a24b6a55
Added builders for enum and enum case
2021-11-05 22:26:04 +01:00
Jaroslav Hanslík
0a20979a62
Unified builder methods for setting types
2021-09-14 18:09:07 +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
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
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
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
Tomáš Votruba
88f3a669c1
Add union type to ParamBuilder and BuilderHelpers
2020-01-05 00:34:49 +01:00
Nikita Popov
5b1cd2e4f2
Fix phpdoc for Param\Builer::$type
2019-11-02 18:29:08 +01:00
Nikita Popov
1f95f9215c
Tweak type annotation to include null
2019-01-12 17:31:37 +01:00
Tomas Votruba
af8c729603
Add PHP 7.4 typed properties support
2019-01-05 21:34:25 +01:00
Nikita Popov
41408081d7
Rename setTypeHint() to setType()
...
To align with modern terminology -- we don't like calling these
type hints anymore. Old method name remains, marked as @deprecated.
2018-07-22 21:41:21 +02:00
ProgMiner
8d9ae46597
Add Builder\TraitUse::with receiving adaptation builder ability
2018-07-22 21:23:00 +02:00
ProgMiner
f6fc248ca3
Add TraitUseAdaptation and factory for it
2018-07-22 21:23:00 +02:00
ProgMiner
84dcd179d2
Add TraitUse builder and useTrait builder factory
2018-07-22 21:22:57 +02:00
Gabriel Caruso
68d07c4662
[CS] New line in the end of file
2018-01-13 16:08:26 +01:00
Gabriel Caruso
7f72c84122
[CS] Open class brackets in new line
2018-01-13 16:03:55 +01:00
Nikita Popov
5285df8f22
[CS] Use elseif instead of else if
...
Conflicts:
lib/PhpParser/TokenStream.php
2018-01-13 16:03:36 +01:00
Nikita Popov
0bb74e03aa
Drop two more getType() usages in builders
2017-11-13 00:24:01 +01:00
Nikita Popov
fd6e8d7ea8
Merge branch '3.x'
...
Conflicts:
lib/PhpParser/Builder/Namespace_.php
lib/PhpParser/Node/Stmt/ClassMethod.php
test/PhpParser/Builder/NamespaceTest.php
2017-11-04 12:45:04 +01:00
Nikita Popov
0ba710affa
Add setDocComment() to namespace build ( #437 )
2017-11-04 12:43:02 +01:00