From e5e15ddf7927dd5d518451a4fe535d6e4dfd19da Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= <roland@mxchange.org> Date: Thu, 17 Aug 2023 02:39:51 +0200 Subject: [PATCH] WIP: - removed deprecated files - updated exceptions.php - updated 'core' framework --- application/lfdb2/data.php | 2 -- application/lfdb2/exceptions.php | 35 +++++++++++++++++++++----------- application/lfdb2/init.php | 2 -- application/lfdb2/loader.php | 2 -- application/lfdb2/starter.php | 2 -- core | 2 +- 6 files changed, 24 insertions(+), 21 deletions(-) delete mode 100644 application/lfdb2/data.php delete mode 100644 application/lfdb2/init.php delete mode 100644 application/lfdb2/loader.php delete mode 100644 application/lfdb2/starter.php 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 @@ -<?php -// @DEPRECATED diff --git a/application/lfdb2/exceptions.php b/application/lfdb2/exceptions.php index e84a25e..3f04264 100644 --- a/application/lfdb2/exceptions.php +++ b/application/lfdb2/exceptions.php @@ -10,7 +10,7 @@ use Org\Mxchange\CoreFramework\Object\BaseFrameworkSystem; * * @author Roland Haeder <webmaster@shipsimu.org> * @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 = '<em>Unknown</em>'; } @@ -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 @@ -<?php -// @DEPRECATED diff --git a/application/lfdb2/loader.php b/application/lfdb2/loader.php deleted file mode 100644 index 7d6dcee..0000000 --- a/application/lfdb2/loader.php +++ /dev/null @@ -1,2 +0,0 @@ -<?php -// @DEPRECATED diff --git a/application/lfdb2/starter.php b/application/lfdb2/starter.php deleted file mode 100644 index 7d6dcee..0000000 --- a/application/lfdb2/starter.php +++ /dev/null @@ -1,2 +0,0 @@ -<?php -// @DEPRECATED diff --git a/core b/core index cef490a..6e12381 160000 --- a/core +++ b/core @@ -1 +1 @@ -Subproject commit cef490aa082a79da16d3dd2b1951dd993c9eda08 +Subproject commit 6e12381ce34de3edb56d18830949362491ddb61a -- 2.39.5