- 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 is deprecated, pass B instead in /in/CLnhZ on line 11 object(B)#3 (0) { } object(B)#3 (0) { }
<?php
class A {}
class B {}
class C {
public function __construct(
protected 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());