3v4l.org

run code in 200+ PHP versions simultaneously
<?php class T1 {} class T2 extends T1 {} class A { /*readonly*/ public T1 $a; public function foo(T1 $a) { $this->a = $a; } } class B extends A { /*readonly*/ public T2 $a; } $foo = new B(); $foo->foo(new T1());
based on gMPHr
Output for 7.4.0 - 7.4.4
Fatal error: Type of B::$a must be T1 (as in class A) in /in/DQ3To on line 16
Process exited with code 255.
Output for 7.2.0 - 7.3.16
Parse error: syntax error, unexpected 'T1' (T_STRING), expecting function (T_FUNCTION) or const (T_CONST) in /in/DQ3To on line 7
Process exited with code 255.