/usr/share/php/Nette/Diagnostics/Helpers.php is in php-nette 2.1.0-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 | <?php
/**
* This file is part of the Nette Framework (http://nette.org)
* Copyright (c) 2004 David Grudl (http://davidgrudl.com)
*/
namespace Nette\Diagnostics;
use Nette;
/**
* Rendering helpers for Debugger.
*
* @author David Grudl
*/
class Helpers
{
/**
* Returns link to editor.
* @return Nette\Utils\Html
*/
public static function editorLink($file, $line)
{
if (Debugger::$editor && is_file($file)) {
$dir = dirname(strtr($file, '/', DIRECTORY_SEPARATOR));
$base = isset($_SERVER['SCRIPT_FILENAME']) ? dirname(dirname(strtr($_SERVER['SCRIPT_FILENAME'], '/', DIRECTORY_SEPARATOR))) : dirname($dir);
if (substr($dir, 0, strlen($base)) === $base) {
$dir = '...' . substr($dir, strlen($base));
}
return Nette\Utils\Html::el('a')
->href(strtr(Debugger::$editor, array('%file' => rawurlencode($file), '%line' => $line)))
->title("$file:$line")
->setHtml(htmlSpecialChars(rtrim($dir, DIRECTORY_SEPARATOR), ENT_IGNORE) . DIRECTORY_SEPARATOR . '<b>' . htmlSpecialChars(basename($file), ENT_IGNORE) . '</b>' . ($line ? ":$line" : ''));
} else {
return Nette\Utils\Html::el('span')->setText($file . ($line ? ":$line" : ''));
}
}
public static function findTrace(array $trace, $method, & $index = NULL)
{
$m = explode('::', $method);
foreach ($trace as $i => $item) {
if (isset($item['function']) && $item['function'] === end($m)
&& isset($item['class']) === isset($m[1])
&& (!isset($item['class']) || $item['class'] === $m[0] || $m[0] === '*' || is_subclass_of($item['class'], $m[0]))
) {
$index = $i;
return $item;
}
}
}
public static function fixStack($exception)
{
if (function_exists('xdebug_get_function_stack')) {
$stack = array();
foreach (array_slice(array_reverse(xdebug_get_function_stack()), 2, -1) as $row) {
$frame = array(
'file' => $row['file'],
'line' => $row['line'],
'function' => isset($row['function']) ? $row['function'] : '*unknown*',
'args' => array(),
);
if (!empty($row['class'])) {
$frame['type'] = isset($row['type']) && $row['type'] === 'dynamic' ? '->' : '::';
$frame['class'] = $row['class'];
}
$stack[] = $frame;
}
$ref = new \ReflectionProperty('Exception', 'trace');
$ref->setAccessible(TRUE);
$ref->setValue($exception, $stack);
}
return $exception;
}
/** @deprecated */
public static function htmlDump($var)
{
trigger_error(__METHOD__ . '() is deprecated; use Nette\Diagnostics\Dumper::toHtml() instead.', E_USER_DEPRECATED);
return Dumper::toHtml($var);
}
/** @deprecated */
public static function clickableDump($var)
{
trigger_error(__METHOD__ . '() is deprecated; use Nette\Diagnostics\Dumper::toHtml() instead.', E_USER_DEPRECATED);
return Dumper::toHtml($var);
}
/** @deprecated */
public static function textDump($var)
{
trigger_error(__METHOD__ . '() is deprecated; use Nette\Diagnostics\Dumper::toText() instead.', E_USER_DEPRECATED);
return Dumper::toText($var);
}
}
|