@@ -196,8 +196,8 @@ private function getDocBlock(string $class, string $property): array
196196
197197 $ ucFirstProperty = ucfirst ($ property );
198198
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 ];
201201 } elseif ([$ docBlock , $ _ , $ declaringClass ] = $ this ->getDocBlockFromMethod ($ class , $ ucFirstProperty , self ::ACCESSOR )) {
202202 $ data = [$ docBlock , self ::ACCESSOR , null , $ declaringClass ];
203203 } elseif ([$ docBlock , $ prefix , $ declaringClass ] = $ this ->getDocBlockFromMethod ($ class , $ ucFirstProperty , self ::MUTATOR )) {
@@ -210,7 +210,7 @@ private function getDocBlock(string $class, string $property): array
210210 }
211211
212212 /**
213- * @return array{PhpDocNode, string}|null
213+ * @return array{PhpDocNode, int, string}|null
214214 */
215215 private function getDocBlockFromProperty (string $ class , string $ property ): ?array
216216 {
@@ -221,15 +221,21 @@ private function getDocBlockFromProperty(string $class, string $property): ?arra
221221 return null ;
222222 }
223223
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 ) {
225231 return null ;
226232 }
227233
228234 $ tokens = new TokenIterator ($ this ->lexer ->tokenize ($ rawDocNode ));
229235 $ phpDocNode = $ this ->phpDocParser ->parse ($ tokens );
230236 $ tokens ->consumeTokenType (Lexer::TOKEN_END );
231237
232- return [$ phpDocNode , $ reflectionProperty ->class ];
238+ return [$ phpDocNode , $ source , $ reflectionProperty ->class ];
233239 }
234240
235241 /**
0 commit comments