function DebugDump::getCaller

Same name and namespace in other branches
  1. 11.x core/tests/Drupal/TestTools/Extension/Dump/DebugDump.php \Drupal\TestTools\Extension\Dump\DebugDump::getCaller()

Returns information about the caller of dump().

Return value

array{test: \PHPUnit\Framework\Event\Code\TestMethod, file: string|null, line: int|null} Caller information.

1 call to DebugDump::getCaller()
DebugDump::cliHandler in core/tests/Drupal/TestTools/Extension/Dump/DebugDump.php
A CLI handler for \Symfony\Component\VarDumper\VarDumper.

File

core/tests/Drupal/TestTools/Extension/Dump/DebugDump.php, line 160

Class

DebugDump
Drupal's extension for printing dump() output results.

Namespace

Drupal\TestTools\Extension\Dump

Code

private static function getCaller() : array {
  $backtrace = debug_backtrace();
  while (!isset($backtrace[0]['function']) || $backtrace[0]['function'] !== 'dump') {
    array_shift($backtrace);
  }
  $call['file'] = $backtrace[1]['file'] ?? NULL;
  $call['line'] = $backtrace[1]['line'] ?? NULL;
  while (!isset($backtrace[0]['object']) || !$backtrace[0]['object'] instanceof TestCase) {
    array_shift($backtrace);
  }
  $call['test'] = $backtrace[0]['object']->valueObjectForEvents();
  return $call;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.