get_called_class() Cannot Be Called Outside A Class
get_called_class() generated a warning when called outside a class or an enumeration. Since PHP 8.0, it is a fatal error.
PHP code
<?php
var_dump(get_called_class());
?>
Before
PHP Warning: get_called_class() called from outside a class
Warning: get_called_class() called from outside a class
bool(false)
After
PHP Fatal error: Uncaught Error: get_called_class() must be called from within a class
Fatal error: Uncaught Error: get_called_class() must be called from within a class
PHP version change
This behavior was deprecated in 7.0.
This behavior changed in 8.0.