From 741e36aa16b4a1c21beb352a53f401d32249905c Mon Sep 17 00:00:00 2001 From: Mark Story Date: Tue, 25 Jul 2023 20:42:43 -0700 Subject: [PATCH] Improve compatibility with CakePHP 4.5 and PHP 8.2 - `ServerRequest::is()` now throws exceptions when a detector is unregistered. - PHP 8.2 emits deprecations for dynamically created properties. --- src/Middleware/InertiaMiddleware.php | 6 +++--- tests/TestCase/View/InertiaJsonViewTest.php | 2 ++ 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/Middleware/InertiaMiddleware.php b/src/Middleware/InertiaMiddleware.php index 34d56c2..0261337 100644 --- a/src/Middleware/InertiaMiddleware.php +++ b/src/Middleware/InertiaMiddleware.php @@ -21,12 +21,12 @@ class InertiaMiddleware implements MiddlewareInterface */ public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface { - if (!$request->hasHeader('X-Inertia')) { - return $handler->handle($request); - } if ($request instanceof ServerRequest) { $this->setupDetectors($request); } + if (!$request->hasHeader('X-Inertia')) { + return $handler->handle($request); + } $response = $handler->handle($request); if ( diff --git a/tests/TestCase/View/InertiaJsonViewTest.php b/tests/TestCase/View/InertiaJsonViewTest.php index be8bd47..f30b5c4 100644 --- a/tests/TestCase/View/InertiaJsonViewTest.php +++ b/tests/TestCase/View/InertiaJsonViewTest.php @@ -10,6 +10,8 @@ class InertiaJsonViewTest extends TestCase { + public $View; + public function setUp(): void { parent::setUp();