<?php
declare(strict_types=1);
class Dummy { }
class Parental {
public function __set($name, $val) {
printf("Setting %s to %s\n", $name, var_export($val, true));
$this->{$name} = $val;
}
}
class Demo extends Parental {
private Dummy $x;
public function test() {
$this->x = new Dummy();
}
}
$d = new Demo();
$d->test();
print_r($d);
Parse error: syntax error, unexpected 'Dummy' (T_STRING), expecting function (T_FUNCTION) or const (T_CONST) in /in/DQqak on line 15
Process exited with code 255.