本文整理汇总了PHP中Debugger::excerpt方法的典型用法代码示例。如果您正苦于以下问题:PHP Debugger::excerpt方法的具体用法?PHP Debugger::excerpt怎么用?PHP Debugger::excerpt使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Debugger
的用法示例。
在下文中一共展示了Debugger::excerpt方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testExcerpt
/**
* test Excerpt writing
*
* @return void
**/
function testExcerpt()
{
$return = Debugger::excerpt(__FILE__, 2, 2);
$this->assertTrue(is_array($return));
$this->assertEqual(count($return), 4);
$this->assertPattern('#/* SVN FILE: \\$Id: debugger.test.php#', $return[1]);
$return = Debugger::excerpt('[internal]', 2, 2);
$this->assertTrue(empty($return));
}
示例2: testExcerpt
/**
* test Excerpt writing
*
* @return void
*/
public function testExcerpt()
{
$result = Debugger::excerpt(__FILE__, __LINE__, 2);
$this->assertTrue(is_array($result));
$this->assertEquals(count($result), 5);
$this->assertRegExp('/function(.+)testExcerpt/', $result[1]);
$result = Debugger::excerpt(__FILE__, 2, 2);
$this->assertTrue(is_array($result));
$this->assertEquals(count($result), 4);
$pattern = '/<code><span style\\="color\\: \\#\\d+">.*?<\\?php/';
$this->assertRegExp($pattern, $result[0]);
$return = Debugger::excerpt('[internal]', 2, 2);
$this->assertTrue(empty($return));
}
示例3: testExcerpt
/**
* test Excerpt writing
*
* @access public
* @return void
*/
function testExcerpt()
{
$result = Debugger::excerpt(__FILE__, __LINE__, 2);
$this->assertTrue(is_array($result));
$this->assertEqual(count($result), 5);
$this->assertPattern('/function(.+)testExcerpt/', $result[1]);
$result = Debugger::excerpt(__FILE__, 2, 2);
$this->assertTrue(is_array($result));
$this->assertEqual(count($result), 4);
$expected = '<code><span style="color: #000000"><?php';
$expected .= '</span></code>';
$this->assertEqual($result[0], $expected);
$return = Debugger::excerpt('[internal]', 2, 2);
$this->assertTrue(empty($return));
}
示例4: handleError
/**
* Overrides PHP's default error handling
*
* @param integer $code Code of error
* @param string $description Error description
* @param string $file File on which error occurred
* @param integer $line Line that triggered the error
* @param array $context Context
* @return boolean true if error was handled
* @access public
*/
function handleError($code, $description, $file = null, $line = null, $context = null)
{
if (error_reporting() == 0 || $code === 2048) {
return;
}
$_this = Debugger::getInstance();
if (empty($file)) {
$file = '[internal]';
}
if (empty($line)) {
$line = '??';
}
$file = $_this->trimPath($file);
$info = compact('code', 'description', 'file', 'line');
if (!in_array($info, $_this->errors)) {
$_this->errors[] = $info;
} else {
return;
}
$level = LOG_DEBUG;
switch ($code) {
case E_PARSE:
case E_ERROR:
case E_CORE_ERROR:
case E_COMPILE_ERROR:
$error = 'Fatal Error';
$level = LOG_ERROR;
break;
case E_WARNING:
case E_USER_WARNING:
case E_COMPILE_WARNING:
case E_RECOVERABLE_ERROR:
$error = 'Warning';
$level = LOG_WARNING;
break;
case E_NOTICE:
$error = 'Notice';
$level = LOG_NOTICE;
break;
default:
return false;
break;
}
$helpCode = null;
if (!empty($_this->helpPath) && preg_match('/.*\\[([0-9]+)\\]$/', $description, $codes)) {
if (isset($codes[1])) {
$helpCode = $codes[1];
$description = trim(preg_replace('/\\[[0-9]+\\]$/', '', $description));
}
}
$link = "document.getElementById(\"CakeStackTrace" . count($_this->errors) . "\").style.display = (document.getElementById(\"CakeStackTrace" . count($_this->errors) . "\").style.display == \"none\" ? \"\" : \"none\")";
$out = "<a href='javascript:void(0);' onclick='{$link}'><b>{$error}</b> ({$code})</a>: {$description} [<b>{$file}</b>, line <b>{$line}</b>]";
if (Configure::read() > 0) {
debug($out, false, false);
e('<div id="CakeStackTrace' . count($_this->errors) . '" class="cake-stack-trace" style="display: none;">');
if (!empty($context)) {
$link = "document.getElementById(\"CakeErrorContext" . count($_this->errors) . "\").style.display = (document.getElementById(\"CakeErrorContext" . count($_this->errors) . "\").style.display == \"none\" ? \"\" : \"none\")";
e("<a href='javascript:void(0);' onclick='{$link}'>Context</a> | ");
$link = "document.getElementById(\"CakeErrorCode" . count($_this->errors) . "\").style.display = (document.getElementById(\"CakeErrorCode" . count($_this->errors) . "\").style.display == \"none\" ? \"\" : \"none\")";
e("<a href='javascript:void(0);' onclick='{$link}'>Code</a>");
if (!empty($helpCode)) {
e(" | <a href='{$_this->helpPath}{$helpCode}' target='blank'>Help</a>");
}
e("<pre id=\"CakeErrorContext" . count($_this->errors) . "\" class=\"cake-context\" style=\"display: none;\">");
foreach ($context as $var => $value) {
e("\${$var}\t=\t" . $_this->exportVar($value, 1) . "\n");
}
e("</pre>");
}
}
$files = $_this->trace(array('start' => 1, 'format' => 'points'));
$listing = Debugger::excerpt($files[0]['file'], $files[0]['line'] - 1, 2);
if (Configure::read() > 0) {
e("<div id=\"CakeErrorCode" . count($_this->errors) . "\" class=\"cake-code-dump\" style=\"display: none;\">");
pr(implode("\n", $listing), false);
e('</div>');
pr($_this->trace(array('start' => 1)), false);
e('</div>');
}
if (Configure::read('log')) {
CakeLog::write($level, "{$error} ({$code}): {$description} in [{$file}, line {$line}]");
}
if ($error == 'Fatal Error') {
die;
}
return true;
}