File tree Expand file tree Collapse file tree 3 files changed +24
-1
lines changed Expand file tree Collapse file tree 3 files changed +24
-1
lines changed Original file line number Diff line number Diff line change @@ -389,8 +389,9 @@ private function setupFunction($function, Node\FunctionLike $node): void
389
389
$ function ->setReturnType ($ node ->getReturnType () ? $ this ->toPhp ($ node ->getReturnType ()) : null );
390
390
foreach ($ node ->getParams () as $ item ) {
391
391
$ visibility = $ this ->toVisibility ($ item ->flags );
392
+ $ isReadonly = (bool ) ($ item ->flags & Node \Stmt \Class_::MODIFIER_READONLY );
392
393
$ param = $ visibility
393
- ? ($ function ->addPromotedParameter ($ item ->var ->name ))->setVisibility ($ visibility )
394
+ ? ($ function ->addPromotedParameter ($ item ->var ->name ))->setVisibility ($ visibility )-> setReadonly ( $ isReadonly )
394
395
: $ function ->addParameter ($ item ->var ->name );
395
396
$ param ->setType ($ item ->type ? $ this ->toPhp ($ item ->type ) : null );
396
397
$ param ->setReference ($ item ->byRef );
Original file line number Diff line number Diff line change @@ -27,3 +27,14 @@ class Class11
27
27
class Attr
28
28
{
29
29
}
30
+
31
+ class Class12
32
+ {
33
+ private readonly string $bar;
34
+
35
+
36
+ public function __construct(private readonly string $foo)
37
+ {
38
+ $this->bar = "foobar";
39
+ }
40
+ }
Original file line number Diff line number Diff line change @@ -27,3 +27,14 @@ public function bar($c = new \stdClass)
27
27
class Attr
28
28
{
29
29
}
30
+
31
+ class Class12
32
+ {
33
+ private readonly string $ bar ;
34
+
35
+
36
+ public function __construct (private readonly string $ foo )
37
+ {
38
+ $ this ->bar = "foobar " ;
39
+ }
40
+ }
You can’t perform that action at this time.
0 commit comments