src/debug/DebugHelper.php
public static function fixTrace(array $trace, $file='unknown', $line=0) {
        // check if the stacktrace is already fixed
        if ($trace && isset($trace[0]['fixed']))
            return $trace;

        // Fix an incomplete frame[0][line] if parameters are provided and $file matches (e.g. with SimpleXMLElement).
        if ($file!='unknown' && $line) {
            if (isset($trace[0]['file']) && $trace[0]['file']==$file) {
                if (isset($trace[0]['line']) && $trace[0]['line']===0) {
                    $trace[0]['line'] = $line;
                }
            }
        }

        // Add a frame for the main script to the bottom (end of array).
        $trace[] = ['function' => '{main}'];

        // Move FILE and LINE fields down (to the end) by one position.
        for ($i=sizeof($trace); $i--;) {
            if (isset($trace[$i-1]['file'])) $trace[$i]['file'] = $trace[$i-1]['file'];
            else                       unset($trace[$i]['file']);

            if (isset($trace[$i-1]['line'])) $trace[$i]['line'] = $trace[$i-1]['line'];
            else                       unset($trace[$i]['line']);

            $trace[$i]['fixed'] = true;
        }

        // Add location details from parameters to frame[0] only if they differ from the old values (now in frame[1])
        if (!isset($trace[1]['file']) || !isset($trace[1]['line']) || $trace[1]['file']!=$file || $trace[1]['line']!=$line) {
            $trace[0]['file'] = $file;                          // test with:
            $trace[0]['line'] = $line;                          // \SQLite3::enableExceptions(true|false);
        }                                                       // \SQLite3::exec($invalid_sql);
        else {
            unset($trace[0]['file'], $trace[0]['line']);        // otherwise delete them
        }

        // Remove the last frame (the one we added for the main script) if it now points to an unknown location (PHP core).
        $size = sizeof($trace);
        if (!isset($trace[$size-1]['file'])) {
            \array_pop($trace);
        }
        return $trace;

        /**
         * TODO: fix wrong stack frames originating from calls to virtual static functions
         *
         * phalcon\mvc\Model::__callStatic()                  [php-phalcon]
         * vokuro\models\Users::findFirstByEmail() # line 27, file: F:\Projekte\phalcon\sample-apps\vokuro\app\library\Auth\Auth.php
         * vokuro\auth\Auth->check()               # line 27, file: F:\Projekte\phalcon\sample-apps\vokuro\app\library\Auth\Auth.php
         */
    }
public static function fixTrace(array $trace, $file='unknown', $line=0) {
        // check if the stacktrace is already fixed
        if ($trace && isset($trace[0]['fixed']))
            return $trace;

        // Fix an incomplete frame[0][line] if parameters are provided and $file matches (e.g. with SimpleXMLElement).
        if ($file!='unknown' && $line) {
            if (isset($trace[0]['file']) && $trace[0]['file']==$file) {
                if (isset($trace[0]['line']) && $trace[0]['line']===0) {
                    $trace[0]['line'] = $line;
                }
            }
        }

        // Add a frame for the main script to the bottom (end of array).
        $trace[] = ['function' => '{main}'];

        // Move FILE and LINE fields down (to the end) by one position.
        for ($i=sizeof($trace); $i--;) {
            if (isset($trace[$i-1]['file'])) $trace[$i]['file'] = $trace[$i-1]['file'];
            else                       unset($trace[$i]['file']);

            if (isset($trace[$i-1]['line'])) $trace[$i]['line'] = $trace[$i-1]['line'];
            else                       unset($trace[$i]['line']);

            $trace[$i]['fixed'] = true;
        }

        // Add location details from parameters to frame[0] only if they differ from the old values (now in frame[1])
        if (!isset($trace[1]['file']) || !isset($trace[1]['line']) || $trace[1]['file']!=$file || $trace[1]['line']!=$line) {
            $trace[0]['file'] = $file;                          // test with:
            $trace[0]['line'] = $line;                          // \SQLite3::enableExceptions(true|false);
        }                                                       // \SQLite3::exec($invalid_sql);
        else {
            unset($trace[0]['file'], $trace[0]['line']);        // otherwise delete them
        }

        // Remove the last frame (the one we added for the main script) if it now points to an unknown location (PHP core).
        $size = sizeof($trace);
        if (!isset($trace[$size-1]['file'])) {
            \array_pop($trace);
        }
        return $trace;

        /**
         * TODO: fix wrong stack frames originating from calls to virtual static functions
         *
         * phalcon\mvc\Model::__callStatic()                  [php-phalcon]
         * vokuro\models\Users::findFirstByEmail() # line 27, file: F:\Projekte\phalcon\sample-apps\vokuro\app\library\Auth\Auth.php
         * vokuro\auth\Auth->check()               # line 27, file: F:\Projekte\phalcon\sample-apps\vokuro\app\library\Auth\Auth.php
         */
    }
public static function fixTrace ( array $ trace , $ file = 'unknown' , $ line = 0 ) { // check if the stacktrace is already fixed if ( $ trace && isset ( $ trace [ 0 ] [ 'fixed' ] ) ) return $ trace ; // Fix an incomplete frame[0][line] if parameters are provided and $file matches (e.g. with SimpleXMLElement). if ( $ file != 'unknown' && $ line ) { if ( isset ( $ trace [ 0 ] [ 'file' ] ) && $ trace [ 0 ] [ 'file' ] == $ file ) { if ( isset ( $ trace [ 0 ] [ 'line' ] ) && $ trace [ 0 ] [ 'line' ] === 0 ) { $ trace [ 0 ] [ 'line' ] = $ line ; } } } // Add a frame for the main script to the bottom (end of array). $ trace [ ] = [ 'function' => '{main}' ] ; // Move FILE and LINE fields down (to the end) by one position. for ( $ i = sizeof ( $ trace ) ; $ i -- ; ) { if ( isset ( $ trace [ $ i - 1 ] [ 'file' ] ) ) $ trace [ $ i ] [ 'file' ] = $ trace [ $ i - 1 ] [ 'file' ] ; else unset ( $ trace [ $ i ] [ 'file' ] ) ; if ( isset ( $ trace [ $ i - 1 ] [ 'line' ] ) ) $ trace [ $ i ] [ 'line' ] = $ trace [ $ i - 1 ] [ 'line' ] ; else unset ( $ trace [ $ i ] [ 'line' ] ) ; $ trace [ $ i ] [ 'fixed' ] = true ; } // Add location details from parameters to frame[0] only if they differ from the old values (now in frame[1]) if ( ! isset ( $ trace [ 1 ] [ 'file' ] ) || ! isset ( $ trace [ 1 ] [ 'line' ] ) || $ trace [ 1 ] [ 'file' ] != $ file || $ trace [ 1 ] [ 'line' ] != $ line ) { $ trace [ 0 ] [ 'file' ] = $ file ; // test with: $ trace [ 0 ] [ 'line' ] = $ line ; // \SQLite3::enableExceptions(true|false); } // \SQLite3::exec($invalid_sql); else { unset ( $ trace [ 0 ] [ 'file' ] , $ trace [ 0 ] [ 'line' ] ) ; // otherwise delete them } // Remove the last frame (the one we added for the main script) if it now points to an unknown location (PHP core). $ size = sizeof ( $ trace ) ; if ( ! isset ( $ trace [ $ size - 1 ] [ 'file' ] ) ) { \ array_pop ( $ trace ) ; } return $ trace ; /**
         * TODO: fix wrong stack frames originating from calls to virtual static functions
         *
         * phalcon\mvc\Model::__callStatic()                  [php-phalcon]
         * vokuro\models\Users::findFirstByEmail() # line 27, file: F:\Projekte\phalcon\sample-apps\vokuro\app\library\Auth\Auth.php
         * vokuro\auth\Auth->check()               # line 27, file: F:\Projekte\phalcon\sample-apps\vokuro\app\library\Auth\Auth.php
         */ }
Take a regular PHP stacktrace and create a fixed and more readable Java-like one.

@param  array  $trace           - regular PHP stacktrace
@param  string $file [optional] - name of the file where the stacktrace was generated
@param  int    $line [optional] - line of the file where the stacktrace was generated

@return array - new fixed stacktrace

@example
original stacktrace:
<pre>
require_once()  # line 5,  file: /var/www/phalcon/vokuro/vendor/autoload.php
include_once()  # line 21, file: /var/www/phalcon/vokuro/app/config/loader.php
include()       # line 26, file: /var/www/phalcon/vokuro/public/index.php
{main}
</pre>

new stacktrace:
<pre>
require_once()             [php]
include_once()  # line 5,  file: /var/www/phalcon/vokuro/vendor/autoload.php
include()       # line 21, file: /var/www/phalcon/vokuro/app/config/loader.php
{main}          # line 26, file: /var/www/phalcon/vokuro/public/index.php
</pre>
Take a regular PHP stacktrace and create a fixed and more readable Java - like one .