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, ) { if ($this->c instanceof B) { trigger_error('A, B, C, D is deprecated, pass A, C, D instead', E_USER_DEPRECATED); $this->c = $this->d; $this->d = func_get_arg(3); } 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.31, 8.2.0 - 8.2.26, 8.3.0 - 8.3.15, 8.4.1 - 8.4.2
Deprecated: A, B, C, D is deprecated, pass A, C, D instead in /in/WVIp1 on line 15 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:
73.9 ms | 406 KiB | 5 Q