From 13d2edb7c36799d83cfc64c9a2a144e4d920383c Mon Sep 17 00:00:00 2001 From: flashwave Date: Wed, 31 Jul 2024 19:20:55 +0000 Subject: [PATCH] Removed exception conversion stuff. --- VERSION | 2 +- index.php | 10 ----- src/Exceptions.php | 79 ---------------------------------------- src/IO/FileStream.php | 4 +- src/IO/NetworkStream.php | 4 +- 5 files changed, 5 insertions(+), 94 deletions(-) delete mode 100644 src/Exceptions.php diff --git a/VERSION b/VERSION index 47c0813..f38e5b3 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.2407.311911 +0.2407.311920 diff --git a/index.php b/index.php index 387cb39..c58e038 100644 --- a/index.php +++ b/index.php @@ -7,13 +7,3 @@ namespace Index; define('NDX_ROOT', __DIR__); define('NDX_DIR_SRC', NDX_ROOT . DIRECTORY_SEPARATOR . 'src'); - -// currently phpstan sucks and relies on error suppression, luckily it leaves a constant! -if(!defined('__PHPSTAN_RUNNING__')) { - // defining this WILL cause issues, never do it unless you HAVE to - if(!defined('NDX_LEAVE_ERRORS')) - Exceptions::convertErrors(); - - if(!defined('NDX_LEAVE_EXCEPTIONS')) - Exceptions::handleExceptions(); -} diff --git a/src/Exceptions.php b/src/Exceptions.php deleted file mode 100644 index c05c14d..0000000 --- a/src/Exceptions.php +++ /dev/null @@ -1,79 +0,0 @@ -NDX_LEAVE_ERRORS is defined beforehand. - * This is not recommended as it may cause undefined behaviour in some classes. - * This will also make error suppression not work, luckily you've not been using that since PHP 5. Right? Right?! - * Besides, this makes it possible to try..catch errors. - */ - public static function convertErrors(): void { - self::restoreErrors(); - set_error_handler([self::class, 'handleError'], -1); - } - - /** - * Restores error handling to the default PHP state. - */ - public static function restoreErrors(): void { - restore_error_handler(); - } - - /** - * Handle uncaught exceptions. - * - * Automatically invoked by inclusion of index.php into your project unless the constant NDX_LEAVE_EXCEPTIONS is defined. - */ - public static function handleExceptions(): void { - self::restoreExceptions(); - //set_exception_handler([self::class, 'handleException']); - } - - /** - * Restores uncaught exception handling to the default PHP state. - */ - public static function restoreExceptions(): void { - restore_exception_handler(); - } - - /** - * Converts errors to ErrorExceptions. - * - * Paramater documentation is copied from the set_error_handler page on php.net - * - * @see https://www.php.net/manual/en/function.set-error-handler.php - * @param int $errno The first parameter, errno, will be passed the level of the error raised, as an integer. - * @param string $errstr The second parameter, errstr, will be passed the error message, as a string. - * @param string $errfile If the callback accepts a third parameter, errfile, it will be passed the filename that the error was raised in, as a string. - * @param int $errline If the callback accepts a fourth parameter, errline, it will be passed the line number where the error was raised, as an integer. - * @throws ErrorException An ErrorException with the provided parameters. - * @return bool if this were false the PHP error handler would continue, but returning is never reached. - */ - public static function handleError(int $errno, string $errstr, string $errfile, int $errline): bool { - throw new ErrorException($errstr, 0, $errno, $errfile, $errline); - } - - /** - * Handles uncaught exceptions. - * - * @see https://www.php.net/manual/en/function.set-exception-handler.php - * @param ?Throwable $ex Uncaught Throwable to handle. May be null to reset state(?) apparently. - */ - public static function handleException(?Throwable $ex): void { - if($ex === null) - return; - } -} diff --git a/src/IO/FileStream.php b/src/IO/FileStream.php index ae807fa..4f2842c 100644 --- a/src/IO/FileStream.php +++ b/src/IO/FileStream.php @@ -1,7 +1,7 @@