Skip to content

Commit ce97e46

Browse files
bckpdg
authored andcommitted
Application: refactor to return Response from processRequest() BC break (#350)
Changed Application::processRequest to return a Response object instead of sending it directly. Updated run() to call send() on the returned Response. This improves testability and separation of concerns by decoupling request processing from response sending.
1 parent 07918ee commit ce97e46

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/Application/Application.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,15 +74,17 @@ public function run(): void
7474
{
7575
try {
7676
Arrays::invoke($this->onStartup, $this);
77-
$this->processRequest($this->createInitialRequest());
77+
$this->processRequest($this->createInitialRequest())
78+
->send($this->httpRequest, $this->httpResponse);
7879
Arrays::invoke($this->onShutdown, $this);
7980

8081
} catch (\Throwable $e) {
8182
$this->sendHttpCode($e);
8283
Arrays::invoke($this->onError, $this, $e);
8384
if ($this->catchExceptions && ($req = $this->createErrorRequest($e))) {
8485
try {
85-
$this->processRequest($req);
86+
$this->processRequest($req)
87+
->send($this->httpRequest, $this->httpResponse);
8688
Arrays::invoke($this->onShutdown, $this, $e);
8789
return;
8890

@@ -121,7 +123,7 @@ public function createInitialRequest(): Request
121123
}
122124

123125

124-
public function processRequest(Request $request): void
126+
public function processRequest(Request $request): Response
125127
{
126128
process:
127129
if (count($this->requests) > $this->maxLoop) {
@@ -156,7 +158,7 @@ public function processRequest(Request $request): void
156158
}
157159

158160
Arrays::invoke($this->onResponse, $this, $response);
159-
$response->send($this->httpRequest, $this->httpResponse);
161+
return $response;
160162
}
161163

162164

0 commit comments

Comments
 (0)