3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Dad { static function getStatic() { return new static; } static function getSelf() { return new self; } } trait Useless { static function getStatic() { return new static; } } final class A extends Dad { use Useless; static function getSelf() { return new self; } } var_dump(A::getStatic()::class); var_dump(A::getSelf()::class);
Output for 8.0.8, 8.1.5
string(1) "A" string(1) "A"
Output for 7.2.34, 7.3.2
Fatal error: Dynamic class names are not allowed in compile-time ::class fetch in /in/CsmAr on line 27
Process exited with code 255.

preferences:
36.97 ms | 409 KiB | 5 Q