Eloquent\Phony\Assertion\Exception\AssertionException::tracePhonyCall PHP Метод

tracePhonyCall() публичный статический Метод

Find the Phony entry point call in a stack trace.
public static tracePhonyCall ( array $trace ) : array | null
$trace array The stack trace.
Результат array | null The call, or null if unable to determine the entry point.
    public static function tracePhonyCall(array $trace)
    {
        $prefix = 'Eloquent\\Phony\\';
        for ($i = count($trace) - 1; $i >= 0; --$i) {
            $entry = $trace[$i];
            if (isset($entry['class'])) {
                if (0 === strpos($entry['class'], $prefix)) {
                    return $entry;
                }
            } elseif (0 === strpos($entry['function'], $prefix)) {
                return $entry;
            }
        }
        return null;
    }

Usage Example

 /**
  * Create a new assertion failure exception.
  *
  * @param string $description The failure description.
  *
  * @throws Exception If this recorder throws exceptions.
  */
 public function createFailure($description)
 {
     $flags = 0;
     if (defined('DEBUG_BACKTRACE_IGNORE_ARGS')) {
         $flags = DEBUG_BACKTRACE_IGNORE_ARGS;
     }
     $call = AssertionException::tracePhonyCall(debug_backtrace($flags));
     if ($call && isset($call['file']) && isset($call['line'])) {
         $description .= PHP_EOL . "at [{$call['file']} line {$call['line']}]";
     }
     $this->simpletestContext->getReporter()->paintFail(preg_replace('/(\\R)/', '$1   ', $description));
 }