@@ -196,8 +196,8 @@ private function getDocBlock(string $class, string $property): array
196
196
197
197
$ ucFirstProperty = ucfirst ($ property );
198
198
199
- if ([$ docBlock , $ declaringClass ] = $ this ->getDocBlockFromProperty ($ class , $ property )) {
200
- $ data = [$ docBlock , self :: PROPERTY , null , $ declaringClass ];
199
+ if ([$ docBlock , $ source , $ declaringClass ] = $ this ->getDocBlockFromProperty ($ class , $ property )) {
200
+ $ data = [$ docBlock , $ source , null , $ declaringClass ];
201
201
} elseif ([$ docBlock , $ _ , $ declaringClass ] = $ this ->getDocBlockFromMethod ($ class , $ ucFirstProperty , self ::ACCESSOR )) {
202
202
$ data = [$ docBlock , self ::ACCESSOR , null , $ declaringClass ];
203
203
} elseif ([$ docBlock , $ prefix , $ declaringClass ] = $ this ->getDocBlockFromMethod ($ class , $ ucFirstProperty , self ::MUTATOR )) {
@@ -210,7 +210,7 @@ private function getDocBlock(string $class, string $property): array
210
210
}
211
211
212
212
/**
213
- * @return array{PhpDocNode, string}|null
213
+ * @return array{PhpDocNode, int, string}|null
214
214
*/
215
215
private function getDocBlockFromProperty (string $ class , string $ property ): ?array
216
216
{
@@ -221,15 +221,21 @@ private function getDocBlockFromProperty(string $class, string $property): ?arra
221
221
return null ;
222
222
}
223
223
224
- if (null === $ rawDocNode = $ reflectionProperty ->getDocComment () ?: null ) {
224
+ $ source = self ::PROPERTY ;
225
+
226
+ if ($ reflectionProperty ->isPromoted ()) {
227
+ $ constructor = new \ReflectionMethod ($ class , '__construct ' );
228
+ $ rawDocNode = $ constructor ->getDocComment ();
229
+ $ source = self ::MUTATOR ;
230
+ } elseif (null === $ rawDocNode = $ reflectionProperty ->getDocComment () ?: null ) {
225
231
return null ;
226
232
}
227
233
228
234
$ tokens = new TokenIterator ($ this ->lexer ->tokenize ($ rawDocNode ));
229
235
$ phpDocNode = $ this ->phpDocParser ->parse ($ tokens );
230
236
$ tokens ->consumeTokenType (Lexer::TOKEN_END );
231
237
232
- return [$ phpDocNode , $ reflectionProperty ->class ];
238
+ return [$ phpDocNode , $ source , $ reflectionProperty ->class ];
233
239
}
234
240
235
241
/**
0 commit comments