3v4l.org

run code in 300+ PHP versions simultaneously
<?php class A {} class B {} class C { public function __construct( protected readonly A|B $b ) { if ($this->b instanceof A) { trigger_error('A is deprecated, pass B instead', E_USER_DEPRECATED); $this->b = new B(); } var_dump($this->b); } } new C(new A()); new C(new B());

preferences:
46.6 ms | 405 KiB | 5 Q