Class app\models\ReportModel has an uninitialized property $is_employee_noticed. Give it default value or assign it in the constructor
13 public ?string $subject;
14 public ?string $message;
15 public bool $is_resolved;
16 public bool $is_employee_noticed; 17
18
19 public function __construct($params = array()) {
Class app\models\ReportModel has an uninitialized property $is_resolved. Give it default value or assign it in the constructor
12 public string $user_type;
13 public ?string $subject;
14 public ?string $message;
15 public bool $is_resolved; 16 public bool $is_employee_noticed;
17
18
Class app\models\ReportModel has an uninitialized property $message. Give it default value or assign it in the constructor
11 public string $username;
12 public string $user_type;
13 public ?string $subject;
14 public ?string $message; 15 public bool $is_resolved;
16 public bool $is_employee_noticed;
17
Class app\models\ReportModel has an uninitialized property $subject. Give it default value or assign it in the constructor
10 public string $inquiry_id;
11 public string $username;
12 public string $user_type;
13 public ?string $subject; 14 public ?string $message;
15 public bool $is_resolved;
16 public bool $is_employee_noticed;
Class app\models\ReportModel has an uninitialized property $user_type. Give it default value or assign it in the constructor
9{
10 public string $inquiry_id;
11 public string $username;
12 public string $user_type; 13 public ?string $subject;
14 public ?string $message;
15 public bool $is_resolved;
Class app\models\ReportModel has an uninitialized property $username. Give it default value or assign it in the constructor
8class ReportModel extends Model
9{
10 public string $inquiry_id;
11 public string $username; 12 public string $user_type;
13 public ?string $subject;
14 public ?string $message;
Class app\models\ReportModel has an uninitialized property $inquiry_id. Give it default value or assign it in the constructor
7
8class ReportModel extends Model
9{
10 public string $inquiry_id; 11 public string $username;
12 public string $user_type;
13 public ?string $subject;
Description
The typed properties must not be accessed before initialization. That means the property is in Uninitialized state, so reading from the property will result in a fatal runtime error.
To avoid this problem it is recommended to give it a default value or assign it to the constructor.
Bad practice
class Greet
{
public string $message;
public function user(string $name): string
{
// invalid: $message property is uninitialized
$greetings = sprintf('%s %s', $this->message, $name);
return $greetings;
}
}
Recommended
Consider giving it a default value:
class Greet
{
public string $message = 'Welcome';
public function user(string $name): string
{
$greetings = sprintf('%s %s', $this->message, $name);
return $greetings;
}
}
Initialize the property in constructor:
class Greet
{
public string $message;
public function __construct(string $message)
{
$this->message = $message;
}
public function user(string $name): string
{
$greetings = sprintf('%s %s', $this->message, $name);
return $greetings;
}
}