Skip to content

Commit fd91c16

Browse files
committed
Support readonly properties
1 parent c72a5ea commit fd91c16

File tree

3 files changed

+4
-3
lines changed

3 files changed

+4
-3
lines changed

src/Ast/DtoVisitor.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ private function createDtoType(Class_|Enum_ $node): void
105105
/** @var DtoClassProperty[]|null $classMethodCommentsParsed */
106106
$classMethodCommentsParsed = null;
107107
foreach ($stmt->params as $param) {
108-
if ($param->flags !== Node\Stmt\Class_::MODIFIER_PUBLIC) {
108+
if (!($param->flags & Node\Stmt\Class_::MODIFIER_PUBLIC)) {
109109
continue;
110110
}
111111

tests/ConverterTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ class FullName {
4242
4343
class Profile {
4444
public FullName|null|string $name;
45-
public int $age;
45+
public readonly int $age;
4646
}
4747
CODE;
4848

@@ -131,7 +131,7 @@ class UserCreate {
131131
*/
132132
public function __construct(
133133
public $id,
134-
public $fullName,
134+
public readonly $fullName,
135135
) {
136136
137137
}

tests/__snapshots__/TypeScriptGeneratorTest__testPhp81SuccessWhenBacked__1.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,6 @@ export enum Role {
1414

1515
export type User = {
1616
color: Color;
17+
user: number;
1718
role: Role;
1819
};

0 commit comments

Comments
 (0)