Skip to content

Commit 80c5ed4

Browse files
Fix passed parameters resolution.
1 parent c312711 commit 80c5ed4

2 files changed

Lines changed: 7 additions & 7 deletions

File tree

src/Http/ControllerFactory.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -110,27 +110,27 @@ public function invokeAction(Controller $controller)
110110

111111
$passed = $request->getParam('pass');
112112
$args = [];
113+
$i = 0;
113114
foreach ($parameters as $parameter) {
114-
$name = $parameter->getName();
115-
if (isset($passed[$name])) {
116-
$args[] = $passed[$name];
117-
unset($passed[$name]);
115+
if (isset($passed[$i])) {
116+
$args[] = $passed[$i];
118117
} else {
119118
$class = $parameter->getClass();
120119
if ($class) {
121120
$id = $class->getName();
122121
} else {
123-
$id = $name;
122+
$id = $parameter->getName();
124123
}
125124
if ($this->container->has($id)) {
126125
$args[] = $this->container->get($id);
127126
}
128127
}
128+
$i++;
129129
}
130130

131131
/* @var callable $callable */
132132
$callable = [$controller, $action];
133133

134-
return $callable(...array_merge($args, array_values($passed)));
134+
return $callable(...$args);
135135
}
136136
}

tests/TestCase/Http/ControllerFactoryTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public function testInvoke()
6060
$request = ServerRequestFactory::fromGlobals()
6161
->withParam('controller', 'Articles')
6262
->withParam('action', 'view')
63-
->withParam('pass', ['id' => 1]);
63+
->withParam('pass', [1]);
6464
$response = new Response;
6565

6666
$controller = new ArticlesController($request, $response);

0 commit comments

Comments
 (0)