♻️ revert get default value to string

This commit is contained in:
Gautier DELEGLISE
2024-11-03 23:28:27 +01:00
parent 2b2242d323
commit f26d445de6
2 changed files with 7 additions and 4 deletions
@@ -66,7 +66,7 @@ final class MethodParameterFactory
}
/**
* @param array<array, null, int, float, bool, string, object> $defaultValue
* @param array<array|null|int|float|bool|string|object> $defaultValue
* @return string
*/
private function formatArray(array $defaultValue): string
+6 -3
View File
@@ -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) : '');
}
}