From: Roland Häder Date: Sat, 17 Jun 2017 20:38:25 +0000 (+0200) Subject: Some rewrites: X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=0551dc708ab662db5663d7a693219e6428c9a3da;p=core.git Some rewrites: - debugOutput() does not include caller method name and line number - partialStub() no longer outputs caller method name Signed-off-by: Roland Häder --- diff --git a/framework/main/classes/class_BaseFrameworkSystem.php b/framework/main/classes/class_BaseFrameworkSystem.php index 756b3fe8..acf765d8 100644 --- a/framework/main/classes/class_BaseFrameworkSystem.php +++ b/framework/main/classes/class_BaseFrameworkSystem.php @@ -1743,19 +1743,8 @@ Loaded includes: * @return void */ protected function partialStub ($message = '') { - // Get the backtrace - $backtrace = debug_backtrace(); - - // Generate the class::method string - $methodName = 'UnknownClass->unknownMethod'; - if ((isset($backtrace[1]['class'])) && (isset($backtrace[1]['function']))) { - $methodName = $backtrace[1]['class'] . '->' . $backtrace[1]['function']; - } // END - if - - // Construct the full message - $stubMessage = sprintf('[%s]: Partial stub!', - $methodName - ); + // Init variable + $stubMessage = 'Partial Stub!'; // Is the extra message given? if (!empty($message)) { @@ -1824,11 +1813,11 @@ Loaded includes: // Empty string should be ignored and used for testing the middleware DebugMiddleware::getSelfInstance()->output(''); - // Set it in its own class. This will set it in the registry - $debugInstance->setDebugInstance($debugInstance); + // Set it in registry + Registry::getRegistry()->addInstance('debug', $debugInstance); } else { // Get instance from registry - $debugInstance = Registry::getRegistry()->getDebugInstance(); + $debugInstance = Registry::getRegistry()->getInstance('debug'); } // Return it @@ -1860,6 +1849,28 @@ Loaded includes: // Set debug instance to NULL $debugInstance = NULL; + // Get backtrace + $backtrace = debug_backtrace(!DEBUG_BACKTRACE_PROVIDE_OBJECT); + + // Is function 'partialStub' ? + if ($backtrace[1]['function'] == 'partialStub') { + // Prepend class::function:line from 3rd element + $message = sprintf('[%s::%s:%d]: %s', + $backtrace[2]['class'], + $backtrace[2]['function'], + (isset($backtrace[2]['line']) ? $backtrace[2]['line'] : '0'), + $message + ); + } else { + // Prepend class::function:line from 2nd element + $message = sprintf('[%s::%s:%d]: %s', + $backtrace[1]['class'], + $backtrace[1]['function'], + (isset($backtrace[1]['line']) ? $backtrace[1]['line'] : '0'), + $message + ); + } + // Try it: try { // Get debug instance diff --git a/framework/main/middleware/debug/class_DebugMiddleware.php b/framework/main/middleware/debug/class_DebugMiddleware.php index abca7c30..7bb30586 100644 --- a/framework/main/middleware/debug/class_DebugMiddleware.php +++ b/framework/main/middleware/debug/class_DebugMiddleware.php @@ -51,9 +51,6 @@ class DebugMiddleware extends BaseMiddleware implements Registerable { // Set own instance self::$selfInstance = $this; - - // Set it so all can use it - $this->setDebugInstance($this); } /**