class_alias() Works On Internal Classes¶
class_alias() makes an alias for a class, an enumeration, an interface or a trait. Until PHP 8.3, it was only possible on custom structures.
PHP code¶
<?php
class_alias(stdClass::class, A::class);
var_dump(new A);
Before¶
First argument of class_alias() must be a name of user defined class
After¶
object(stdClass)#1 (0) {
}
PHP version change¶
This behavior changed in 8.3