-
-
Notifications
You must be signed in to change notification settings - Fork 388
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Extract parameter formatting from Version class and move to Parameter… #641
Conversation
*/ | ||
public function formatParameters(array $params, array $types) : string | ||
{ | ||
if (empty($params)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please avoid empty()
, either use count(...) !== 0
or !== []
$out = []; | ||
foreach ($params as $key => $value) { | ||
$type = $types[$key] ?? 'string'; | ||
$outval = '[' . $this->formatParameter($value, $type) . ']'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
$formattedValue
private function parameterToString($value) : string | ||
{ | ||
if (is_array($value)) { | ||
return implode(', ', array_map([$this, 'parameterToString'], $value)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Better use closure here instead of string name.
} | ||
|
||
/** | ||
* @param int[]|bool[]|string[]|array|int|string|bool $value |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the function is doing recursion 🤔
17443b9
to
1f4925f
Compare
Fixes #640