Commit ea82bb3b authored by catch's avatar catch

Issue #2665232 by dawehner: Add the line to Error::formatBacktrace()

parent b1cd7326
......@@ -180,7 +180,12 @@ public static function formatBacktrace(array $backtrace) {
}
}
$return .= $call['function'] . '(' . implode(', ', $call['args']) . ")\n";
$line = '';
if (isset($trace['line'])) {
$line = " (Line: {$trace['line']})";
}
$return .= $call['function'] . '(' . implode(', ', $call['args']) . ")$line\n";
}
return $return;
......
......@@ -89,28 +89,28 @@ public function providerTestFormatBacktrace() {
$data = array();
// Test with no function, main should be in the backtrace.
$data[] = array(array($this->createBacktraceItem(NULL, NULL)), "main()\n");
$data[] = array(array($this->createBacktraceItem(NULL, NULL)), "main() (Line: 10)\n");
$base = array($this->createBacktraceItem());
$data[] = array($base, "test_function()\n");
$data[] = array($base, "test_function() (Line: 10)\n");
// Add a second item.
$second_item = $base;
$second_item[] = $this->createBacktraceItem('test_function_2');
$data[] = array($second_item, "test_function()\ntest_function_2()\n");
$data[] = array($second_item, "test_function() (Line: 10)\ntest_function_2() (Line: 10)\n");
// Add a second item, with a class.
$second_item_class = $base;
$second_item_class[] = $this->createBacktraceItem('test_function_2', 'TestClass');
$data[] = array($second_item_class, "test_function()\nTestClass->test_function_2()\n");
$data[] = array($second_item_class, "test_function() (Line: 10)\nTestClass->test_function_2() (Line: 10)\n");
// Add a second item, with a class.
$second_item_args = $base;
$second_item_args[] = $this->createBacktraceItem('test_function_2', NULL, array('string', 10, new \stdClass()));
$data[] = array($second_item_args, "test_function()\ntest_function_2('string', 10, Object)\n");
$data[] = array($second_item_args, "test_function() (Line: 10)\ntest_function_2('string', 10, Object) (Line: 10)\n");
return $data;
}
......@@ -124,14 +124,16 @@ public function providerTestFormatBacktrace() {
* (optional) The class to use in the backtrace item.
* @param array $args
* (optional) An array of function arguments to add to the backtrace item.
* @param int $line
* (optional) The line where the function was called.
*
* @return array
* A backtrace array item.
*/
protected function createBacktraceItem($function = 'test_function', $class = NULL, array $args = array()) {
protected function createBacktraceItem($function = 'test_function', $class = NULL, array $args = array(), $line = 10) {
$backtrace = array(
'file' => 'test_file',
'line' => 10,
'line' => $line,
'function' => $function,
'args' => array(),
);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment