mirror of
https://github.com/symfony/debug.git
synced 2026-03-24 17:22:13 +01:00
Compare commits
34 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1a69249219 | ||
|
|
60d1b678b7 | ||
|
|
77603bad55 | ||
|
|
6637e62480 | ||
|
|
5de6c6e7f5 | ||
|
|
346e1507ee | ||
|
|
43ede438d4 | ||
|
|
2f9160e92e | ||
|
|
0239626388 | ||
|
|
d2bbd5ffb4 | ||
|
|
26c72fcb6d | ||
|
|
a8d2d5c944 | ||
|
|
45b2136377 | ||
|
|
157bbec4fd | ||
|
|
af4987aa4a | ||
|
|
edfa86f186 | ||
|
|
462dbe3a63 | ||
|
|
84de62e42e | ||
|
|
7f265ded6f | ||
|
|
ebcaaad20c | ||
|
|
5768cc007b | ||
|
|
5dfc7825f3 | ||
|
|
65fe7b4986 | ||
|
|
c87adf3fc1 | ||
|
|
ab42889de5 | ||
|
|
ba95c0aa9b | ||
|
|
bfcf449c91 | ||
|
|
5a40526df8 | ||
|
|
90c931ffd0 | ||
|
|
888525fe28 | ||
|
|
34a8785ac1 | ||
|
|
434a1f80c9 | ||
|
|
0a7f96d51e | ||
|
|
9109e4414e |
49
CHANGELOG.md
49
CHANGELOG.md
@@ -10,67 +10,66 @@ CHANGELOG
|
||||
4.3.0
|
||||
-----
|
||||
|
||||
* made the `ErrorHandler` and `ExceptionHandler` classes final
|
||||
* added `Exception\FlattenException::getAsString` and
|
||||
`Exception\FlattenException::getTraceAsString` to increase compatibility to php
|
||||
exception objects
|
||||
* made the `ErrorHandler` and `ExceptionHandler` classes final
|
||||
* added `Exception\FlattenException::getAsString` and
|
||||
`Exception\FlattenException::getTraceAsString` to increase compatibility to php
|
||||
exception objects
|
||||
|
||||
4.0.0
|
||||
-----
|
||||
|
||||
* removed the symfony_debug extension
|
||||
* removed `ContextErrorException`
|
||||
* removed the symfony_debug extension
|
||||
* removed `ContextErrorException`
|
||||
|
||||
3.4.0
|
||||
-----
|
||||
|
||||
* deprecated `ErrorHandler::stackErrors()` and `ErrorHandler::unstackErrors()`
|
||||
* deprecated `ErrorHandler::stackErrors()` and `ErrorHandler::unstackErrors()`
|
||||
|
||||
3.3.0
|
||||
-----
|
||||
|
||||
* deprecated the `ContextErrorException` class: use \ErrorException directly now
|
||||
* deprecated the `ContextErrorException` class: use \ErrorException directly now
|
||||
|
||||
3.2.0
|
||||
-----
|
||||
|
||||
* `FlattenException::getTrace()` now returns additional type descriptions
|
||||
`integer` and `float`.
|
||||
|
||||
* `FlattenException::getTrace()` now returns additional type descriptions
|
||||
`integer` and `float`.
|
||||
|
||||
3.0.0
|
||||
-----
|
||||
|
||||
* removed classes, methods and interfaces deprecated in 2.x
|
||||
* removed classes, methods and interfaces deprecated in 2.x
|
||||
|
||||
2.8.0
|
||||
-----
|
||||
|
||||
* added BufferingLogger for errors that happen before a proper logger is configured
|
||||
* allow throwing from `__toString()` with `return trigger_error($e, E_USER_ERROR);`
|
||||
* deprecate ExceptionHandler::createResponse
|
||||
* added BufferingLogger for errors that happen before a proper logger is configured
|
||||
* allow throwing from `__toString()` with `return trigger_error($e, E_USER_ERROR);`
|
||||
* deprecate ExceptionHandler::createResponse
|
||||
|
||||
2.7.0
|
||||
-----
|
||||
|
||||
* added deprecations checking for parent interfaces/classes to DebugClassLoader
|
||||
* added ZTS support to symfony_debug extension
|
||||
* added symfony_debug_backtrace() to symfony_debug extension
|
||||
to track the backtrace of fatal errors
|
||||
* added deprecations checking for parent interfaces/classes to DebugClassLoader
|
||||
* added ZTS support to symfony_debug extension
|
||||
* added symfony_debug_backtrace() to symfony_debug extension
|
||||
to track the backtrace of fatal errors
|
||||
|
||||
2.6.0
|
||||
-----
|
||||
|
||||
* generalized ErrorHandler and ExceptionHandler,
|
||||
with some new methods and others deprecated
|
||||
* enhanced error messages for uncaught exceptions
|
||||
* generalized ErrorHandler and ExceptionHandler,
|
||||
with some new methods and others deprecated
|
||||
* enhanced error messages for uncaught exceptions
|
||||
|
||||
2.5.0
|
||||
-----
|
||||
|
||||
* added ExceptionHandler::setHandler()
|
||||
* added UndefinedMethodFatalErrorHandler
|
||||
* deprecated DummyException
|
||||
* added ExceptionHandler::setHandler()
|
||||
* added UndefinedMethodFatalErrorHandler
|
||||
* deprecated DummyException
|
||||
|
||||
2.4.0
|
||||
-----
|
||||
|
||||
@@ -49,7 +49,7 @@ class Debug
|
||||
if (!\in_array(\PHP_SAPI, ['cli', 'phpdbg'], true)) {
|
||||
ini_set('display_errors', 0);
|
||||
ExceptionHandler::register();
|
||||
} elseif ($displayErrors && (!filter_var(ini_get('log_errors'), \FILTER_VALIDATE_BOOLEAN) || ini_get('error_log'))) {
|
||||
} elseif ($displayErrors && (!filter_var(\ini_get('log_errors'), \FILTER_VALIDATE_BOOLEAN) || \ini_get('error_log'))) {
|
||||
// CLI - display errors only if they're not already logged to STDERR
|
||||
ini_set('display_errors', 1);
|
||||
}
|
||||
|
||||
@@ -90,8 +90,8 @@ class DebugClassLoader
|
||||
public static function enable()
|
||||
{
|
||||
// Ensures we don't hit https://bugs.php.net/42098
|
||||
class_exists('Symfony\Component\Debug\ErrorHandler');
|
||||
class_exists('Psr\Log\LogLevel');
|
||||
class_exists(\Symfony\Component\Debug\ErrorHandler::class);
|
||||
class_exists(\Psr\Log\LogLevel::class);
|
||||
|
||||
if (!\is_array($functions = spl_autoload_functions())) {
|
||||
return;
|
||||
@@ -300,7 +300,7 @@ class DebugClassLoader
|
||||
$hasCall = $refl->hasMethod('__call');
|
||||
$hasStaticCall = $refl->hasMethod('__callStatic');
|
||||
foreach (self::$method[$use] as $method) {
|
||||
list($interface, $name, $static, $description) = $method;
|
||||
[$interface, $name, $static, $description] = $method;
|
||||
if ($static ? $hasStaticCall : $hasCall) {
|
||||
continue;
|
||||
}
|
||||
@@ -335,12 +335,12 @@ class DebugClassLoader
|
||||
}
|
||||
|
||||
if ($parent && isset(self::$finalMethods[$parent][$method->name])) {
|
||||
list($declaringClass, $message) = self::$finalMethods[$parent][$method->name];
|
||||
[$declaringClass, $message] = self::$finalMethods[$parent][$method->name];
|
||||
$deprecations[] = sprintf('The "%s::%s()" method is considered final%s. It may change without further notice as of its next major version. You should not extend it from "%s".', $declaringClass, $method->name, $message, $class);
|
||||
}
|
||||
|
||||
if (isset(self::$internalMethods[$class][$method->name])) {
|
||||
list($declaringClass, $message) = self::$internalMethods[$class][$method->name];
|
||||
[$declaringClass, $message] = self::$internalMethods[$class][$method->name];
|
||||
if (strncmp($ns, $declaringClass, $len)) {
|
||||
$deprecations[] = sprintf('The "%s::%s()" method is considered internal%s. It may change without further notice. You should not extend it from "%s".', $declaringClass, $method->name, $message, $class);
|
||||
}
|
||||
@@ -388,7 +388,7 @@ class DebugClassLoader
|
||||
$definedParameters[$parameter->name] = true;
|
||||
}
|
||||
}
|
||||
foreach ($matches as list(, $parameterType, $parameterName)) {
|
||||
foreach ($matches as [, $parameterType, $parameterName]) {
|
||||
if (!isset($definedParameters[$parameterName])) {
|
||||
$parameterType = trim($parameterType);
|
||||
self::$annotatedParameters[$class][$method->name][$parameterName] = sprintf('The "%%s::%s()" method will require a new "%s$%s" argument in the next major version of its %s "%s", not defining it is deprecated.', $method->name, $parameterType ? $parameterType.' ' : '', $parameterName, interface_exists($class) ? 'interface' : 'parent class', $method->class);
|
||||
|
||||
@@ -119,7 +119,7 @@ class ErrorHandler
|
||||
public static function register(self $handler = null, $replace = true)
|
||||
{
|
||||
if (null === self::$reservedMemory) {
|
||||
self::$reservedMemory = str_repeat('x', 10240);
|
||||
self::$reservedMemory = str_repeat('x', 32768);
|
||||
register_shutdown_function(__CLASS__.'::handleFatalError');
|
||||
}
|
||||
|
||||
@@ -169,7 +169,7 @@ class ErrorHandler
|
||||
$this->bootstrappingLogger = $bootstrappingLogger;
|
||||
$this->setDefaultLogger($bootstrappingLogger);
|
||||
}
|
||||
$this->traceReflector = new \ReflectionProperty('Exception', 'trace');
|
||||
$this->traceReflector = new \ReflectionProperty(\Exception::class, 'trace');
|
||||
$this->traceReflector->setAccessible(true);
|
||||
}
|
||||
|
||||
@@ -354,8 +354,8 @@ class ErrorHandler
|
||||
*/
|
||||
private function reRegister(int $prev)
|
||||
{
|
||||
if ($prev !== $this->thrownErrors | $this->loggedErrors) {
|
||||
$handler = set_error_handler('var_dump');
|
||||
if ($prev !== ($this->thrownErrors | $this->loggedErrors)) {
|
||||
$handler = set_error_handler('is_int');
|
||||
$handler = \is_array($handler) ? $handler[0] : null;
|
||||
restore_error_handler();
|
||||
if ($handler === $this) {
|
||||
@@ -490,7 +490,7 @@ class ErrorHandler
|
||||
$log = 0;
|
||||
} else {
|
||||
if (\PHP_VERSION_ID < (\PHP_VERSION_ID < 70400 ? 70316 : 70404)) {
|
||||
$currentErrorHandler = set_error_handler('var_dump');
|
||||
$currentErrorHandler = set_error_handler('is_int');
|
||||
restore_error_handler();
|
||||
}
|
||||
|
||||
@@ -601,7 +601,7 @@ class ErrorHandler
|
||||
$sameHandlerLimit = 10;
|
||||
|
||||
while (!\is_array($handler) || !$handler[0] instanceof self) {
|
||||
$handler = set_exception_handler('var_dump');
|
||||
$handler = set_exception_handler('is_int');
|
||||
restore_exception_handler();
|
||||
|
||||
if (!$handler) {
|
||||
@@ -636,7 +636,7 @@ class ErrorHandler
|
||||
if ($error && $error['type'] &= \E_PARSE | \E_ERROR | \E_CORE_ERROR | \E_COMPILE_ERROR) {
|
||||
// Let's not throw anymore but keep logging
|
||||
$handler->throwAt(0, true);
|
||||
$trace = isset($error['backtrace']) ? $error['backtrace'] : null;
|
||||
$trace = $error['backtrace'] ?? null;
|
||||
|
||||
if (0 === strpos($error['message'], 'Allowed memory') || 0 === strpos($error['message'], 'Out of memory')) {
|
||||
$exception = new OutOfMemoryException($handler->levels[$error['type']].': '.$error['message'], 0, $error['type'], $error['file'], $error['line'], 2, false, $trace);
|
||||
|
||||
@@ -35,8 +35,7 @@ class FatalErrorException extends \ErrorException
|
||||
|
||||
$this->setTrace($trace);
|
||||
} elseif (null !== $traceOffset) {
|
||||
if (\function_exists('xdebug_get_function_stack')) {
|
||||
$trace = xdebug_get_function_stack();
|
||||
if (\function_exists('xdebug_get_function_stack') && $trace = @xdebug_get_function_stack()) {
|
||||
if (0 < $traceOffset) {
|
||||
array_splice($trace, -$traceOffset);
|
||||
}
|
||||
@@ -74,7 +73,7 @@ class FatalErrorException extends \ErrorException
|
||||
|
||||
protected function setTrace($trace)
|
||||
{
|
||||
$traceReflector = new \ReflectionProperty('Exception', 'trace');
|
||||
$traceReflector = new \ReflectionProperty(\Exception::class, 'trace');
|
||||
$traceReflector->setAccessible(true);
|
||||
$traceReflector->setValue($this, $trace);
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ class FatalThrowableError extends FatalErrorException
|
||||
|
||||
public function __construct(\Throwable $e)
|
||||
{
|
||||
$this->originalClassName = get_debug_type($e);
|
||||
$this->originalClassName = \get_class($e);
|
||||
|
||||
if ($e instanceof \ParseError) {
|
||||
$severity = \E_PARSE;
|
||||
|
||||
@@ -67,7 +67,7 @@ class FlattenException
|
||||
$e->setStatusCode($statusCode);
|
||||
$e->setHeaders($headers);
|
||||
$e->setTraceFromThrowable($exception);
|
||||
$e->setClass($exception instanceof FatalThrowableError ? $exception->getOriginalClassName() : get_debug_type($exception));
|
||||
$e->setClass($exception instanceof FatalThrowableError ? $exception->getOriginalClassName() : \get_class($exception));
|
||||
$e->setFile($exception->getFile());
|
||||
$e->setLine($exception->getLine());
|
||||
|
||||
@@ -281,11 +281,11 @@ class FlattenException
|
||||
$this->trace[] = [
|
||||
'namespace' => $namespace,
|
||||
'short_class' => $class,
|
||||
'class' => isset($entry['class']) ? $entry['class'] : '',
|
||||
'type' => isset($entry['type']) ? $entry['type'] : '',
|
||||
'function' => isset($entry['function']) ? $entry['function'] : null,
|
||||
'file' => isset($entry['file']) ? $entry['file'] : null,
|
||||
'line' => isset($entry['line']) ? $entry['line'] : null,
|
||||
'class' => $entry['class'] ?? '',
|
||||
'type' => $entry['type'] ?? '',
|
||||
'function' => $entry['function'] ?? null,
|
||||
'file' => $entry['file'] ?? null,
|
||||
'line' => $entry['line'] ?? null,
|
||||
'args' => isset($entry['args']) ? $this->flattenArgs($entry['args']) : [],
|
||||
];
|
||||
}
|
||||
|
||||
@@ -55,7 +55,7 @@ class ExceptionHandler
|
||||
public function __construct(bool $debug = true, string $charset = null, $fileLinkFormat = null)
|
||||
{
|
||||
$this->debug = $debug;
|
||||
$this->charset = $charset ?: ini_get('default_charset') ?: 'UTF-8';
|
||||
$this->charset = $charset ?: \ini_get('default_charset') ?: 'UTF-8';
|
||||
$this->fileLinkFormat = $fileLinkFormat;
|
||||
}
|
||||
|
||||
@@ -390,7 +390,7 @@ EOF;
|
||||
private function formatPath(string $path, int $line): string
|
||||
{
|
||||
$file = $this->escapeHtml(preg_match('#[^/\\\\]*+$#', $path, $file) ? $file[0] : $path);
|
||||
$fmt = $this->fileLinkFormat ?: ini_get('xdebug.file_link_format') ?: get_cfg_var('xdebug.file_link_format');
|
||||
$fmt = $this->fileLinkFormat ?: \ini_get('xdebug.file_link_format') ?: get_cfg_var('xdebug.file_link_format');
|
||||
|
||||
if (!$fmt) {
|
||||
return sprintf('<span class="block trace-file-path">in <span title="%s%3$s"><strong>%s</strong>%s</span></span>', $this->escapeHtml($path), $file, 0 < $line ? ' line '.$line : '');
|
||||
|
||||
@@ -40,7 +40,7 @@ class UndefinedMethodFatalErrorHandler implements FatalErrorHandlerInterface
|
||||
|
||||
$message = sprintf('Attempted to call an undefined method named "%s" of class "%s".', $methodName, $className);
|
||||
|
||||
if (!class_exists($className) || null === $methods = get_class_methods($className)) {
|
||||
if ('' === $methodName || !class_exists($className) || null === $methods = get_class_methods($className)) {
|
||||
// failed to get the class or its methods on which an unknown method was called (for example on an anonymous class)
|
||||
return new UndefinedMethodException($message, $exception);
|
||||
}
|
||||
|
||||
2
LICENSE
2
LICENSE
@@ -1,4 +1,4 @@
|
||||
Copyright (c) 2004-2020 Fabien Potencier
|
||||
Copyright (c) 2004-2022 Fabien Potencier
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
10
README.md
10
README.md
@@ -12,7 +12,7 @@ Getting Started
|
||||
---------------
|
||||
|
||||
```
|
||||
$ composer install symfony/debug
|
||||
$ composer require symfony/debug
|
||||
```
|
||||
|
||||
```php
|
||||
@@ -24,7 +24,7 @@ Debug::enable();
|
||||
Resources
|
||||
---------
|
||||
|
||||
* [Contributing](https://symfony.com/doc/current/contributing/index.html)
|
||||
* [Report issues](https://github.com/symfony/symfony/issues) and
|
||||
[send Pull Requests](https://github.com/symfony/symfony/pulls)
|
||||
in the [main Symfony repository](https://github.com/symfony/symfony)
|
||||
* [Contributing](https://symfony.com/doc/current/contributing/index.html)
|
||||
* [Report issues](https://github.com/symfony/symfony/issues) and
|
||||
[send Pull Requests](https://github.com/symfony/symfony/pulls)
|
||||
in the [main Symfony repository](https://github.com/symfony/symfony)
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
namespace Symfony\Component\Debug\Tests;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Bridge\Debug\Tests\Fixtures\ExtendsDeprecatedParent;
|
||||
use Symfony\Component\Debug\DebugClassLoader;
|
||||
|
||||
/**
|
||||
@@ -54,7 +55,7 @@ class DebugClassLoaderTest extends TestCase
|
||||
$reflProp = $reflClass->getProperty('classLoader');
|
||||
$reflProp->setAccessible(true);
|
||||
|
||||
$this->assertNotInstanceOf('Symfony\Component\Debug\DebugClassLoader', $reflProp->getValue($function[0]));
|
||||
$this->assertNotInstanceOf(DebugClassLoader::class, $reflProp->getValue($function[0]));
|
||||
|
||||
return;
|
||||
}
|
||||
@@ -65,7 +66,7 @@ class DebugClassLoaderTest extends TestCase
|
||||
|
||||
public function testThrowingClass()
|
||||
{
|
||||
$this->expectException('Exception');
|
||||
$this->expectException(\Exception::class);
|
||||
$this->expectExceptionMessage('boo');
|
||||
try {
|
||||
class_exists(Fixtures\Throwing::class);
|
||||
@@ -80,14 +81,14 @@ class DebugClassLoaderTest extends TestCase
|
||||
|
||||
public function testNameCaseMismatch()
|
||||
{
|
||||
$this->expectException('RuntimeException');
|
||||
$this->expectException(\RuntimeException::class);
|
||||
$this->expectExceptionMessage('Case mismatch between loaded and declared class names');
|
||||
class_exists(TestingCaseMismatch::class, true);
|
||||
}
|
||||
|
||||
public function testFileCaseMismatch()
|
||||
{
|
||||
$this->expectException('RuntimeException');
|
||||
$this->expectException(\RuntimeException::class);
|
||||
$this->expectExceptionMessage('Case mismatch between class and real file names');
|
||||
if (!file_exists(__DIR__.'/Fixtures/CaseMismatch.php')) {
|
||||
$this->markTestSkipped('Can only be run on case insensitive filesystems');
|
||||
@@ -98,7 +99,7 @@ class DebugClassLoaderTest extends TestCase
|
||||
|
||||
public function testPsr4CaseMismatch()
|
||||
{
|
||||
$this->expectException('RuntimeException');
|
||||
$this->expectException(\RuntimeException::class);
|
||||
$this->expectExceptionMessage('Case mismatch between loaded and declared class names');
|
||||
class_exists(__NAMESPACE__.'\Fixtures\Psr4CaseMismatch', true);
|
||||
}
|
||||
@@ -179,7 +180,7 @@ class DebugClassLoaderTest extends TestCase
|
||||
$e = error_reporting(0);
|
||||
trigger_error('', E_USER_NOTICE);
|
||||
|
||||
class_exists('Symfony\Bridge\Debug\Tests\Fixtures\ExtendsDeprecatedParent', true);
|
||||
class_exists(ExtendsDeprecatedParent::class, true);
|
||||
|
||||
error_reporting($e);
|
||||
restore_error_handler();
|
||||
|
||||
@@ -12,10 +12,12 @@
|
||||
namespace Symfony\Component\Debug\Tests;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use Psr\Log\LogLevel;
|
||||
use Psr\Log\NullLogger;
|
||||
use Symfony\Component\Debug\BufferingLogger;
|
||||
use Symfony\Component\Debug\ErrorHandler;
|
||||
use Symfony\Component\Debug\Exception\ClassNotFoundException;
|
||||
use Symfony\Component\Debug\Exception\SilencedErrorContext;
|
||||
use Symfony\Component\Debug\Tests\Fixtures\ErrorHandlerThatUsesThePreviousOne;
|
||||
use Symfony\Component\Debug\Tests\Fixtures\LoggerThatSetAnErrorHandler;
|
||||
@@ -35,7 +37,7 @@ class ErrorHandlerTest extends TestCase
|
||||
$handler = ErrorHandler::register();
|
||||
|
||||
try {
|
||||
$this->assertInstanceOf('Symfony\Component\Debug\ErrorHandler', $handler);
|
||||
$this->assertInstanceOf(ErrorHandler::class, $handler);
|
||||
$this->assertSame($handler, ErrorHandler::register());
|
||||
|
||||
$newHandler = new ErrorHandler();
|
||||
@@ -72,7 +74,7 @@ class ErrorHandlerTest extends TestCase
|
||||
|
||||
public function testErrorGetLast()
|
||||
{
|
||||
$logger = $this->getMockBuilder('Psr\Log\LoggerInterface')->getMock();
|
||||
$logger = $this->createMock(LoggerInterface::class);
|
||||
$handler = ErrorHandler::register();
|
||||
$handler->setDefaultLogger($logger);
|
||||
$handler->screamAt(\E_ALL);
|
||||
@@ -150,7 +152,7 @@ class ErrorHandlerTest extends TestCase
|
||||
public function testDefaultLogger()
|
||||
{
|
||||
try {
|
||||
$logger = $this->getMockBuilder('Psr\Log\LoggerInterface')->getMock();
|
||||
$logger = $this->createMock(LoggerInterface::class);
|
||||
$handler = ErrorHandler::register();
|
||||
|
||||
$handler->setDefaultLogger($logger, \E_NOTICE);
|
||||
@@ -225,7 +227,7 @@ class ErrorHandlerTest extends TestCase
|
||||
restore_error_handler();
|
||||
restore_exception_handler();
|
||||
|
||||
$logger = $this->getMockBuilder('Psr\Log\LoggerInterface')->getMock();
|
||||
$logger = $this->createMock(LoggerInterface::class);
|
||||
|
||||
$warnArgCheck = function ($logLevel, $message, $context) {
|
||||
$this->assertEquals('info', $logLevel);
|
||||
@@ -250,7 +252,7 @@ class ErrorHandlerTest extends TestCase
|
||||
restore_error_handler();
|
||||
restore_exception_handler();
|
||||
|
||||
$logger = $this->getMockBuilder('Psr\Log\LoggerInterface')->getMock();
|
||||
$logger = $this->createMock(LoggerInterface::class);
|
||||
|
||||
$line = null;
|
||||
$logArgCheck = function ($level, $message, $context) use (&$line) {
|
||||
@@ -355,7 +357,7 @@ class ErrorHandlerTest extends TestCase
|
||||
$this->assertSame('User Deprecated: Foo deprecation', $exception->getMessage());
|
||||
};
|
||||
|
||||
$logger = $this->getMockBuilder('Psr\Log\LoggerInterface')->getMock();
|
||||
$logger = $this->createMock(LoggerInterface::class);
|
||||
$logger
|
||||
->expects($this->once())
|
||||
->method('log')
|
||||
@@ -370,7 +372,7 @@ class ErrorHandlerTest extends TestCase
|
||||
public function testHandleException()
|
||||
{
|
||||
try {
|
||||
$logger = $this->getMockBuilder('Psr\Log\LoggerInterface')->getMock();
|
||||
$logger = $this->createMock(LoggerInterface::class);
|
||||
$handler = ErrorHandler::register();
|
||||
|
||||
$exception = new \Exception('foo');
|
||||
@@ -450,7 +452,7 @@ class ErrorHandlerTest extends TestCase
|
||||
|
||||
$bootLogger->log(LogLevel::WARNING, 'Foo message', ['exception' => $exception]);
|
||||
|
||||
$mockLogger = $this->getMockBuilder('Psr\Log\LoggerInterface')->getMock();
|
||||
$mockLogger = $this->createMock(LoggerInterface::class);
|
||||
$mockLogger->expects($this->once())
|
||||
->method('log')
|
||||
->with(LogLevel::WARNING, 'Foo message', ['exception' => $exception]);
|
||||
@@ -465,7 +467,7 @@ class ErrorHandlerTest extends TestCase
|
||||
|
||||
$exception = new \Exception('Foo message');
|
||||
|
||||
$mockLogger = $this->getMockBuilder('Psr\Log\LoggerInterface')->getMock();
|
||||
$mockLogger = $this->createMock(LoggerInterface::class);
|
||||
$mockLogger->expects($this->once())
|
||||
->method('log')
|
||||
->with(LogLevel::CRITICAL, 'Uncaught Exception: Foo message', ['exception' => $exception]);
|
||||
@@ -480,7 +482,7 @@ class ErrorHandlerTest extends TestCase
|
||||
public function testHandleFatalError()
|
||||
{
|
||||
try {
|
||||
$logger = $this->getMockBuilder('Psr\Log\LoggerInterface')->getMock();
|
||||
$logger = $this->createMock(LoggerInterface::class);
|
||||
$handler = ErrorHandler::register();
|
||||
|
||||
$error = [
|
||||
@@ -527,13 +529,13 @@ class ErrorHandlerTest extends TestCase
|
||||
|
||||
$handler->handleException($exception);
|
||||
|
||||
$this->assertInstanceOf('Symfony\Component\Debug\Exception\ClassNotFoundException', $args[0]);
|
||||
$this->assertInstanceOf(ClassNotFoundException::class, $args[0]);
|
||||
$this->assertStringStartsWith("Attempted to load class \"IReallyReallyDoNotExistAnywhereInTheRepositoryISwear\" from the global namespace.\nDid you forget a \"use\" statement", $args[0]->getMessage());
|
||||
}
|
||||
|
||||
public function testCustomExceptionHandler()
|
||||
{
|
||||
$this->expectException('Exception');
|
||||
$this->expectException(\Exception::class);
|
||||
$handler = new ErrorHandler();
|
||||
$handler->setExceptionHandler(function ($e) use ($handler) {
|
||||
$handler->handleException($e);
|
||||
|
||||
@@ -286,7 +286,7 @@ class FlattenExceptionTest extends TestCase
|
||||
|
||||
$args = $array[$i++];
|
||||
$this->assertSame($args[0], 'object');
|
||||
$this->assertTrue('Closure' === $args[1] || is_subclass_of($args[1], '\Closure'), 'Expect object class name to be Closure or a subclass of Closure.');
|
||||
$this->assertTrue('Closure' === $args[1] || is_subclass_of($args[1], \Closure::class), 'Expect object class name to be Closure or a subclass of Closure.');
|
||||
|
||||
$this->assertSame(['array', [['integer', 1], ['integer', 2]]], $array[$i++]);
|
||||
$this->assertSame(['array', ['foo' => ['integer', 123]]], $array[$i++]);
|
||||
|
||||
@@ -14,6 +14,7 @@ namespace Symfony\Component\Debug\Tests\FatalErrorHandler;
|
||||
use Composer\Autoload\ClassLoader as ComposerClassLoader;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Component\Debug\DebugClassLoader;
|
||||
use Symfony\Component\Debug\Exception\ClassNotFoundException;
|
||||
use Symfony\Component\Debug\Exception\FatalErrorException;
|
||||
use Symfony\Component\Debug\FatalErrorHandler\ClassNotFoundFatalErrorHandler;
|
||||
|
||||
@@ -67,7 +68,7 @@ class ClassNotFoundFatalErrorHandlerTest extends TestCase
|
||||
array_map('spl_autoload_register', $autoloaders);
|
||||
}
|
||||
|
||||
$this->assertInstanceOf('Symfony\Component\Debug\Exception\ClassNotFoundException', $exception);
|
||||
$this->assertInstanceOf(ClassNotFoundException::class, $exception);
|
||||
$this->assertMatchesRegularExpression($translatedMessage, $exception->getMessage());
|
||||
$this->assertSame($error['type'], $exception->getSeverity());
|
||||
$this->assertSame($error['file'], $exception->getFile());
|
||||
@@ -218,6 +219,6 @@ class ClassNotFoundFatalErrorHandlerTest extends TestCase
|
||||
$handler = new ClassNotFoundFatalErrorHandler();
|
||||
$exception = $handler->handleError($error, new FatalErrorException('', 0, $error['type'], $error['file'], $error['line']));
|
||||
|
||||
$this->assertInstanceOf('Symfony\Component\Debug\Exception\ClassNotFoundException', $exception);
|
||||
$this->assertInstanceOf(ClassNotFoundException::class, $exception);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,6 +13,7 @@ namespace Symfony\Component\Debug\Tests\FatalErrorHandler;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Component\Debug\Exception\FatalErrorException;
|
||||
use Symfony\Component\Debug\Exception\UndefinedFunctionException;
|
||||
use Symfony\Component\Debug\FatalErrorHandler\UndefinedFunctionFatalErrorHandler;
|
||||
|
||||
/**
|
||||
@@ -28,7 +29,7 @@ class UndefinedFunctionFatalErrorHandlerTest extends TestCase
|
||||
$handler = new UndefinedFunctionFatalErrorHandler();
|
||||
$exception = $handler->handleError($error, new FatalErrorException('', 0, $error['type'], $error['file'], $error['line']));
|
||||
|
||||
$this->assertInstanceOf('Symfony\Component\Debug\Exception\UndefinedFunctionException', $exception);
|
||||
$this->assertInstanceOf(UndefinedFunctionException::class, $exception);
|
||||
// class names are case insensitive and PHP do not return the same
|
||||
$this->assertSame(strtolower($translatedMessage), strtolower($exception->getMessage()));
|
||||
$this->assertSame($error['type'], $exception->getSeverity());
|
||||
|
||||
@@ -13,6 +13,7 @@ namespace Symfony\Component\Debug\Tests\FatalErrorHandler;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Component\Debug\Exception\FatalErrorException;
|
||||
use Symfony\Component\Debug\Exception\UndefinedMethodException;
|
||||
use Symfony\Component\Debug\FatalErrorHandler\UndefinedMethodFatalErrorHandler;
|
||||
|
||||
/**
|
||||
@@ -28,7 +29,7 @@ class UndefinedMethodFatalErrorHandlerTest extends TestCase
|
||||
$handler = new UndefinedMethodFatalErrorHandler();
|
||||
$exception = $handler->handleError($error, new FatalErrorException('', 0, $error['type'], $error['file'], $error['line']));
|
||||
|
||||
$this->assertInstanceOf('Symfony\Component\Debug\Exception\UndefinedMethodException', $exception);
|
||||
$this->assertInstanceOf(UndefinedMethodException::class, $exception);
|
||||
$this->assertSame($translatedMessage, $exception->getMessage());
|
||||
$this->assertSame($error['type'], $exception->getSeverity());
|
||||
$this->assertSame($error['file'], $exception->getFile());
|
||||
@@ -47,6 +48,15 @@ class UndefinedMethodFatalErrorHandlerTest extends TestCase
|
||||
],
|
||||
'Attempted to call an undefined method named "what" of class "SplObjectStorage".',
|
||||
],
|
||||
[
|
||||
[
|
||||
'type' => 1,
|
||||
'line' => 12,
|
||||
'file' => 'foo.php',
|
||||
'message' => 'Call to undefined method SplObjectStorage::()',
|
||||
],
|
||||
'Attempted to call an undefined method named "" of class "SplObjectStorage".',
|
||||
],
|
||||
[
|
||||
[
|
||||
'type' => 1,
|
||||
|
||||
@@ -1,5 +1,14 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Debug\Tests\Fixtures2;
|
||||
|
||||
class RequiredTwice
|
||||
|
||||
@@ -14,7 +14,7 @@ require $vendor.'/vendor/autoload.php';
|
||||
if (true) {
|
||||
class TestLogger extends \Psr\Log\AbstractLogger
|
||||
{
|
||||
public function log($level, $message, array $context = [])
|
||||
public function log($level, $message, array $context = []): void
|
||||
{
|
||||
echo $message, "\n";
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "symfony/debug",
|
||||
"type": "library",
|
||||
"description": "Symfony Debug Component",
|
||||
"description": "Provides tools to ease debugging PHP code",
|
||||
"keywords": [],
|
||||
"homepage": "https://symfony.com",
|
||||
"license": "MIT",
|
||||
@@ -17,8 +17,7 @@
|
||||
],
|
||||
"require": {
|
||||
"php": ">=7.1.3",
|
||||
"psr/log": "~1.0",
|
||||
"symfony/polyfill-php80": "^1.15"
|
||||
"psr/log": "^1|^2|^3"
|
||||
},
|
||||
"conflict": {
|
||||
"symfony/http-kernel": "<3.4"
|
||||
@@ -32,10 +31,5 @@
|
||||
"/Tests/"
|
||||
]
|
||||
},
|
||||
"minimum-stability": "dev",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "4.4-dev"
|
||||
}
|
||||
}
|
||||
"minimum-stability": "dev"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user