Skip to content

Commit

Permalink
fix: json api instantiation fails
Browse files Browse the repository at this point in the history
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
```
  • Loading branch information
luceos committed Jun 18, 2024
1 parent 71c20ef commit 49bf9b7
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions framework/core/src/Api/JsonApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down

0 comments on commit 49bf9b7

Please sign in to comment.