Some rewrites:
authorRoland Häder <roland@mxchange.org>
Sat, 17 Jun 2017 20:38:25 +0000 (22:38 +0200)
committerRoland Häder <roland@mxchange.org>
Sat, 17 Jun 2017 20:38:25 +0000 (22:38 +0200)
- debugOutput() does not include caller method name and line number
- partialStub() no longer outputs caller method name

Signed-off-by: Roland Häder <roland@mxchange.org>
framework/main/classes/class_BaseFrameworkSystem.php
framework/main/middleware/debug/class_DebugMiddleware.php

index 756b3fe86833866bc9ea2d3485e12a3ba2fcb156..acf765d8b31083c9082fd73c00ae1699fcf54835 100644 (file)
@@ -1743,19 +1743,8 @@ Loaded includes:
         * @return      void
         */
        protected function partialStub ($message = '') {
         * @return      void
         */
        protected function partialStub ($message = '') {
-               // Get the backtrace
-               $backtrace = debug_backtrace();
-
-               // Generate the class::method string
-               $methodName = 'UnknownClass-&gt;unknownMethod';
-               if ((isset($backtrace[1]['class'])) && (isset($backtrace[1]['function']))) {
-                       $methodName = $backtrace[1]['class'] . '-&gt;' . $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)) {
 
                // 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('');
 
                        // 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
                } else {
                        // Get instance from registry
-                       $debugInstance = Registry::getRegistry()->getDebugInstance();
+                       $debugInstance = Registry::getRegistry()->getInstance('debug');
                }
 
                // Return it
                }
 
                // Return it
@@ -1860,6 +1849,28 @@ Loaded includes:
                // Set debug instance to NULL
                $debugInstance = NULL;
 
                // 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
                // Try it:
                try {
                        // Get debug instance
index abca7c3091ac69836f91a64b8e0b1db5fd69cec4..7bb3058690429ab3fd109e5403a01ef6bfc82d48 100644 (file)
@@ -51,9 +51,6 @@ class DebugMiddleware extends BaseMiddleware implements Registerable {
 
                // Set own instance
                self::$selfInstance = $this;
 
                // Set own instance
                self::$selfInstance = $this;
-
-               // Set it so all can use it
-               $this->setDebugInstance($this);
        }
 
        /**
        }
 
        /**