From 49bf9b734bec5815b2bb7d1a3dccc49348a0fff2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dani=C3=ABl=20Klabbers?= Date: Tue, 18 Jun 2024 19:15:23 +0200 Subject: [PATCH] fix: json api instantiation fails Currently the JsonApi is heavily used with methods `forEndpoint` and `forResource`, these method set their respective properties, which have no value initially. When instantiating the class, an "cannot access before initialization" error because there's no default. ``` Typed property Flarum\Api\JsonApi::$endpointName must not be accessed before initialization ``` --- framework/core/src/Api/JsonApi.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/framework/core/src/Api/JsonApi.php b/framework/core/src/Api/JsonApi.php index dd192dc930..100265bbd6 100644 --- a/framework/core/src/Api/JsonApi.php +++ b/framework/core/src/Api/JsonApi.php @@ -25,8 +25,8 @@ class JsonApi extends BaseJsonApi { - protected string $resourceClass; - protected string $endpointName; + protected ?string $resourceClass = null; + protected ?string $endpointName = null; protected ?Request $baseRequest = null; protected ?Container $container = null;