SimpleStackTrace::traceMethod PHP Method

traceMethod() public method

Captures a stack trace if none given.
public traceMethod ( array $stack = false ) : string
$stack array List of stack frames.
return string Snippet of test report with line number and file.
    public function traceMethod($stack = false)
    {
        $stack = $stack ? $stack : $this->captureTrace();
        foreach ($stack as $frame) {
            if ($this->frameLiesWithinSimpleTestFolder($frame)) {
                continue;
            }
            if ($this->frameMatchesPrefix($frame)) {
                return ' at [' . $frame['file'] . ' line ' . $frame['line'] . ']';
            }
        }
        return '';
    }

Usage Example

Example #1
0
 /**
  *    Uses a stack trace to find the line of an assertion.
  *    @access public
  *    @static
  */
 function getExpectationLine()
 {
     $trace = new SimpleStackTrace(array('expect'));
     return $trace->traceMethod();
 }
All Usage Examples Of SimpleStackTrace::traceMethod