diff --git a/src/PhpDoc/PhpDocBlock.php b/src/PhpDoc/PhpDocBlock.php index fd75fa5306..f8030003fe 100644 --- a/src/PhpDoc/PhpDocBlock.php +++ b/src/PhpDoc/PhpDocBlock.php @@ -128,18 +128,24 @@ public static function resolvePhpDocBlockForProperty( array $newPositionalParameterNames, // unused ): self { - return self::resolvePhpDocBlockTree( - $docComment, - $classReflection, - $trait, + $docBlocksFromParents = self::resolveParentPhpDocBlocks( + self::getParentReflections($classReflection), $propertyName, - $file, 'hasNativeProperty', 'getNativeProperty', __FUNCTION__, - $explicit, - [], - [], + $explicit ?? $docComment !== null, + $newPositionalParameterNames, + ); + + return new self( + $docComment ?? ResolvedPhpDocBlock::EMPTY_DOC_STRING, + $file, + $classReflection, + $trait, + $explicit ?? true, + self::remapParameterNames($originalPositionalParameterNames, $newPositionalParameterNames), + $docBlocksFromParents, ); } @@ -158,18 +164,24 @@ public static function resolvePhpDocBlockForConstant( array $newPositionalParameterNames, // unused ): self { - return self::resolvePhpDocBlockTree( - $docComment, - $classReflection, - null, + $docBlocksFromParents = self::resolveParentPhpDocBlocks( + self::getParentReflections($classReflection), $constantName, - $file, 'hasConstant', 'getConstant', __FUNCTION__, - $explicit, - [], - [], + $explicit ?? $docComment !== null, + $newPositionalParameterNames, + ); + + return new self( + $docComment ?? ResolvedPhpDocBlock::EMPTY_DOC_STRING, + $file, + $classReflection, + $trait, + $explicit ?? true, + self::remapParameterNames($originalPositionalParameterNames, $newPositionalParameterNames), + $docBlocksFromParents, ); } @@ -188,45 +200,12 @@ public static function resolvePhpDocBlockForMethod( array $newPositionalParameterNames, ): self { - return self::resolvePhpDocBlockTree( - $docComment, - $classReflection, - $trait, + $docBlocksFromParents = self::resolveParentPhpDocBlocks( + self::getParentReflections($classReflection), $methodName, - $file, 'hasNativeMethod', 'getNativeMethod', __FUNCTION__, - $explicit, - $originalPositionalParameterNames, - $newPositionalParameterNames, - ); - } - - /** - * @param array $originalPositionalParameterNames - * @param array $newPositionalParameterNames - */ - private static function resolvePhpDocBlockTree( - ?string $docComment, - ClassReflection $classReflection, - ?string $trait, - string $name, - ?string $file, - string $hasMethodName, - string $getMethodName, - string $resolveMethodName, - ?bool $explicit, - array $originalPositionalParameterNames, - array $newPositionalParameterNames, - ): self - { - $docBlocksFromParents = self::resolveParentPhpDocBlocks( - $classReflection, - $name, - $hasMethodName, - $getMethodName, - $resolveMethodName, $explicit ?? $docComment !== null, $newPositionalParameterNames, ); @@ -264,11 +243,12 @@ private static function remapParameterNames( } /** + * @param array $parentReflections * @param array $positionalParameterNames * @return array */ private static function resolveParentPhpDocBlocks( - ClassReflection $classReflection, + array $parentReflections, string $name, string $hasMethodName, string $getMethodName, @@ -278,7 +258,6 @@ private static function resolveParentPhpDocBlocks( ): array { $result = []; - $parentReflections = self::getParentReflections($classReflection); foreach ($parentReflections as $parentReflection) { $oneResult = self::resolvePhpDocBlockFromClass(