Skip to content

Commit 081b02f

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 9693942 commit 081b02f

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

src/Application/Application.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,15 +66,17 @@ public function run(): void
6666
{
6767
try {
6868
Arrays::invoke($this->onStartup, $this);
69-
$this->processRequest($this->createInitialRequest());
69+
$this->processRequest($this->createInitialRequest())
70+
->send($this->httpRequest, $this->httpResponse);
7071
Arrays::invoke($this->onShutdown, $this);
7172

7273
} catch (\Throwable $e) {
7374
$this->sendHttpCode($e);
7475
Arrays::invoke($this->onError, $this, $e);
7576
if ($this->catchExceptions && ($req = $this->createErrorRequest($e))) {
7677
try {
77-
$this->processRequest($req);
78+
$this->processRequest($req)
79+
->send($this->httpRequest, $this->httpResponse);
7880
Arrays::invoke($this->onShutdown, $this, $e);
7981
return;
8082

@@ -113,7 +115,7 @@ public function createInitialRequest(): Request
113115
}
114116

115117

116-
public function processRequest(Request $request): void
118+
public function processRequest(Request $request): Response
117119
{
118120
process:
119121
if (count($this->requests) > $this->maxLoop) {
@@ -148,7 +150,7 @@ public function processRequest(Request $request): void
148150
}
149151

150152
Arrays::invoke($this->onResponse, $this, $response);
151-
$response->send($this->httpRequest, $this->httpResponse);
153+
return $response;
152154
}
153155

154156

0 commit comments

Comments
 (0)