function Error::getLastCaller
Same name in other branches
- 8.9.x core/lib/Drupal/Core/Utility/Error.php \Drupal\Core\Utility\Error::getLastCaller()
- 10 core/lib/Drupal/Core/Utility/Error.php \Drupal\Core\Utility\Error::getLastCaller()
- 11.x core/lib/Drupal/Core/Utility/Error.php \Drupal\Core\Utility\Error::getLastCaller()
Gets the last caller from a backtrace.
Parameters
array $backtrace: A standard PHP backtrace. Passed by reference.
Return value
array An associative array with keys 'file', 'line' and 'function'.
5 calls to Error::getLastCaller()
- BrowserHtmlDebugTrait::getTestMethodCaller in core/
tests/ Drupal/ Tests/ BrowserHtmlDebugTrait.php - Retrieves the current calling line in the class under test.
- BrowserTestBase::getTestMethodCaller in core/
tests/ Drupal/ Tests/ BrowserTestBase.php - Retrieves the current calling line in the class under test.
- Error::decodeException in core/
lib/ Drupal/ Core/ Utility/ Error.php - Decodes an exception and retrieves the correct caller.
- ErrorTest::testGetLastCaller in core/
tests/ Drupal/ Tests/ Core/ Utility/ ErrorTest.php - Tests the getLastCaller() method.
- _drupal_error_handler_real in core/
includes/ errors.inc - Provides custom PHP error handling.
File
-
core/
lib/ Drupal/ Core/ Utility/ Error.php, line 112
Class
- Error
- Drupal error utility class.
Namespace
Drupal\Core\UtilityCode
public static function getLastCaller(array &$backtrace) {
// Errors that occur inside PHP internal functions do not generate
// information about file and line. Ignore the ignored functions.
while ($backtrace && !isset($backtrace[0]['line']) || isset($backtrace[1]['function']) && in_array($backtrace[1]['function'], static::$ignoredFunctions)) {
array_shift($backtrace);
}
// The first trace is the call itself.
// It gives us the line and the file of the last call.
$call = $backtrace[0];
// The second call gives us the function where the call originated.
if (isset($backtrace[1])) {
if (isset($backtrace[1]['class'])) {
$call['function'] = $backtrace[1]['class'] . $backtrace[1]['type'] . $backtrace[1]['function'] . '()';
}
else {
$call['function'] = $backtrace[1]['function'] . '()';
}
}
else {
$call['function'] = 'main()';
}
return $call;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.