1111class PHPClass extends BasePHPClass
1212{
1313 /**
14- * @var string
14+ * @var string|null
1515 *
16- * @psalm-var class-string
16+ * @psalm-var null| class-string
1717 */
1818 public $ name ;
1919
@@ -130,6 +130,17 @@ public function readObjectFromBetterReflection($clazz): self
130130 $ parent = $ clazz ->getParentClass ();
131131 if ($ parent ) {
132132 $ this ->parentClass = $ parent ->getName ();
133+
134+ /** @noinspection ArgumentEqualsDefaultValueInspection */
135+ if (
136+ !$ this ->parserContainer ->getClass ($ this ->parentClass )
137+ &&
138+ \class_exists ($ this ->parentClass , true )
139+ ) {
140+ $ reflectionClass = ReflectionClass::createFromName ($ this ->parentClass );
141+ $ class = (new self ($ this ->parserContainer ))->readObjectFromBetterReflection ($ reflectionClass );
142+ $ this ->parserContainer ->addClass ($ class );
143+ }
133144 }
134145
135146 foreach ($ clazz ->getProperties () as $ property ) {
@@ -173,7 +184,7 @@ public function readObjectFromBetterReflection($clazz): self
173184 *
174185 * @return array
175186 *
176- * @psalm-return array<string, array{type: null|string, typeMaybeWithComment : null|string, typeFromPhpDoc: null|string, typeFromPhpDocSimple: null|string, typeFromPhpDocPslam: null|string, typeFromDefaultValue: null|string}>
187+ * @psalm-return array<string, array{type: null|string, typeFromPhpDocMaybeWithComment : null|string, typeFromPhpDoc: null|string, typeFromPhpDocSimple: null|string, typeFromPhpDocPslam: null|string, typeFromDefaultValue: null|string}>
177188 */
178189 public function getPropertiesInfo (
179190 array $ access = ['public ' , 'protected ' , 'private ' ],
@@ -193,7 +204,7 @@ public function getPropertiesInfo(
193204
194205 $ types = [];
195206 $ types ['type ' ] = $ property ->type ;
196- $ types ['typeMaybeWithComment ' ] = $ property ->typeMaybeWithComment ;
207+ $ types ['typeFromPhpDocMaybeWithComment ' ] = $ property ->typeFromPhpDocMaybeWithComment ;
197208 $ types ['typeFromPhpDoc ' ] = $ property ->typeFromPhpDoc ;
198209 $ types ['typeFromPhpDocSimple ' ] = $ property ->typeFromPhpDocSimple ;
199210 $ types ['typeFromPhpDocPslam ' ] = $ property ->typeFromPhpDocPslam ;
@@ -212,9 +223,7 @@ public function getPropertiesInfo(
212223 *
213224 * @return array<mixed>
214225 *
215- * @psalm-return array<string, array{fullDescription: string, line: null|int, file: null|string, error: string, is_deprecated: bool, is_static: bool, is_meta: bool, is_internal: bool, is_removed: bool, paramsTypes: array<string, array{type: null|string, typeFromPhpDoc: null|string, typeFromPhpDocPslam: null|string, typeFromPhpDocSimple: null|string, typeMaybeWithComment: null|string, typeFromDefaultValue: null|string}>, returnTypes: array{type: null|string, typeFromPhpDoc: null|string, typeFromPhpDocPslam: null|string, typeFromPhpDocSimple: null|string, typeMaybeWithComment: null|string}}>
216- *
217- * @psalm-suppress MoreSpecificReturnType or Less ?
226+ * @psalm-return array<string, array{fullDescription: string, line: null|int, file: null|string, error: string, is_deprecated: bool, is_static: null|bool, is_meta: bool, is_internal: bool, is_removed: bool, paramsTypes: array<string, array{type: null|string, typeFromPhpDoc: null|string, typeFromPhpDocPslam: null|string, typeFromPhpDocSimple: null|string, typeFromPhpDocMaybeWithComment: null|string, typeFromDefaultValue: null|string}>, returnTypes: array{type: null|string, typeFromPhpDoc: null|string, typeFromPhpDocPslam: null|string, typeFromPhpDocSimple: null|string, typeFromPhpDocMaybeWithComment: null|string}}>
218227 */
219228 public function getMethodsInfo (
220229 array $ access = ['public ' , 'protected ' , 'private ' ],
@@ -240,7 +249,7 @@ public function getMethodsInfo(
240249 $ paramsTypes = [];
241250 foreach ($ method ->parameters as $ tagParam ) {
242251 $ paramsTypes [$ tagParam ->name ]['type ' ] = $ tagParam ->type ;
243- $ paramsTypes [$ tagParam ->name ]['typeMaybeWithComment ' ] = $ tagParam ->typeMaybeWithComment ;
252+ $ paramsTypes [$ tagParam ->name ]['typeFromPhpDocMaybeWithComment ' ] = $ tagParam ->typeFromPhpDocMaybeWithComment ;
244253 $ paramsTypes [$ tagParam ->name ]['typeFromPhpDoc ' ] = $ tagParam ->typeFromPhpDoc ;
245254 $ paramsTypes [$ tagParam ->name ]['typeFromPhpDocSimple ' ] = $ tagParam ->typeFromPhpDocSimple ;
246255 $ paramsTypes [$ tagParam ->name ]['typeFromPhpDocPslam ' ] = $ tagParam ->typeFromPhpDocPslam ;
@@ -249,7 +258,7 @@ public function getMethodsInfo(
249258
250259 $ returnTypes = [];
251260 $ returnTypes ['type ' ] = $ method ->returnType ;
252- $ returnTypes ['typeMaybeWithComment ' ] = $ method ->returnTypeMaybeWithComment ;
261+ $ returnTypes ['typeFromPhpDocMaybeWithComment ' ] = $ method ->returnTypeFromPhpDocMaybeWithComment ;
253262 $ returnTypes ['typeFromPhpDoc ' ] = $ method ->returnTypeFromPhpDoc ;
254263 $ returnTypes ['typeFromPhpDocSimple ' ] = $ method ->returnTypeFromPhpDocSimple ;
255264 $ returnTypes ['typeFromPhpDocPslam ' ] = $ method ->returnTypeFromPhpDocPslam ;
@@ -275,7 +284,6 @@ public function getMethodsInfo(
275284
276285 \asort ($ allInfo );
277286
278- /** @psalm-suppress LessSpecificReturnStatement ? */
279287 return $ allInfo ;
280288 }
281289
@@ -322,13 +330,13 @@ private function readPhpDocProperties(string $docComment): void
322330
323331 $ propertyPhp ->typeFromPhpDoc = Utils::normalizePhpType ($ type . '' );
324332
325- $ typeMaybeWithCommentTmp = \trim ((string ) $ parsedPropertyTag );
333+ $ typeFromPhpDocMaybeWithCommentTmp = \trim ((string ) $ parsedPropertyTag );
326334 if (
327- $ typeMaybeWithCommentTmp
335+ $ typeFromPhpDocMaybeWithCommentTmp
328336 &&
329- \strpos ($ typeMaybeWithCommentTmp , '$ ' ) !== 0
337+ \strpos ($ typeFromPhpDocMaybeWithCommentTmp , '$ ' ) !== 0
330338 ) {
331- $ propertyPhp ->typeMaybeWithComment = $ typeMaybeWithCommentTmp ;
339+ $ propertyPhp ->typeFromPhpDocMaybeWithComment = $ typeFromPhpDocMaybeWithCommentTmp ;
332340 }
333341
334342 $ typeTmp = Utils::parseDocTypeObject ($ type );
@@ -346,7 +354,7 @@ private function readPhpDocProperties(string $docComment): void
346354 }
347355 }
348356 } catch (\Exception $ e ) {
349- $ tmpErrorMessage = $ this ->name . ': ' . ($ this ->line ?? '' ) . ' | ' . \print_r ($ e ->getMessage (), true );
357+ $ tmpErrorMessage = ( $ this ->name ?? ' ? ' ) . ': ' . ($ this ->line ?? '? ' ) . ' | ' . \print_r ($ e ->getMessage (), true );
350358 $ this ->parseError [\md5 ($ tmpErrorMessage )] = $ tmpErrorMessage ;
351359 }
352360 }
0 commit comments