Skip to content

Commit

Permalink
Fix caller for \DebugBacktraceHtml and \DebugBacktraceConsole
Browse files Browse the repository at this point in the history
  • Loading branch information
steevanb committed Mar 30, 2017
1 parent 5792365 commit b64a8e3
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 17 deletions.
9 changes: 6 additions & 3 deletions DebugBacktrace.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down Expand Up @@ -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
)
) {
Expand Down
3 changes: 3 additions & 0 deletions DebugBacktraceConsole.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@

class DebugBacktraceConsole extends \DebugBacktrace
{
/** @var ?string */
protected static $callerRemoveFile = __FILE__;

/**
* @param OutputInterface $output
* @param int $offset
Expand Down
3 changes: 3 additions & 0 deletions DebugBacktraceHtml.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

class DebugBacktraceHtml extends \DebugBacktrace
{
/** @var ?string */
protected static $callerRemoveFile = __FILE__;

/**
* @param int $offset
* @param int|null $limit
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
19 changes: 9 additions & 10 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit b64a8e3

Please sign in to comment.