mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 11:28:25 +00:00
parent
6cf6903982
commit
1e49be3472
2 changed files with 28 additions and 10 deletions
|
@ -84,7 +84,13 @@ class DebuggerTest extends CakeTestCase {
|
||||||
$this->assertTrue(is_array($result));
|
$this->assertTrue(is_array($result));
|
||||||
$this->assertEquals(4, count($result));
|
$this->assertEquals(4, count($result));
|
||||||
|
|
||||||
$pattern = '/<code><span style\="color\: \#\d+">.*?<\?php/';
|
$pattern = '/<code>.*?<span style\="color\: \#\d+">.*?<\?php/';
|
||||||
|
$this->assertRegExp($pattern, $result[0]);
|
||||||
|
|
||||||
|
$result = Debugger::excerpt(__FILE__, 10, 2);
|
||||||
|
$this->assertEquals(5, count($result));
|
||||||
|
|
||||||
|
$pattern = '/<span style\="color\: \#\d{6}">\*<\/span>/';
|
||||||
$this->assertRegExp($pattern, $result[0]);
|
$this->assertRegExp($pattern, $result[0]);
|
||||||
|
|
||||||
$return = Debugger::excerpt('[internal]', 2, 2);
|
$return = Debugger::excerpt('[internal]', 2, 2);
|
||||||
|
|
|
@ -396,12 +396,14 @@ class Debugger {
|
||||||
return array();
|
return array();
|
||||||
}
|
}
|
||||||
$data = file_get_contents($file);
|
$data = file_get_contents($file);
|
||||||
if (!empty($data) && strpos($data, "\n") !== false) {
|
if (empty($data)) {
|
||||||
|
return $lines;
|
||||||
|
}
|
||||||
|
if (strpos($data, "\n") !== false) {
|
||||||
$data = explode("\n", $data);
|
$data = explode("\n", $data);
|
||||||
}
|
}
|
||||||
|
if (!isset($data[$line])) {
|
||||||
if (empty($data) || !isset($data[$line])) {
|
return $lines;
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
for ($i = $line - ($context + 1); $i < $line + $context; $i++) {
|
for ($i = $line - ($context + 1); $i < $line + $context; $i++) {
|
||||||
if (!isset($data[$i])) {
|
if (!isset($data[$i])) {
|
||||||
|
@ -425,13 +427,23 @@ class Debugger {
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
protected static function _highlight($str) {
|
protected static function _highlight($str) {
|
||||||
static $supportHighlight = null;
|
if (function_exists('hphp_log')) {
|
||||||
if (!$supportHighlight && function_exists('hphp_log')) {
|
|
||||||
$supportHighlight = false;
|
|
||||||
return htmlentities($str);
|
return htmlentities($str);
|
||||||
}
|
}
|
||||||
$supportHighlight = true;
|
$added = false;
|
||||||
return highlight_string($str, true);
|
if (strpos($str, '<?php') === false) {
|
||||||
|
$added = true;
|
||||||
|
$str = "<?php \n" . $str;
|
||||||
|
}
|
||||||
|
$highlight = highlight_string($str, true);
|
||||||
|
if ($added) {
|
||||||
|
$highlight = str_replace(
|
||||||
|
'<?php <br />',
|
||||||
|
'',
|
||||||
|
$highlight
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return $highlight;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in a new issue