<?php declare(strict_types=1); error_reporting(E_ALL); final class foo { protected string $name; public function setName(string $name): void { if (!empty($this->name)) { throw new \RuntimeException('name already set and cannot be changed.'); } $this->name = $name; } public function getName(): string { return $this->name; } } $test1 = new foo(); var_dump($test1->getName());
You have javascript disabled. You will not be able to edit any code.