本文整理汇总了PHP中Tracy\Dumper类的典型用法代码示例。如果您正苦于以下问题:PHP Dumper类的具体用法?PHP Dumper怎么用?PHP Dumper使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Dumper类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: decode
/**
* Parses a signed_request and validates the signature.
*
* @param string $signedRequest A signed token
* @param string $appSecret
*
* @return array The payload inside it or null if the sig is wrong
*/
public static function decode($signedRequest, $appSecret)
{
if (!$signedRequest || strpos($signedRequest, '.') === false) {
Debugger::log('Signed request is invalid! ' . json_encode($signedRequest), 'facebook');
return NULL;
}
list($encoded_sig, $payload) = explode('.', $signedRequest, 2);
// decode the data
$sig = Helpers::base64UrlDecode($encoded_sig);
$data = Json::decode(Helpers::base64UrlDecode($payload), Json::FORCE_ARRAY);
if (!isset($data['algorithm']) || strtoupper($data['algorithm']) !== Configuration::SIGNED_REQUEST_ALGORITHM) {
Debugger::log("Unknown algorithm '{$data['algorithm']}', expected " . Configuration::SIGNED_REQUEST_ALGORITHM, 'facebook');
return NULL;
}
// check sig
$expected_sig = hash_hmac('sha256', $payload, $appSecret, $raw = TRUE);
if (strlen($expected_sig) !== strlen($sig)) {
Debugger::log('Bad Signed JSON signature! Expected ' . Dumper::toText($expected_sig) . ', but given ' . Dumper::toText($sig), 'facebook');
return NULL;
}
$result = 0;
for ($i = 0; $i < strlen($expected_sig); $i++) {
$result |= ord($expected_sig[$i]) ^ ord($sig[$i]);
}
if ($result !== 0) {
Debugger::log('Bad Signed JSON signature! Expected ' . Dumper::toText($expected_sig) . ', but given ' . Dumper::toText($sig), 'facebook');
return NULL;
}
return $data;
}
示例2: 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);
}
}
示例3: getInfo
/**
* e.g. SQL explain
*
* @return NULL|Html|string
*/
public function getInfo()
{
$info = $this->response;
unset($info['hits']['hits']);
$html = Dumper::toHtml($info, [Dumper::COLLAPSE => TRUE, Dumper::TRUNCATE => 50]);
return Html::el()->setHtml($html);
}
示例4: renderHtml
private function renderHtml()
{
$res = '<style>code, pre {white-space:nowrap} a {text-decoration:none} pre {color:gray;display:inline} big {color:red}</style><code>';
foreach ($this->list as $item) {
$res .= Helpers::editorLink($item[0], $item[1]) . ' ' . str_replace(self::BOM, '<big>BOM</big>', Dumper::toHtml($item[2])) . "<br>\n";
}
return $res . '</code>';
}
示例5: render
/**
* @internal
* @param \Exception|NULL $e
* @return string[]|NULL
*/
public static function render(\Exception $e = NULL)
{
if (!$e instanceof \Nella\Tracy\DebugInfoException) {
return NULL;
// skip
}
return ['tab' => 'Exception Debug Info', 'panel' => \Tracy\Dumper::toHtml($e->__debugInfo())];
}
示例6: getResult
/**
* @return Html|string
*/
public function getResult()
{
$data = iterator_to_array($this->result);
foreach ($data as &$row) {
$row = $this->rowToArray($row);
}
$html = Dumper::toHtml($data, [Dumper::COLLAPSE => TRUE]);
return Html::el()->setHtml($html);
}
示例7: doDump
protected function doDump($data)
{
if (!class_exists('\\Tracy\\Dumper')) {
return '';
}
ob_start();
Dumper::dump($data, $this->options);
return ob_get_clean();
}
示例8: processQuery
/**
* @param array
* @return string
*/
protected function processQuery(array $query)
{
$s = '';
list($sql, $params, $time) = $query;
$s .= '<tr><td>' . sprintf('%0.3f', $time * 1000);
$s .= '</td><td class="nette-Doctrine2Panel-sql">' . Helpers::dumpSql($sql);
$s .= '</td><td>' . Dumper::toHtml($params) . '</tr>';
return $s;
}
示例9: initializePanel
public static function initializePanel(Nette\Application\Application $application)
{
Tracy\Debugger::getBlueScreen()->addPanel(function ($e) use ($application) {
return $e ? NULL : array(
'tab' => 'Nette Application',
'panel' => '<h3>Requests</h3>' . Tracy\Dumper::toHtml($application->getRequests())
. '<h3>Presenter</h3>' . Tracy\Dumper::toHtml($application->getPresenter()),
);
});
}
示例10: getPanel
/**
* Renders HTML code for custom panel.
* @return string
*/
function getPanel()
{
if (!$this->messages) {
return NULL;
}
ob_start();
$esc = callback('Nette\\Templating\\Helpers::escapeHtml');
$click = class_exists('\\Tracy\\Dumper') ? function ($o, $c = FALSE) {
return \Tracy\Dumper::toHtml($o, array('collapse' => $c));
} : callback('\\Tracy\\Helpers::clickableDump');
require __DIR__ . '/panel.phtml';
return ob_get_clean();
}
示例11: renderHtml
private function renderHtml()
{
$res = '<style>code, pre {white-space:nowrap} a {text-decoration:none} pre {color:gray;display:inline} big {color:red}</style><code>';
foreach ($this->list as $item) {
$stack = array();
foreach (array_slice($item[3], 1) as $t) {
$t += array('class' => '', 'type' => '', 'function' => '');
$stack[] = "{$t['class']}{$t['type']}{$t['function']}()" . (isset($t['file'], $t['line']) ? ' in ' . basename($t['file']) . ":{$t['line']}" : '');
}
$res .= Helpers::editorLink($item[0], $item[1]) . ' ' . '<span title="' . htmlspecialchars(implode("\n", $stack), ENT_IGNORE | ENT_QUOTES, 'UTF-8') . '">' . str_replace(self::BOM, '<big>BOM</big>', Dumper::toHtml($item[2])) . "</span><br>\n";
}
return $res . '</code>';
}
示例12: getPanel
/**
* Renders HTML code for custom panel.
* @return string
*/
public function getPanel()
{
if (!$this->resources) {
return null;
}
$esc = \Nette\Utils\Callback::closure('Latte\\Runtime\\Filters::escapeHtml');
$click = function ($o, $c = false) {
return \Tracy\Dumper::toHtml($o, ['collapse' => $c]);
};
ob_start();
include __DIR__ . '/panel.phtml';
return ob_get_clean();
}
示例13: getPanel
/**
* @return string
*/
public function getPanel()
{
if (empty($this->evaluatedFeatures)) {
return NULL;
}
$evaluatedFeatures = $this->evaluatedFeatures;
$click = class_exists('\\Tracy\\Dumper') ? function ($o, $c = TRUE, $d = 4) {
return \Tracy\Dumper::toHtml($o, array('collapse' => $c, 'depth' => $d));
} : callback('\\Tracy\\Helpers::clickableDump');
ob_start();
require __DIR__ . '/panel.phtml';
return ob_get_clean();
}
示例14: formatMessage
/**
* @return string
*/
protected function formatMessage($message)
{
if ($message instanceof \Exception) {
while ($message) {
$tmp[] = ($message instanceof \ErrorException ? 'Fatal error: ' . $message->getMessage() : get_class($message) . ': ' . $message->getMessage()) . ' in ' . $message->getFile() . ':' . $message->getLine();
$message = $message->getPrevious();
}
$message = implode($tmp, "\ncaused by ");
} elseif (!is_string($message)) {
$message = Dumper::toText($message);
}
return trim($message);
}
示例15: getPanel
/**
* @return string
*/
public function getPanel()
{
if (!$this->calls) {
return NULL;
}
ob_start();
$esc = array('Nette\\Templating\\Helpers', 'escapeHtml');
$click = class_exists('\\Tracy\\Dumper') ? function ($o, $c = FALSE) {
return \Tracy\Dumper::toHtml($o, array('collapse' => $c));
} : array('\\Tracy\\Helpers', 'clickableDump');
$totalTime = $this->totalTime ? sprintf('%0.3f', $this->totalTime * 1000) . ' ms' : 'none';
require __DIR__ . '/panel.phtml';
return ob_get_clean();
}