From b64a8e3abd8134a967b13d0e9de02bb862ee4557 Mon Sep 17 00:00:00 2001 From: Steevan BARBOYON Date: Thu, 30 Mar 2017 15:35:55 +0200 Subject: [PATCH] Fix caller for \DebugBacktraceHtml and \DebugBacktraceConsole --- DebugBacktrace.php | 9 ++++++--- DebugBacktraceConsole.php | 3 +++ DebugBacktraceHtml.php | 3 +++ README.md | 8 ++++---- changelog.md | 19 +++++++++---------- 5 files changed, 25 insertions(+), 17 deletions(-) diff --git a/DebugBacktrace.php b/DebugBacktrace.php index 254ef1d..33b79d0 100644 --- a/DebugBacktrace.php +++ b/DebugBacktrace.php @@ -5,6 +5,9 @@ class DebugBacktrace /** @var bool|string */ protected static $removePathPrefix = true; + /** @var ?string */ + protected static $callerRemoveFile = __FILE__; + /** @param bool|string $remove */ public static function setRemovePathPrefix($remove) { @@ -48,19 +51,19 @@ public static function getBacktraces($offset = 0, $limit = null) /** @return array|null */ public static function getCaller() { - $backtraces = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 7); + $backtraces = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 10); $nextIsCaller = false; $caller = null; foreach ($backtraces as $backtrace) { if ( isset($backtrace['file']) - && strpos($backtrace['file'], __FILE__) !== false + && strpos($backtrace['file'], static::$callerRemoveFile) !== false ) { $nextIsCaller = true; } elseif ( $nextIsCaller && ( - (isset($backtrace['file']) && strpos($backtrace['file'], __FILE__) === false) + (isset($backtrace['file']) && strpos($backtrace['file'], static::$callerRemoveFile) === false) || isset($backtrace['file']) === false ) ) { diff --git a/DebugBacktraceConsole.php b/DebugBacktraceConsole.php index 595271d..9a78a87 100644 --- a/DebugBacktraceConsole.php +++ b/DebugBacktraceConsole.php @@ -5,6 +5,9 @@ class DebugBacktraceConsole extends \DebugBacktrace { + /** @var ?string */ + protected static $callerRemoveFile = __FILE__; + /** * @param OutputInterface $output * @param int $offset diff --git a/DebugBacktraceHtml.php b/DebugBacktraceHtml.php index 0be3dc3..6970634 100644 --- a/DebugBacktraceHtml.php +++ b/DebugBacktraceHtml.php @@ -2,6 +2,9 @@ class DebugBacktraceHtml extends \DebugBacktrace { + /** @var ?string */ + protected static $callerRemoveFile = __FILE__; + /** * @param int $offset * @param int|null $limit diff --git a/README.md b/README.md index 1d4de2e..99cbcd9 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,8 @@ -[![version](https://img.shields.io/badge/version-2.0.0-green.svg)](https://github.com/steevanb/php-backtrace/tree/2.0.0) -[![php](https://img.shields.io/badge/php->=5.4-blue.svg)](http://php.net) -![Lines](https://img.shields.io/badge/code%20lines-509-green.svg) +[![version](https://img.shields.io/badge/version-2.0.1-green.svg)](https://github.com/steevanb/php-backtrace/tree/2.0.1) +[![php](https://img.shields.io/badge/php-^5.4%20||%20^7.0-blue.svg)](http://php.net) +![Lines](https://img.shields.io/badge/code%20lines-519-green.svg) ![Total Downloads](https://poser.pugx.org/steevanb/php-backtrace/downloads) -[![SensionLabsInsight](https://img.shields.io/badge/SensionLabsInsight-platinum-brightgreen.svg)](https://insight.sensiolabs.com/projects/2b6dd6a0-ef48-4b5b-ba13-e825e0841be3/analyses/12) +[![SensionLabsInsight](https://img.shields.io/badge/SensionLabsInsight-platinum-brightgreen.svg)](https://insight.sensiolabs.com/projects/2b6dd6a0-ef48-4b5b-ba13-e825e0841be3/analyses/15) [![Scrutinizer](https://scrutinizer-ci.com/g/steevanb/php-backtrace/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/steevanb/php-backtrace/) php-backtrace diff --git a/changelog.md b/changelog.md index 93f785c..ec3145f 100644 --- a/changelog.md +++ b/changelog.md @@ -1,30 +1,29 @@ -2.0.0 (2016-12-31) ------------------- +### [2.0.1](../../compare/2.0.0...2.0.1) (2017-03-30) + +- Fix caller for \DebugBacktraceHtml and \DebugBacktraceConsole + +### [2.0.0](../../compare/1.1.1...2.0.0) (2016-12-31) - Reverse backtraces : first shown is first call (debug_backtrace() show last call in first) - Split \DumpBacktrace in 3 classes : \DebugBacktrace, \DebugBacktraceHtml and \DebugBacktraceConsole - Add dump for symfony/console applications -1.1.1 (2016-10-12) ------------------- +### [1.1.1](../../compare/1.1.0...1.1.1) (2016-10-12) - Fix file not found errors - Fix eval()'d code in file path - Update backtrace.png -1.1.0 (2016-10-10) ------------------- +### [1.1.0](../../compare/1.0.1...1.1.0) (2016-10-10) - Add eDump() and getDump() -1.0.1 (2016-08-16) ------------------- +### [1.0.1](../../compare/1.0.0...1.0.1) (2016-08-16) - Fix (Unknow call) when function is called - Add preview only when available - Show \Closure in File::Line column, instead of (Unknow file)::(Uknow line) -1.0.0 (2016-08-02) ------------------- +### 1.0.0 (2016-08-02) - Create \DumpBacktrace class