<?php class Sample { private string $instantiatedViaConstructor; private ?string $notInstantiated; public function __construct(string $instantiatedViaConstructor) { $this->instantiatedViaConstructor = $instantiatedViaConstructor; } public function getNotInstantiated(): ?string { return $this->notInstantiated; } public function getWorkingNotInstantiated(): ?string { return $this->notInstantiated ?? null; } } var_dump((new Sample('foo'))->getWorkingNotInstantiated()); var_dump((new Sample('foo'))->getNotInstantiated());
You have javascript disabled. You will not be able to edit any code.