<?php
declare(strict_types=1);
error_reporting(E_ALL);
class ClassUsedForTyping
{
}
class ClassWithSetMagic {
public function __construct(array $dummy) {
printf("Constructor for ClassWithSetMagic\n");
}
public function __set($name, $value) {
printf("Setting %s\n", $name);
}
public function __isset($name) {
return false;
}
}
class ClassInheritingFromClassWithSetMagic extends ClassWithSetMagic {
public ClassUsedForTyping $property_with_type;
public function __construct(array $dummy, ClassUsedForTyping $class_used_for_typing) {
parent::__construct($dummy);
printf("Constructor for ClassInheritingFromClassWithSetMagic\n");
$this->property_with_type = $class_used_for_typing;
}
}
$inst = new ClassInheritingFromClassWithSetMagic(
[],
new ClassUsedForTyping()
);
print_r($inst);
Parse error: syntax error, unexpected 'ClassUsedForTyping' (T_STRING), expecting function (T_FUNCTION) or const (T_CONST) in /in/LECsk on line 27
Process exited with code 255.