mirror of
https://github.com/symfony/debug.git
synced 2026-03-24 17:22:13 +01:00
Compare commits
10 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e1aa457a97 | ||
|
|
e9470b1f9e | ||
|
|
77d632fd72 | ||
|
|
20c5dad1af | ||
|
|
8f1257608f | ||
|
|
355f12cf08 | ||
|
|
ff6a582db5 | ||
|
|
30d1de52f1 | ||
|
|
dfe71c73cf | ||
|
|
01c8bc9bac |
@@ -133,6 +133,7 @@ class ErrorHandler
|
||||
unset($context['GLOBALS']);
|
||||
}
|
||||
|
||||
$level &= E_ALL | E_STRICT;
|
||||
$exception = new ContextErrorException(sprintf('%s: %s in %s line %d', isset($this->levels[$level]) ? $this->levels[$level] : $level, $message, $file, $line), 0, $level, $file, $line, $context);
|
||||
|
||||
// Exceptions thrown from error handlers are sometimes not caught by the exception
|
||||
@@ -173,7 +174,7 @@ class ErrorHandler
|
||||
}
|
||||
|
||||
$this->reservedMemory = '';
|
||||
$type = $error['type'];
|
||||
$type = $error['type'] & (E_ALL | E_STRICT);
|
||||
if (0 === $this->level || !in_array($type, array(E_ERROR, E_CORE_ERROR, E_COMPILE_ERROR, E_PARSE))) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -157,10 +157,11 @@ EOF
|
||||
}
|
||||
if (isset($trace['file']) && isset($trace['line'])) {
|
||||
if ($linkFormat = ini_get('xdebug.file_link_format')) {
|
||||
$link = str_replace(array('%f', '%l'), array($trace['file'], $trace['line']), $linkFormat);
|
||||
$content .= sprintf(' in <a href="%s" title="Go to source">%s line %s</a>', $link, $trace['file'], $trace['line']);
|
||||
$link = strtr($linkFormat, array('%f' => $trace['file'], '%l' => $trace['line']));
|
||||
$link = htmlspecialchars($link, $flags, $this->charset);
|
||||
$content .= sprintf(' in <a href="%s" title="Go to source">%s line %d</a>', $link, htmlspecialchars($trace['file'], $flags, $this->charset), $trace['line']);
|
||||
} else {
|
||||
$content .= sprintf(' in %s line %s', $trace['file'], $trace['line']);
|
||||
$content .= sprintf(' in %s line %d', htmlspecialchars($trace['file'], $flags, $this->charset), $trace['line']);
|
||||
}
|
||||
}
|
||||
$content .= "</li>\n";
|
||||
|
||||
@@ -39,6 +39,10 @@ class ErrorHandlerTest extends \PHPUnit_Framework_TestCase
|
||||
|
||||
public function testCompileTimeError()
|
||||
{
|
||||
if (defined('HHVM_VERSION')) {
|
||||
$this->markTestSkipped('HHVM does not trigger strict notices.');
|
||||
}
|
||||
|
||||
// the ContextErrorException must not be loaded to test the workaround
|
||||
// for https://bugs.php.net/bug.php?id=65322.
|
||||
if (class_exists('Symfony\Component\Debug\Exception\ContextErrorException', false)) {
|
||||
@@ -62,10 +66,10 @@ class ErrorHandlerTest extends \PHPUnit_Framework_TestCase
|
||||
$that->assertEquals(2, $exception->getLine());
|
||||
if (PHP_VERSION_ID < 70000) {
|
||||
$that->assertEquals(E_STRICT, $exception->getSeverity());
|
||||
$that->assertStringStartsWith('Runtime Notice: Declaration of _CompileTimeError::foo() should be compatible with', $exception->getMessage());
|
||||
$that->assertStringStartsWith('Runtime Notice: Declaration', $exception->getMessage());
|
||||
} else {
|
||||
$that->assertEquals(E_WARNING, $exception->getSeverity());
|
||||
$that->assertStringStartsWith('Warning: Declaration of _CompileTimeError::foo() should be compatible with', $exception->getMessage());
|
||||
$that->assertStringStartsWith('Warning: Declaration', $exception->getMessage());
|
||||
}
|
||||
$that->assertArrayHasKey('bar', $exception->getContext());
|
||||
};
|
||||
@@ -107,7 +111,7 @@ PHP
|
||||
$that->assertEquals(E_NOTICE, $exception->getSeverity());
|
||||
$that->assertEquals(__LINE__ + 40, $exception->getLine());
|
||||
$that->assertEquals(__FILE__, $exception->getFile());
|
||||
$that->assertRegexp('/^Notice: Undefined variable: (foo|bar)/', $exception->getMessage());
|
||||
$that->assertRegExp('/^Notice: Undefined variable: (foo|bar)/', $exception->getMessage());
|
||||
$that->assertArrayHasKey('foobar', $exception->getContext());
|
||||
|
||||
$trace = $exception->getTrace();
|
||||
@@ -117,11 +121,11 @@ PHP
|
||||
$that->assertEquals('->', $trace[0]['type']);
|
||||
|
||||
$that->assertEquals(__FILE__, $trace[1]['file']);
|
||||
$that->assertEquals(__CLASS__, $trace[1]['class']);
|
||||
$that->assertEquals('Symfony\Component\Debug\Tests\ErrorHandlerTest', $trace[1]['class']);
|
||||
$that->assertEquals('triggerNotice', $trace[1]['function']);
|
||||
$that->assertEquals('::', $trace[1]['type']);
|
||||
|
||||
$that->assertEquals(__CLASS__, $trace[2]['class']);
|
||||
$that->assertEquals('Symfony\Component\Debug\Tests\ErrorHandlerTest', $trace[2]['class']);
|
||||
$that->assertEquals('testNotice', $trace[2]['function']);
|
||||
$that->assertEquals('->', $trace[2]['type']);
|
||||
};
|
||||
|
||||
@@ -189,9 +189,9 @@ class FlattenExceptionTest extends \PHPUnit_Framework_TestCase
|
||||
public function testTooBigArray()
|
||||
{
|
||||
$a = array();
|
||||
for ($i = 0; $i < 20; $i++) {
|
||||
for ($j = 0; $j < 50; $j++) {
|
||||
for ($k = 0; $k < 10; $k++) {
|
||||
for ($i = 0; $i < 20; ++$i) {
|
||||
for ($j = 0; $j < 50; ++$j) {
|
||||
for ($k = 0; $k < 10; ++$k) {
|
||||
$a[$i][$j][$k] = 'value';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,7 +22,6 @@
|
||||
"symfony/http-kernel": ">=2.3,<2.3.24|~2.4.0|>=2.5,<2.5.9|>=2.6,<2.6.2"
|
||||
},
|
||||
"require-dev": {
|
||||
"symfony/phpunit-bridge": "~2.7",
|
||||
"symfony/http-kernel": "~2.3.24|~2.5.9|~2.6,>=2.6.2",
|
||||
"symfony/http-foundation": "~2.1"
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user