function ErrorTest::createBacktraceItem

Same name in other branches
  1. 8.9.x core/tests/Drupal/Tests/Core/Utility/ErrorTest.php \Drupal\Tests\Core\Utility\ErrorTest::createBacktraceItem()
  2. 10 core/tests/Drupal/Tests/Core/Utility/ErrorTest.php \Drupal\Tests\Core\Utility\ErrorTest::createBacktraceItem()
  3. 11.x 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 $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 127

Class

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

Namespace

Drupal\Tests\Core\Utility

Code

protected function createBacktraceItem($function = 'test_function', $class = NULL, array $args = [], $line = 10) {
    $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.