From f26d445de6a5b1268250e27b8c142e7850d1ca62 Mon Sep 17 00:00:00 2001 From: Gautier DELEGLISE Date: Sun, 3 Nov 2024 23:28:27 +0100 Subject: [PATCH] :recycle: revert get default value to string --- src/DocBlock/Tags/Factory/MethodParameterFactory.php | 2 +- src/DocBlock/Tags/MethodParameter.php | 9 ++++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/DocBlock/Tags/Factory/MethodParameterFactory.php b/src/DocBlock/Tags/Factory/MethodParameterFactory.php index 6de2051..92ff69d 100644 --- a/src/DocBlock/Tags/Factory/MethodParameterFactory.php +++ b/src/DocBlock/Tags/Factory/MethodParameterFactory.php @@ -66,7 +66,7 @@ final class MethodParameterFactory } /** - * @param array $defaultValue + * @param array $defaultValue * @return string */ private function formatArray(array $defaultValue): string diff --git a/src/DocBlock/Tags/MethodParameter.php b/src/DocBlock/Tags/MethodParameter.php index 2cb8177..4cb2827 100644 --- a/src/DocBlock/Tags/MethodParameter.php +++ b/src/DocBlock/Tags/MethodParameter.php @@ -69,9 +69,12 @@ final class MethodParameter return $this->isVariadic; } - public function getDefaultValue(): mixed + public function getDefaultValue(): ?string { - return $this->defaultValue; + if (is_array($this->defaultValue)) { + return implode(',', $this->defaultValue); + } + return (string) $this->defaultValue; } public function __toString(): string @@ -80,6 +83,6 @@ final class MethodParameter ($this->isReference() ? '&' : '') . ($this->isVariadic() ? '...' : '') . '$' . $this->getName() . - ($this->getDefaultValue() !== self::NO_DEFAULT_VALUE ? (new MethodParameterFactory)->format($this->getDefaultValue()) : ''); + ($this->defaultValue !== self::NO_DEFAULT_VALUE ? (new MethodParameterFactory)->format($this->defaultValue) : ''); } }