- var_dump: documentation ( source)
- trigger_error: documentation ( source)
<?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());