本文整理汇总了PHP中Tracy\Helpers::findTrace方法的典型用法代码示例。如果您正苦于以下问题:PHP Helpers::findTrace方法的具体用法?PHP Helpers::findTrace怎么用?PHP Helpers::findTrace使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Tracy\Helpers
的用法示例。
在下文中一共展示了Helpers::findTrace方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: sdump
/**
* Dumps information about a variable in readable format.
*
* @param mixed $var to dump
* @param null $title
* @return void
*/
public static function sdump($var, $title = null)
{
if (!Debugger::$productionMode) {
self::initialize();
$trace = debug_backtrace(DEBUG_BACKTRACE_PROVIDE_OBJECT);
$item = Helpers::findTrace($trace, 'sdump', $index) ?: Helpers::findTrace($trace, __CLASS__ . '::sdump', $index);
if (isset($item['file'], $item['line']) && is_file($item['file'])) {
$lines = file($item['file']);
preg_match('#sdump\\((.*)\\)#', $lines[$item['line'] - 1], $matches);
$params = isset($matches[1]) ? htmlspecialchars($matches[1]) : false;
if ($params) {
preg_match('#array\\((.*)\\)#', $params, $matches2);
$params = isset($matches2[1]) ? $matches2[1] : $params;
$params = explode(',', $params);
}
$dumpParams = isset($matches[0]) ? "{$matches['0']};" : '';
$location = Debugger::$showLocation ? "<br>" . Helpers::editorLink($item['file'], $item['line']) : false;
}
$tiMethod = $trace[$index + 1];
$dumpTitle = isset($tiMethod['class']) ? $tiMethod['class'] . $tiMethod['type'] . $tiMethod['function'] . '(); ' : $tiMethod['function'] . $title;
$dumpObject = self::$dumpObject && isset($tiMethod['object']) ? Dumper::toHtml($tiMethod['object']) : '';
$dump = (isset($dumpParams) ? "<b>{$dumpParams}</b> " : '') . (isset($location) ? $location : '') . $dumpObject;
if (self::$traceMode) {
for ($i = 0; $i <= $index; $i++) {
array_shift($trace);
}
$dump .= "<br/>" . self::showTraceSimple($trace);
}
$dump .= Dumper::toHtml($var);
self::$dumps = array('title' => $dumpTitle, 'dump' => $dump);
self::addToDumpPanel($dump, $dumpTitle);
}
}
示例2: log
public function log($message, $priority = self::INFO)
{
$parent = parent::log($message, $priority);
$checked = array(self::CRITICAL, self::ERROR);
if (defined('self::EXCEPTION')) {
$checked[] = self::EXCEPTION;
}
if (in_array($priority, $checked, TRUE)) {
$index = NULL;
$trace = debug_backtrace(FALSE);
if (!Tracy\Helpers::findTrace($trace, 'Tracy\\Debugger::log', $index)) {
if (!Tracy\Helpers::findTrace($trace, 'Nette\\Diagnostics\\Debugger::log', $index)) {
Tracy\Helpers::findTrace($trace, 'log', $index);
}
}
$errorTrace = $trace[$index + 1];
//get trace for _errorHandler call
$exceptionTrace = $trace[$index];
//get trace for _exception or ::log call
//if()
$exception = NULL;
if (isset($errorTrace['args']) && count($errorTrace['args']) == 5) {
$exception = new \ErrorException($errorTrace['args'][1], 0, $errorTrace['args'][0], $errorTrace['args'][2], $errorTrace['args'][3]);
} elseif (!empty($exceptionTrace['args']) && !empty($exceptionTrace['args'][0]) && $exceptionTrace['args'][0] instanceof \Exception) {
$exception = $exceptionTrace['args'][0];
}
if ($exception) {
$error = Consumerr::addError($exception);
if ($error && is_array($message)) {
$error->addData('file', Tracy\Debugger::$logDirectory . '/' . substr($message[3], 5));
}
}
}
return $parent;
}
示例3: initialize
public static function initialize()
{
$blueScreen = Tracy\Debugger::getBlueScreen();
if (preg_match('#(.+)/Bridges/Framework$#', strtr(__DIR__, '\\', '/'), $m)) {
if (preg_match('#(.+)/nette/bootstrap/src$#', $m[1], $m2)) {
$blueScreen->collapsePaths[] = "{$m2['1']}/nette";
$blueScreen->collapsePaths[] = "{$m2['1']}/latte";
} else {
$blueScreen->collapsePaths[] = $m[1];
}
}
if (class_exists('Nette\\Framework')) {
$bar = Tracy\Debugger::getBar();
$bar->info[] = $blueScreen->info[] = 'Nette Framework ' . Nette\Framework::VERSION . ' (' . Nette\Framework::REVISION . ')';
}
$blueScreen->addPanel(function ($e) {
if ($e instanceof Latte\CompileException) {
return array('tab' => 'Template', 'panel' => '<p>' . (is_file($e->sourceName) ? '<b>File:</b> ' . Helpers::editorLink($e->sourceName, $e->sourceLine) : htmlspecialchars($e->sourceName)) . '</p>' . ($e->sourceCode ? '<pre>' . BlueScreen::highlightLine(htmlspecialchars($e->sourceCode), $e->sourceLine) . '</pre>' : ''));
} elseif ($e instanceof Nette\Neon\Exception && preg_match('#line (\\d+)#', $e->getMessage(), $m)) {
if ($item = Helpers::findTrace($e->getTrace(), 'Nette\\DI\\Config\\Adapters\\NeonAdapter::load')) {
return array('tab' => 'NEON', 'panel' => '<p><b>File:</b> ' . Helpers::editorLink($item['args'][0], $m[1]) . '</p>' . BlueScreen::highlightFile($item['args'][0], $m[1]));
} elseif ($item = Helpers::findTrace($e->getTrace(), 'Nette\\Neon\\Decoder::decode')) {
return array('tab' => 'NEON', 'panel' => BlueScreen::highlightPhp($item['args'][0], $m[1]));
}
}
});
}
示例4: renderException
public static function renderException($e)
{
if (!$e instanceof \PDOException) {
return;
}
if (isset($e->queryString)) {
$sql = $e->queryString;
} elseif ($item = Tracy\Helpers::findTrace($e->getTrace(), 'PDO::prepare')) {
$sql = $item['args'][0];
}
return isset($sql) ? ['tab' => 'SQL', 'panel' => Helpers::dumpSql($sql)] : NULL;
}
示例5: initialize
public static function initialize()
{
$blueScreen = Tracy\Debugger::getBlueScreen();
if (class_exists('Nette\\Framework')) {
$version = Framework::VERSION . (Framework::REVISION ? ' (' . Framework::REVISION . ')' : '');
Tracy\Debugger::getBar()->getPanel('Tracy:info')->data['Nette Framework'] = $version;
$blueScreen->info[] = "Nette Framework {$version}";
}
$blueScreen->addPanel(function ($e) {
if ($e instanceof Latte\CompileException) {
return ['tab' => 'Template', 'panel' => (@is_file($e->sourceName) ? '<p><b>File:</b> ' . Helpers::editorLink($e->sourceName, $e->sourceLine) . '</p>' : '') . '<pre>' . BlueScreen::highlightLine(htmlspecialchars($e->sourceCode, ENT_IGNORE, 'UTF-8'), $e->sourceLine) . '</pre>'];
}
});
$blueScreen->addPanel(function ($e) {
if ($e instanceof Nette\Neon\Exception && preg_match('#line (\\d+)#', $e->getMessage(), $m) && ($trace = Helpers::findTrace($e->getTrace(), 'Nette\\Neon\\Decoder::decode'))) {
return ['tab' => 'NEON', 'panel' => ($trace2 = Helpers::findTrace($e->getTrace(), 'Nette\\DI\\Config\\Adapters\\NeonAdapter::load')) ? '<p><b>File:</b> ' . Helpers::editorLink($trace2['args'][0], $m[1]) . '</p>' . BlueScreen::highlightFile($trace2['args'][0], $m[1]) : BlueScreen::highlightPhp($trace['args'][0], $m[1])];
}
});
}
示例6: initialize
public static function initialize()
{
$bar = Tracy\Debugger::getBar();
$bar->info[] = 'Nette Framework ' . Nette\Framework::VERSION . ' (' . substr(Nette\Framework::REVISION, 8) . ')';
$blueScreen = Tracy\Debugger::getBlueScreen();
$blueScreen->collapsePaths[] = dirname(dirname(__DIR__));
$blueScreen->info[] = 'Nette Framework ' . Nette\Framework::VERSION . ' (revision ' . Nette\Framework::REVISION . ')';
$blueScreen->addPanel(function ($e) {
if ($e instanceof Latte\CompileException) {
return array('tab' => 'Template', 'panel' => '<p>' . (is_file($e->sourceName) ? '<b>File:</b> ' . Helpers::editorLink($e->sourceName, $e->sourceLine) : htmlspecialchars($e->sourceName)) . '</p>' . ($e->sourceCode ? '<pre>' . BlueScreen::highlightLine(htmlspecialchars($e->sourceCode), $e->sourceLine) . '</pre>' : ''));
} elseif ($e instanceof Nette\Utils\NeonException && preg_match('#line (\\d+)#', $e->getMessage(), $m)) {
if ($item = Helpers::findTrace($e->getTrace(), 'Nette\\DI\\Config\\Adapters\\NeonAdapter::load')) {
return array('tab' => 'NEON', 'panel' => '<p><b>File:</b> ' . Helpers::editorLink($item['args'][0], $m[1]) . '</p>' . BlueScreen::highlightFile($item['args'][0], $m[1]));
} elseif ($item = Helpers::findTrace($e->getTrace(), 'Nette\\Utils\\Neon::decode')) {
return array('tab' => 'NEON', 'panel' => BlueScreen::highlightPhp($item['args'][0], $m[1]));
}
}
});
}
示例7: errorHandler
/**
* Handler to catch warnings and notices.
* @return bool FALSE to call normal error handler, NULL otherwise
* @throws ErrorException
* @internal
*/
public static function errorHandler($severity, $message, $file, $line, $context)
{
if (self::$scream) {
error_reporting(E_ALL);
}
if ($severity === E_RECOVERABLE_ERROR || $severity === E_USER_ERROR) {
if (Helpers::findTrace(debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS), '*::__toString')) {
$previous = isset($context['e']) && $context['e'] instanceof \Exception ? $context['e'] : NULL;
$e = new ErrorException($message, 0, $severity, $file, $line, $previous);
$e->context = $context;
self::exceptionHandler($e);
}
$e = new ErrorException($message, 0, $severity, $file, $line);
$e->context = $context;
throw $e;
} elseif (($severity & error_reporting()) !== $severity) {
return FALSE;
// calls normal error handler to fill-in error_get_last()
} elseif (self::$productionMode && ($severity & self::$logSeverity) === $severity) {
$e = new ErrorException($message, 0, $severity, $file, $line);
$e->context = $context;
try {
self::log($e, self::ERROR);
} catch (\Exception $foo) {
}
return NULL;
} elseif (!self::$productionMode && !isset($_GET['_tracy_skip_error']) && (is_bool(self::$strictMode) ? self::$strictMode : (self::$strictMode & $severity) === $severity)) {
$e = new ErrorException($message, 0, $severity, $file, $line);
$e->context = $context;
$e->skippable = TRUE;
self::exceptionHandler($e);
}
$message = 'PHP ' . Helpers::errorTypeToString($severity) . ": {$message}";
$count =& self::getBar()->getPanel('Tracy:errors')->data["{$file}|{$line}|{$message}"];
if ($count++) {
// repeated error
return NULL;
} elseif (self::$productionMode) {
try {
self::log("{$message} in {$file}:{$line}", self::ERROR);
} catch (\Exception $foo) {
}
return NULL;
} else {
self::fireLog(new ErrorException($message, 0, $severity, $file, $line));
return self::isHtmlMode() ? NULL : FALSE;
// FALSE calls normal error handler
}
}
示例8: renderException
public static function renderException($e = NULL)
{
if (!$e instanceof InvalidResourceException || !($previous = $e->getPrevious())) {
return NULL;
}
$previous = $previous->getPrevious();
if (!$previous instanceof Yaml\Exception\ParseException) {
return NULL;
}
$method = 'Symfony\\Component\\Translation\\Loader\\YamlFileLoader::load';
if ($call = Helpers::findTrace($e->getPrevious()->getTrace(), $method)) {
return array('tab' => 'YAML dictionary', 'panel' => '<p><b>File:</b> ' . self::editorLink($call['args'][0], $previous->getParsedLine()) . '</p>' . ($previous->getParsedLine() ? BlueScreen::highlightFile($call['args'][0], $previous->getParsedLine()) : '') . '<p>' . $previous->getMessage() . ' </p>');
}
}
示例9: resolveExceptionTable
/**
* @param \Exception|\Throwable $e
* @return string|NULL
*/
private static function resolveExceptionTable($e)
{
if (!$e instanceof Doctrine\DBAL\DBALException) {
return NULL;
}
if ($caused = Tracy\Helpers::findTrace($e->getTrace(), 'Doctrine\\DBAL\\DBALException::driverExceptionDuringQuery')) {
if (preg_match('~(?:INSERT|UPDATE|REPLACE)(?:[A-Z_\\s]*)`?([^\\s`]+)`?\\s*~', is_string($caused['args'][1]) ? $caused['args'][1] : $caused['args'][2], $m)) {
return $m[1];
}
}
return NULL;
}
示例10: renderException
/**
* @param \Exception|\Throwable $e
* @param \Nette\DI\Container $dic
* @return array
*/
public static function renderException($e, Nette\DI\Container $dic)
{
if ($e instanceof AnnotationException) {
if ($dump = self::highlightAnnotationLine($e)) {
return ['tab' => 'Annotation', 'panel' => $dump];
}
} elseif ($e instanceof Doctrine\ORM\Mapping\MappingException) {
if ($invalidEntity = Strings::match($e->getMessage(), '~^Class "([\\S]+)" .*? is not .*? valid~i')) {
$refl = Nette\Reflection\ClassType::from($invalidEntity[1]);
$file = $refl->getFileName();
$errorLine = $refl->getStartLine();
return ['tab' => 'Invalid entity', 'panel' => '<p><b>File:</b> ' . self::editorLink($file, $errorLine) . '</p>' . BlueScreen::highlightFile($file, $errorLine)];
}
} elseif ($e instanceof Doctrine\DBAL\Schema\SchemaException && $dic && ($em = $dic->getByType('Kdyby\\Doctrine\\EntityManager', FALSE))) {
/** @var Kdyby\Doctrine\EntityManager $em */
if ($invalidTable = Strings::match($e->getMessage(), '~table \'(.*?)\'~i')) {
foreach ($em->getMetadataFactory()->getAllMetadata() as $class) {
/** @var Kdyby\Doctrine\Mapping\ClassMetadata $class */
if ($class->getTableName() === $invalidTable[1]) {
$refl = $class->getReflectionClass();
break;
}
}
if (!isset($refl)) {
return NULL;
}
$file = $refl->getFileName();
$errorLine = $refl->getStartLine();
return ['tab' => 'Invalid schema', 'panel' => '<p><b>File:</b> ' . self::editorLink($file, $errorLine) . '</p>' . BlueScreen::highlightFile($file, $errorLine)];
}
} elseif ($e instanceof Kdyby\Doctrine\DBALException && $e->query) {
return ['tab' => 'SQL', 'panel' => self::highlightQuery(static::formatQuery($e->query, $e->params, []))];
} elseif ($e instanceof Doctrine\DBAL\Exception\DriverException) {
if (($prev = $e->getPrevious()) && ($item = Helpers::findTrace($e->getTrace(), 'Doctrine\\DBAL\\DBALException::driverExceptionDuringQuery'))) {
/** @var \Doctrine\DBAL\Driver $driver */
$driver = $item['args'][0];
$params = isset($item['args'][3]) ? $item['args'][3] : [];
return ['tab' => 'SQL', 'panel' => self::highlightQuery(static::formatQuery($item['args'][2], $params, [], $driver->getDatabasePlatform()))];
}
} elseif ($e instanceof Doctrine\ORM\Query\QueryException) {
if (($prev = $e->getPrevious()) && preg_match('~^(SELECT|INSERT|UPDATE|DELETE)\\s+.*~i', $prev->getMessage())) {
return ['tab' => 'DQL', 'panel' => self::highlightQuery(static::formatQuery($prev->getMessage(), [], []))];
}
} elseif ($e instanceof \PDOException) {
$params = [];
if (isset($e->queryString)) {
$sql = $e->queryString;
} elseif ($item = Helpers::findTrace($e->getTrace(), 'Doctrine\\DBAL\\Connection::executeQuery')) {
$sql = $item['args'][0];
$params = $item['args'][1];
} elseif ($item = Helpers::findTrace($e->getTrace(), 'PDO::query')) {
$sql = $item['args'][0];
} elseif ($item = Helpers::findTrace($e->getTrace(), 'PDO::prepare')) {
$sql = $item['args'][0];
}
return isset($sql) ? ['tab' => 'SQL', 'panel' => self::highlightQuery(static::formatQuery($sql, $params, []))] : NULL;
}
return NULL;
}
示例11: _errorHandler
/**
* Handler to catch warnings and notices.
* @param int level of the error raised
* @param string error message
* @param string file that the error was raised in
* @param int line number the error was raised at
* @param array an array of variables that existed in the scope the error was triggered in
* @return bool FALSE to call normal error handler, NULL otherwise
* @throws ErrorException
* @internal
*/
public static function _errorHandler($severity, $message, $file, $line, $context)
{
if (self::$scream) {
error_reporting(E_ALL | E_STRICT);
}
if ($severity === E_RECOVERABLE_ERROR || $severity === E_USER_ERROR) {
if (Helpers::findTrace(debug_backtrace(PHP_VERSION_ID >= 50306 ? DEBUG_BACKTRACE_IGNORE_ARGS : FALSE), '*::__toString')) {
$previous = isset($context['e']) && $context['e'] instanceof \Exception ? $context['e'] : NULL;
$e = new ErrorException($message, 0, $severity, $file, $line, $previous);
$e->context = $context;
self::_exceptionHandler($e);
}
$e = new ErrorException($message, 0, $severity, $file, $line);
$e->context = $context;
throw $e;
} elseif (($severity & error_reporting()) !== $severity) {
return FALSE;
// calls normal error handler to fill-in error_get_last()
} elseif (self::$productionMode && ($severity & self::$logSeverity) === $severity) {
$e = new ErrorException($message, 0, $severity, $file, $line);
$e->context = $context;
self::log($e, self::ERROR);
return NULL;
} elseif (!self::$productionMode && (is_bool(self::$strictMode) ? self::$strictMode : (self::$strictMode & $severity) === $severity)) {
$e = new ErrorException($message, 0, $severity, $file, $line);
$e->context = $context;
self::_exceptionHandler($e);
}
$message = 'PHP ' . (isset(self::$errorTypes[$severity]) ? self::$errorTypes[$severity] : 'Unknown error') . ": {$message}";
$count =& self::getBar()->getPanel(__CLASS__ . ':errors')->data["{$file}|{$line}|{$message}"];
if ($count++) {
// repeated error
return NULL;
} elseif (self::$productionMode) {
self::log("{$message} in {$file}:{$line}", self::ERROR);
return NULL;
} else {
self::fireLog(new ErrorException($message, 0, $severity, $file, $line));
return self::isHtmlMode() ? NULL : FALSE;
// FALSE calls normal error handler
}
}