<?php
/**
* driver.php
* ----------
* Registers a shutdown-function, that includes "error_handler.php" (which merely defines
* a innocuous function named "handle_error", and includes "throw_fatal_error.php"
* (that provokes an error declaring two classes with the same name).
*
* What happens is that the fatal error is thrown, shutdownFunc() is called and
* "error_handler.php" is included -- but it occurs another fatal error, complaining that
* handle_error() (defined in "error_handler.php") is undefined.
* The problem does not happen with classes, as can be demonstrated by ErrorClass,
* which is defined in "error_handler.php" and it's existence checked on shutdownFunc().
*
* VERY IMPORTANT NOTE
* If "throw_fatal_error.php" does not include a namespace or if neither class inherits
* from another, everything works ok!
*/
function shutdownFunc () {
eval(<<<'PHP'
function handle_error () {
echo "handle_error() is here<br />\n";
}
class ErrorClass extends \stdclass {}
PHP
);
echo "We're about to call <em>handle_error()</em>...<br />\n";
echo 'ErrorClass is ', class_exists ('ErrorClass') ? 'undefined' : 'defined', "<br />\n";
handle_error();
}
register_shutdown_function ('shutdownFunc');
// Make sure errors are printed.
ini_set ('display_errors', 'On');
// Include the file that provokes the error.
eval(<<<'PHP'
namespace test;
class aclass {}
class aclass extends \stdclass {}
PHP
);