1
0
mirror of https://github.com/flarum/core.git synced 2025-08-05 07:57:46 +02:00

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
```
This commit is contained in:
Daniël Klabbers
2024-06-18 19:15:23 +02:00
parent 71c20ef4f1
commit 49bf9b734b

View File

@@ -25,8 +25,8 @@ use Tobyz\JsonApiServer\Resource\Resource;
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;