/** * Handles an exception * Note: I have removed the type hint of Exception as its different in PHP7 * @param Exception $exception */ public function handleException($exception) { $this->errorWriter->writeToFile((string) $exception); //This is the code that fails if ($this->errorTestLoadAndFails === null) { $this->errorTestLoadAndFails = new ErrorTestLoadAndFails(); $this->errorTestLoadAndFails->test(); } }
} } require_once $root . "bundles/" . implode("/", $classArrayCorrected) . ".php"; }); //Auto loader for all classes without a namespace spl_autoload_register(function ($class) use($root) { if (strpos($class, "\\") !== 0) { $class = "\\" . $class; } if (strpos($class, "\\Error") !== 0) { return false; } require_once $root . "src/" . ltrim($class, "\\") . ".php"; }); //Make the error writer and clear error file (delete it) $errorWriter = new ErrorWriter(); $errorWriter->setProjectRoot($root); $errorWriter->removeErrorFile(); //Build the error handler and tell PHP to use it $errorHandler = new ErrorHandler(); $errorHandler->setErrorWriter($errorWriter); set_error_handler(array($errorHandler, 'handleError')); set_exception_handler(array($errorHandler, 'handleException')); register_shutdown_function(array($errorHandler, 'handleShutdown')); //Trigger the initial error $class = new JeremySells\Test\SuperClass(); $class->theFunctionThatErrors("test", array()); ?> <p>Script Finished</p> <h1>Errors in the error file:</h1>