@@ -2373,7 +2373,7 @@ function parseFunctionLike(
2373
2373
function parseProperty (
2374
2374
Name $ class ,
2375
2375
int $ flags ,
2376
- Stmt \PropertyProperty $ property ,
2376
+ Stmt \PropertyProperty | Node \ Param $ property ,
2377
2377
?Node $ type ,
2378
2378
?DocComment $ comment ,
2379
2379
PrettyPrinterAbstract $ prettyPrinter
@@ -2411,13 +2411,23 @@ function parseProperty(
2411
2411
}
2412
2412
}
2413
2413
2414
+ $ default = $ property ->default ;
2415
+ if ($ property instanceof Node \Param) {
2416
+ $ name = $ property ->var ->name ;
2417
+ if ($ property ->flags & Stmt \Class_::MODIFIER_READONLY ) {
2418
+ $ default = null ;
2419
+ }
2420
+ } else {
2421
+ $ name = $ property ->name ;
2422
+ }
2423
+
2414
2424
return new PropertyInfo (
2415
- new PropertyName ($ class , $ property -> name -> __toString () ),
2425
+ new PropertyName ($ class , ( string ) $ name ),
2416
2426
$ flags ,
2417
2427
$ propertyType ,
2418
2428
$ phpDocType ? Type::fromString ($ phpDocType ) : null ,
2419
- $ property -> default ,
2420
- $ property -> default ? $ prettyPrinter ->prettyPrintExpr ($ property -> default ) : null ,
2429
+ $ default ,
2430
+ $ default ? $ prettyPrinter ->prettyPrintExpr ($ default ) : null ,
2421
2431
$ isDocReadonly ,
2422
2432
$ link
2423
2433
);
@@ -2602,6 +2612,20 @@ function handleStatements(FileInfo $fileInfo, array $stmts, PrettyPrinterAbstrac
2602
2612
$ classStmt ,
2603
2613
$ cond
2604
2614
);
2615
+ if ($ classStmt ->name ->toString () === "__construct " ) {
2616
+ foreach ($ classStmt ->params as $ param ) {
2617
+ if ($ param ->flags ) {
2618
+ $ propertyInfos [] = parseProperty (
2619
+ $ className ,
2620
+ $ param ->flags ,
2621
+ $ param ,
2622
+ $ param ->type ,
2623
+ $ param ->getDocComment (),
2624
+ $ prettyPrinter
2625
+ );
2626
+ }
2627
+ }
2628
+ }
2605
2629
} else if ($ classStmt instanceof Stmt \EnumCase) {
2606
2630
$ enumCaseInfos [] = new EnumCaseInfo (
2607
2631
$ classStmt ->name ->toString (), $ classStmt ->expr );
0 commit comments