From 6a623a4829976aefff76b70ed323fa4f7177139f Mon Sep 17 00:00:00 2001 From: Gautier DELEGLISE Date: Wed, 30 Oct 2024 21:49:01 +0100 Subject: [PATCH] :children_crossing: code review --- .../Tags/Factory/MethodParameterFactory.php | 26 +++++++++++++------ src/DocBlock/Tags/MethodParameter.php | 8 +++++- 2 files changed, 25 insertions(+), 9 deletions(-) diff --git a/src/DocBlock/Tags/Factory/MethodParameterFactory.php b/src/DocBlock/Tags/Factory/MethodParameterFactory.php index 8fd16f2..1cccde9 100644 --- a/src/DocBlock/Tags/Factory/MethodParameterFactory.php +++ b/src/DocBlock/Tags/Factory/MethodParameterFactory.php @@ -17,10 +17,16 @@ use phpDocumentor\Reflection\DocBlock\Tags\Formatter; use function str_repeat; use function strlen; -class MethodParameterFactory +/** + * @internal This class is not part of the BC promise of this library. + */ +final class MethodParameterFactory { /** * Formats the given default value to a string-able mixin + * + * @param mixed $defaultValue + * @return string */ public function format($defaultValue): string { @@ -30,32 +36,36 @@ class MethodParameterFactory return ''; } - protected function formatDouble(float $defaultValue): string + private function formatDouble(float $defaultValue): string { return var_export($defaultValue, true); } - protected function formatNull($defaultValue): string + /** + * @param mixed $defaultValue + * @return string + */ + private function formatNull($defaultValue): string { return 'null'; } - protected function formatInteger(int $defaultValue): string + private function formatInteger(int $defaultValue): string { return var_export($defaultValue, true); } - protected function formatString(string $defaultValue): string + private function formatString(string $defaultValue): string { return var_export($defaultValue, true); } - protected function formatBoolean(bool $defaultValue): string + private function formatBoolean(bool $defaultValue): string { return var_export($defaultValue, true); } - protected function formatArray(array $defaultValue): string + private function formatArray(array $defaultValue): string { $formatedValue = '['; @@ -74,7 +84,7 @@ class MethodParameterFactory return $formatedValue; } - protected function formatObject(object $defaultValue): string + private function formatObject(object $defaultValue): string { return 'new '. get_class($defaultValue). '()'; } diff --git a/src/DocBlock/Tags/MethodParameter.php b/src/DocBlock/Tags/MethodParameter.php index 72d2c4a..c50c87e 100644 --- a/src/DocBlock/Tags/MethodParameter.php +++ b/src/DocBlock/Tags/MethodParameter.php @@ -25,10 +25,16 @@ final class MethodParameter private string $name; - private mixed $defaultValue; + /** + * @var mixed + */ + private $defaultValue; private const NO_DEFAULT_VALUE = '__NO_VALUE__'; + /** + * @param mixed $defaultValue + */ public function __construct( string $name, Type $type,