From: Roland Häder Date: Thu, 17 Aug 2023 00:39:51 +0000 (+0200) Subject: WIP: X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;p=lfdb2.git WIP: - removed deprecated files - updated exceptions.php - updated 'core' framework --- diff --git a/application/lfdb2/data.php b/application/lfdb2/data.php deleted file mode 100644 index 7d6dcee..0000000 --- a/application/lfdb2/data.php +++ /dev/null @@ -1,2 +0,0 @@ - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 LFDB2 Developer Team + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Hub Developer Team * @license GNU GPL 3.0 or any newer version * * This program is free software: you can redistribute it and/or modify @@ -34,16 +34,22 @@ function lfdb2_exception_handler ($exceptionInstance) { // Init variable $backTrace = ''; + // Generate exception code + $exceptionCode = ($exceptionInstance instanceof FrameworkException ? $exceptionInstance->getHexCode() : '0x' . bin2hex($exceptionInstance->getCode())); + // Get all call levels from backtrace foreach ($exceptionInstance->getTrace() as $idx => $traceArray) { // Init argument string $argsString = ''; - // Convert arguments type into human-readable - foreach ($traceArray['args'] as $arg) { - $argsString .= ', ' . gettype($arg); + // Arguments given? + if (isset($traceArray['args'])) { + // Convert arguments type into human-readable + foreach ($traceArray['args'] as $arg) { + $argsString .= ', ' . gettype($arg); + } + $argsString = substr($argsString, 2); } - $argsString = substr($argsString, 2); // Set missing file/line if (!isset($traceArray['file'])) $traceArray['file'] = 'unknown'; @@ -81,7 +87,7 @@ Backtrace: --------------------------------------------------------------------------------\n", trim(html_entity_decode(strip_tags(get_class($exceptionInstance)))), trim(html_entity_decode(strip_tags($exceptionInstance->getMessage()))), - ($exceptionInstance instanceof FrameworkException ? $exceptionInstance->getHexCode() : '0x' . bin2hex($exceptionInstance->getCode())), + $exceptionCode, $exceptionInstance->getFile(), $exceptionInstance->getLine(), trim($backTrace) @@ -89,23 +95,28 @@ Backtrace: // Output the message print($message); + + // Exit with code + exit(hexdec($exceptionCode)); } elseif (is_object($exceptionInstance)) { // Output more details printf('exceptionInstance=%s', print_r($exceptionInstance, true)); + exit(255); } else { /* * Invalid exception instance detected! Do *only* throw exceptions that * extends our own exception 'FrameworkException' to get such nice * outputs like above. */ - printf('exceptionInstance[]=%s is invalid! Please inform the core developer team.' . PHP_EOL, gettype($exceptionInstance)); + printf('exceptionInstance[]=%s is invalid! Please inform the LFDB2 developer team.' . PHP_EOL, gettype($exceptionInstance)); + exit(255); } } // Error handler -function lfdb2_error_handler ($errno, $errstr, $errfile, $errline, array $errcontext) { +function lfdb2_error_handler (int $errno, string $errstr, string $errfile, int $errline, array $errcontext) { // Construct the message - $message = sprintf('File: %s, Line: %s, Code: %s, Message: %s', + $message = sprintf('File: %s, Line: %d, Code: %d, Message: %s', basename($errfile), $errline, $errno, @@ -117,9 +128,9 @@ function lfdb2_error_handler ($errno, $errstr, $errfile, $errline, array $errcon } // Assertion handler -function lfdb2_assert_handler (string $file, int $line, $code) { +function lfdb2_assert_handler (string $file, int $line, int $code) { // Empty code? - if ($code === '') { + if (empty($code)) { $code = 'Unknown'; } @@ -145,7 +156,7 @@ set_exception_handler('lfdb2_exception_handler'); // Init assert handling assert_options(ASSERT_ACTIVE , true); -assert_options(ASSERT_WARNING , false); +assert_options(ASSERT_WARNING , true); assert_options(ASSERT_BAIL , true); assert_options(ASSERT_QUIET_EVAL, false); assert_options(ASSERT_CALLBACK , 'lfdb2_assert_handler'); diff --git a/application/lfdb2/init.php b/application/lfdb2/init.php deleted file mode 100644 index 7d6dcee..0000000 --- a/application/lfdb2/init.php +++ /dev/null @@ -1,2 +0,0 @@ -