3v4l.org

run code in 300+ PHP versions simultaneously
<?php class A {} class B {} class C {} class D {} class Z { public function __construct( protected A $a, protected C|B $c, protected D|C $d, protected ?D $unused = NULL, ) { if ($this->c instanceof B) { trigger_error('A, B, C, D is deprecated, pass A, C, D instead', E_USER_DEPRECATED); $this->c = $d; $this->d = $unused; } var_dump($this->a); var_dump($this->c); var_dump($this->d); } } new Z(new A(), new B(), new C(), new D()); new Z(new A(), new C(), new D());
Output for 8.0.1 - 8.0.30, 8.1.0 - 8.1.30, 8.2.0 - 8.2.25, 8.3.0 - 8.3.13
Deprecated: A, B, C, D is deprecated, pass A, C, D instead in /in/08cBi on line 16 object(A)#2 (0) { } object(C)#4 (0) { } object(D)#5 (0) { } object(A)#5 (0) { } object(C)#4 (0) { } object(D)#2 (0) { }

preferences:
53.54 ms | 406 KiB | 5 Q