function ErrorTest::createBacktraceItem

Same name in other branches
  1. 9 core/tests/Drupal/Tests/Core/Utility/ErrorTest.php \Drupal\Tests\Core\Utility\ErrorTest::createBacktraceItem()
  2. 8.9.x core/tests/Drupal/Tests/Core/Utility/ErrorTest.php \Drupal\Tests\Core\Utility\ErrorTest::createBacktraceItem()
  3. 10 core/tests/Drupal/Tests/Core/Utility/ErrorTest.php \Drupal\Tests\Core\Utility\ErrorTest::createBacktraceItem()

Creates a mock backtrace item.

Parameters

string|null $function: (optional) The function name to use in the backtrace item.

string|null $class: (optional) The class to use in the backtrace item.

array $args: (optional) An array of function arguments to add to the backtrace item.

int $line: (optional) The line where the function was called.

Return value

array A backtrace array item.

2 calls to ErrorTest::createBacktraceItem()
ErrorTest::providerTestFormatBacktrace in core/tests/Drupal/Tests/Core/Utility/ErrorTest.php
Data provider for testFormatBacktrace.
ErrorTest::providerTestGetLastCaller in core/tests/Drupal/Tests/Core/Utility/ErrorTest.php
Data provider for testGetLastCaller.

File

core/tests/Drupal/Tests/Core/Utility/ErrorTest.php, line 129

Class

ErrorTest
@coversDefaultClass \Drupal\Core\Utility\Error @group Utility

Namespace

Drupal\Tests\Core\Utility

Code

protected static function createBacktraceItem(?string $function = 'test_function', ?string $class = NULL, array $args = [], int $line = 10) : array {
    $backtrace = [
        'file' => 'test_file',
        'line' => $line,
        'function' => $function,
        'args' => [],
    ];
    if (isset($class)) {
        $backtrace['class'] = $class;
        $backtrace['type'] = '->';
    }
    if (!empty($args)) {
        $backtrace['args'] = $args;
    }
    return $backtrace;
}

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