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 - 8.1.28, 8.2.10 - 8.2.18, 8.3.0 - 8.3.4, 8.3.6
string(1) "A" string(1) "A"
Output for 8.3.5
Warning: PHP Startup: Unable to load dynamic library 'sodium.so' (tried: /usr/lib/php/8.3.5/modules/sodium.so (libsodium.so.23: cannot open shared object file: No such file or directory), /usr/lib/php/8.3.5/modules/sodium.so.so (/usr/lib/php/8.3.5/modules/sodium.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0 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:
64.24 ms | 401 KiB | 31 Q