Typed property must not be accessed before initialisation

Created on 7 April 2024, 8 months ago
Updated 25 June 2024, 5 months ago

Problem/Motivation

I am getting the following error

Uncaught PHP Exception Error: "Typed property Drupal\simple_oauth\Server\ResourceServer::$subject must not be accessed before initialization"

When typed properties were introduced into classes in Php7.4, it became essential to initialise them before they were accessed. This is usually done in the class constructor, but it can be done by specifying a default value in the class where the property is defined.

This gives the potential for an error if the property is accessed before it is set, which is happening in my case.

Steps to reproduce

Proposed resolution

To avoid this problem, it would be useful to assign a default value to the typed property in the class ResourceServer where it is defined. This could be done with a statement like:

protected ?LeagueResourceServer $subject = NULL;

Remaining tasks

User interface changes

API changes

Data model changes

🐛 Bug report
Status

Fixed

Version

5.2

Component

Code

Created by

🇮🇳India Gnanagowthaman sankar Puducherry

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Production build 0.71.5 2024