Skip to content

Commit

Permalink
Merge pull request #24 from dieend/fix-bug
Browse files Browse the repository at this point in the history
There is a bug where the arguments not ordered correctly
  • Loading branch information
petrabarus committed Nov 19, 2015
2 parents 6a4f52c + 94ebbf1 commit 5e0ac23
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions src/Worker/Controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,22 +56,23 @@ public function bindActionParams($action, $params) {
$method = new \ReflectionMethod($action, 'run');
}

$args = $params;
$args = [];

$missing = [];

foreach ($method->getParameters() as $i => $param) {
/* @var $param \ReflectionParameter */
$name = $param->getName();
if ($param->isArray() && isset($params[$name])) {
$args[$name] = preg_split('/\s*,\s*/', $params[$name]);
}
if (!isset($args[$name])) {
if ($param->isDefaultValueAvailable()) {
$args[$name] = $param->getDefaultValue();
if (isset($params[$name])) {
if ($param->isArray()) {
$args[] = preg_split('/\s*,\s*/', $params[$name]);
} else {
$missing[] = $name;
$args[] = $params[$name];
}
} else if ($param->isDefaultValueAvailable()) {
$args[] = $param->getDefaultValue();
} else {
$missing[] = $name;
}
}

Expand Down

0 comments on commit 5e0ac23

Please sign in to comment.