-
Notifications
You must be signed in to change notification settings - Fork 62
[Server] Implement variadic parameter handling in ReferenceHandler #36
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -85,10 +85,28 @@ private function prepareArguments(\ReflectionFunctionAbstract $reflection, array | |
$finalArgs = []; | ||
|
||
foreach ($reflection->getParameters() as $parameter) { | ||
// TODO: Handle variadic parameters. | ||
$paramName = $parameter->getName(); | ||
$paramPosition = $parameter->getPosition(); | ||
|
||
// Handle variadic parameters | ||
if ($parameter->isVariadic()) { | ||
// For variadic parameters, collect all remaining arguments | ||
$variadicArgs = []; | ||
foreach ($arguments as $key => $value) { | ||
if (is_numeric($key) && $key >= $paramPosition) { | ||
Comment on lines
+95
to
+96
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this reads like |
||
try { | ||
$variadicArgs[] = $this->castArgumentType($value, $parameter); | ||
} catch (InvalidArgumentException $e) { | ||
throw RegistryException::invalidParams($e->getMessage(), $e); | ||
} catch (\Throwable $e) { | ||
throw RegistryException::internalError("Error processing variadic parameter `{$paramName}`: {$e->getMessage()}", $e); | ||
} | ||
Comment on lines
+97
to
+103
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this is basically the same like in line 112-118 - does it make sense to shift the or somehow merge this block into lower if-else part as well? |
||
} | ||
} | ||
$finalArgs[$paramPosition] = $variadicArgs; | ||
continue; | ||
} | ||
|
||
if (isset($arguments[$paramName])) { | ||
$argument = $arguments[$paramName]; | ||
try { | ||
|
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.
i think this is clear with the next line of code already and we can remove this comment