Skip to content

Commit c8347bb

Browse files
committed
fix: pass argv correctly
1 parent fb8be01 commit c8347bb

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/Kernel.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,13 @@ public function run(ServerRequestInterface $request, ?StreamInterface $stream =
3434
{
3535
$this->dispatchConfig->getRouter()->dispatch(function ($data, $args, $middlewares) use ($request, $stream) {
3636

37+
if($args === null) {
38+
$args = $request->getCliArgs();
39+
}
3740

3841
$parts = isset($data[2]) && is_array($data[2]) ? $data[2] : [];
3942
$dispatchCode = (int)($data[0] ?? DispatchCodes::FOUND->value);
4043

41-
4244
if($dispatchCode !== DispatchCodes::FOUND->value) {
4345
$data['handler'] = function (ServerRequestInterface $req, ResponseInterface $res): ResponseInterface
4446
{
@@ -75,13 +77,12 @@ function reMap($data, $args, $middlewares)
7577
if (isset($data[1]) && $middlewares instanceof ServerRequestInterface) {
7678
$item = $data[1];
7779
return [
78-
["handler" => $item['controller']], $_REQUEST, ($item['data'] ?? [])
80+
["handler" => $item['controller']], ($args == null ? $_REQUEST : $args), ($item['data'] ?? [])
7981
];
8082
}
8183
if (!is_array($middlewares)) {
8284
$middlewares = [];
8385
}
84-
8586
if (!is_array($args)) {
8687
$args = [];
8788
}

0 commit comments

Comments
 (0)