当前位置: 首页>>代码示例>>PHP>>正文


PHP Debugger::excerpt方法代码示例

本文整理汇总了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));
 }
开发者ID:javierm,项目名称:wildflower,代码行数:14,代码来源:debugger.test.php

示例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+">.*?&lt;\\?php/';
     $this->assertRegExp($pattern, $result[0]);
     $return = Debugger::excerpt('[internal]', 2, 2);
     $this->assertTrue(empty($return));
 }
开发者ID:ronaldsalazar23,项目名称:ComercialChiriguano,代码行数:19,代码来源:DebuggerTest.php

示例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">&lt;?php';
     $expected .= '</span></code>';
     $this->assertEqual($result[0], $expected);
     $return = Debugger::excerpt('[internal]', 2, 2);
     $this->assertTrue(empty($return));
 }
开发者ID:arendasistemasintegrados,项目名称:mateusleme,代码行数:21,代码来源:debugger.test.php

示例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;
 }
开发者ID:rhencke,项目名称:mozilla-cvs-history,代码行数:98,代码来源:debugger.php


注:本文中的Debugger::excerpt方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。