From 5768cc007bad4742dae66c05451abd15c1227e00 Mon Sep 17 00:00:00 2001 From: "Alexander M. Turek" Date: Sun, 27 Dec 2020 00:49:32 +0100 Subject: [PATCH 1/6] CS: Apply ternary_to_null_coalescing fixer --- ErrorHandler.php | 2 +- Exception/FlattenException.php | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/ErrorHandler.php b/ErrorHandler.php index 6d562c5..6da37ff 100644 --- a/ErrorHandler.php +++ b/ErrorHandler.php @@ -636,7 +636,7 @@ public static function handleFatalError(array $error = null) 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); diff --git a/Exception/FlattenException.php b/Exception/FlattenException.php index b48769a..8e877b0 100644 --- a/Exception/FlattenException.php +++ b/Exception/FlattenException.php @@ -281,11 +281,11 @@ public function setTrace($trace, $file, $line) $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']) : [], ]; } From ebcaaad20c21eda73303ec549a82b669dbe1a02f Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Fri, 1 Jan 2021 10:24:35 +0100 Subject: [PATCH 2/6] Bump license year --- LICENSE | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/LICENSE b/LICENSE index 9e936ec..9ff2d0d 100644 --- a/LICENSE +++ b/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2004-2020 Fabien Potencier +Copyright (c) 2004-2021 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 From 7f265ded6fa84be15db60f9fc173a1a39649c9d1 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Sun, 10 Jan 2021 09:16:05 +0100 Subject: [PATCH 3/6] Improve composer.json descriptions --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index e54a603..a364eb7 100644 --- a/composer.json +++ b/composer.json @@ -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", From 84de62e42e5cc50f4a723d05e80ab4b88eecf64b Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Sun, 10 Jan 2021 13:29:43 +0100 Subject: [PATCH 4/6] Use ::class keyword when possible --- Tests/Exception/FlattenExceptionTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Tests/Exception/FlattenExceptionTest.php b/Tests/Exception/FlattenExceptionTest.php index 6d89a0c..ea441b3 100644 --- a/Tests/Exception/FlattenExceptionTest.php +++ b/Tests/Exception/FlattenExceptionTest.php @@ -286,7 +286,7 @@ function () {}, $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++]); From edfa86f186c81bd24c72d215981464ea81eba62f Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Mon, 11 Jan 2021 09:47:58 +0100 Subject: [PATCH 5/6] Use ::class keyword when possible --- DebugClassLoader.php | 4 ++-- ErrorHandler.php | 2 +- Exception/FatalErrorException.php | 2 +- Tests/DebugClassLoaderTest.php | 12 +++++----- Tests/ErrorHandlerTest.php | 24 +++++++++---------- .../ClassNotFoundFatalErrorHandlerTest.php | 4 ++-- ...UndefinedFunctionFatalErrorHandlerTest.php | 2 +- .../UndefinedMethodFatalErrorHandlerTest.php | 2 +- 8 files changed, 26 insertions(+), 26 deletions(-) diff --git a/DebugClassLoader.php b/DebugClassLoader.php index cf27907..6081c52 100644 --- a/DebugClassLoader.php +++ b/DebugClassLoader.php @@ -90,8 +90,8 @@ public function getClassLoader() 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; diff --git a/ErrorHandler.php b/ErrorHandler.php index 6da37ff..fd22f20 100644 --- a/ErrorHandler.php +++ b/ErrorHandler.php @@ -169,7 +169,7 @@ public function __construct(BufferingLogger $bootstrappingLogger = null) $this->bootstrappingLogger = $bootstrappingLogger; $this->setDefaultLogger($bootstrappingLogger); } - $this->traceReflector = new \ReflectionProperty('Exception', 'trace'); + $this->traceReflector = new \ReflectionProperty(\Exception::class, 'trace'); $this->traceReflector->setAccessible(true); } diff --git a/Exception/FatalErrorException.php b/Exception/FatalErrorException.php index ca34265..a9fd7bb 100644 --- a/Exception/FatalErrorException.php +++ b/Exception/FatalErrorException.php @@ -74,7 +74,7 @@ public function __construct(string $message, int $code, int $severity, string $f protected function setTrace($trace) { - $traceReflector = new \ReflectionProperty('Exception', 'trace'); + $traceReflector = new \ReflectionProperty(\Exception::class, 'trace'); $traceReflector->setAccessible(true); $traceReflector->setValue($this, $trace); } diff --git a/Tests/DebugClassLoaderTest.php b/Tests/DebugClassLoaderTest.php index c946607..dc9617d 100644 --- a/Tests/DebugClassLoaderTest.php +++ b/Tests/DebugClassLoaderTest.php @@ -54,7 +54,7 @@ public function testIdempotence() $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 +65,7 @@ public function testIdempotence() public function testThrowingClass() { - $this->expectException('Exception'); + $this->expectException(\Exception::class); $this->expectExceptionMessage('boo'); try { class_exists(Fixtures\Throwing::class); @@ -80,14 +80,14 @@ class_exists(Fixtures\Throwing::class); 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 +98,7 @@ class_exists(Fixtures\CaseMismatch::class, true); 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 +179,7 @@ public function testDeprecatedSuperInSameNamespace() $e = error_reporting(0); trigger_error('', E_USER_NOTICE); - class_exists('Symfony\Bridge\Debug\Tests\Fixtures\ExtendsDeprecatedParent', true); + class_exists(\Symfony\Bridge\Debug\Tests\Fixtures\ExtendsDeprecatedParent::class, true); error_reporting($e); restore_error_handler(); diff --git a/Tests/ErrorHandlerTest.php b/Tests/ErrorHandlerTest.php index 9f60182..6c2b31a 100644 --- a/Tests/ErrorHandlerTest.php +++ b/Tests/ErrorHandlerTest.php @@ -35,7 +35,7 @@ public function testRegister() $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 +72,7 @@ public function testRegister() public function testErrorGetLast() { - $logger = $this->getMockBuilder('Psr\Log\LoggerInterface')->getMock(); + $logger = $this->getMockBuilder(\Psr\Log\LoggerInterface::class)->getMock(); $handler = ErrorHandler::register(); $handler->setDefaultLogger($logger); $handler->screamAt(\E_ALL); @@ -150,7 +150,7 @@ public function testConstruct() public function testDefaultLogger() { try { - $logger = $this->getMockBuilder('Psr\Log\LoggerInterface')->getMock(); + $logger = $this->getMockBuilder(\Psr\Log\LoggerInterface::class)->getMock(); $handler = ErrorHandler::register(); $handler->setDefaultLogger($logger, \E_NOTICE); @@ -225,7 +225,7 @@ public function testHandleError() restore_error_handler(); restore_exception_handler(); - $logger = $this->getMockBuilder('Psr\Log\LoggerInterface')->getMock(); + $logger = $this->getMockBuilder(\Psr\Log\LoggerInterface::class)->getMock(); $warnArgCheck = function ($logLevel, $message, $context) { $this->assertEquals('info', $logLevel); @@ -250,7 +250,7 @@ public function testHandleError() restore_error_handler(); restore_exception_handler(); - $logger = $this->getMockBuilder('Psr\Log\LoggerInterface')->getMock(); + $logger = $this->getMockBuilder(\Psr\Log\LoggerInterface::class)->getMock(); $line = null; $logArgCheck = function ($level, $message, $context) use (&$line) { @@ -355,7 +355,7 @@ public function testHandleDeprecation() $this->assertSame('User Deprecated: Foo deprecation', $exception->getMessage()); }; - $logger = $this->getMockBuilder('Psr\Log\LoggerInterface')->getMock(); + $logger = $this->getMockBuilder(\Psr\Log\LoggerInterface::class)->getMock(); $logger ->expects($this->once()) ->method('log') @@ -370,7 +370,7 @@ public function testHandleDeprecation() public function testHandleException() { try { - $logger = $this->getMockBuilder('Psr\Log\LoggerInterface')->getMock(); + $logger = $this->getMockBuilder(\Psr\Log\LoggerInterface::class)->getMock(); $handler = ErrorHandler::register(); $exception = new \Exception('foo'); @@ -450,7 +450,7 @@ public function testBootstrappingLogger() $bootLogger->log(LogLevel::WARNING, 'Foo message', ['exception' => $exception]); - $mockLogger = $this->getMockBuilder('Psr\Log\LoggerInterface')->getMock(); + $mockLogger = $this->getMockBuilder(\Psr\Log\LoggerInterface::class)->getMock(); $mockLogger->expects($this->once()) ->method('log') ->with(LogLevel::WARNING, 'Foo message', ['exception' => $exception]); @@ -465,7 +465,7 @@ public function testSettingLoggerWhenExceptionIsBuffered() $exception = new \Exception('Foo message'); - $mockLogger = $this->getMockBuilder('Psr\Log\LoggerInterface')->getMock(); + $mockLogger = $this->getMockBuilder(\Psr\Log\LoggerInterface::class)->getMock(); $mockLogger->expects($this->once()) ->method('log') ->with(LogLevel::CRITICAL, 'Uncaught Exception: Foo message', ['exception' => $exception]); @@ -480,7 +480,7 @@ public function testSettingLoggerWhenExceptionIsBuffered() public function testHandleFatalError() { try { - $logger = $this->getMockBuilder('Psr\Log\LoggerInterface')->getMock(); + $logger = $this->getMockBuilder(\Psr\Log\LoggerInterface::class)->getMock(); $handler = ErrorHandler::register(); $error = [ @@ -527,13 +527,13 @@ public function testHandleErrorException() $handler->handleException($exception); - $this->assertInstanceOf('Symfony\Component\Debug\Exception\ClassNotFoundException', $args[0]); + $this->assertInstanceOf(\Symfony\Component\Debug\Exception\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); diff --git a/Tests/FatalErrorHandler/ClassNotFoundFatalErrorHandlerTest.php b/Tests/FatalErrorHandler/ClassNotFoundFatalErrorHandlerTest.php index 061b645..592a1eb 100644 --- a/Tests/FatalErrorHandler/ClassNotFoundFatalErrorHandlerTest.php +++ b/Tests/FatalErrorHandler/ClassNotFoundFatalErrorHandlerTest.php @@ -67,7 +67,7 @@ public function testHandleClassNotFound($error, $translatedMessage, $autoloader array_map('spl_autoload_register', $autoloaders); } - $this->assertInstanceOf('Symfony\Component\Debug\Exception\ClassNotFoundException', $exception); + $this->assertInstanceOf(\Symfony\Component\Debug\Exception\ClassNotFoundException::class, $exception); $this->assertMatchesRegularExpression($translatedMessage, $exception->getMessage()); $this->assertSame($error['type'], $exception->getSeverity()); $this->assertSame($error['file'], $exception->getFile()); @@ -218,6 +218,6 @@ public function testCannotRedeclareClass() $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(\Symfony\Component\Debug\Exception\ClassNotFoundException::class, $exception); } } diff --git a/Tests/FatalErrorHandler/UndefinedFunctionFatalErrorHandlerTest.php b/Tests/FatalErrorHandler/UndefinedFunctionFatalErrorHandlerTest.php index b827c4c..e46b429 100644 --- a/Tests/FatalErrorHandler/UndefinedFunctionFatalErrorHandlerTest.php +++ b/Tests/FatalErrorHandler/UndefinedFunctionFatalErrorHandlerTest.php @@ -28,7 +28,7 @@ public function testUndefinedFunction($error, $translatedMessage) $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(\Symfony\Component\Debug\Exception\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()); diff --git a/Tests/FatalErrorHandler/UndefinedMethodFatalErrorHandlerTest.php b/Tests/FatalErrorHandler/UndefinedMethodFatalErrorHandlerTest.php index 7ea1b1f..d1b8018 100644 --- a/Tests/FatalErrorHandler/UndefinedMethodFatalErrorHandlerTest.php +++ b/Tests/FatalErrorHandler/UndefinedMethodFatalErrorHandlerTest.php @@ -28,7 +28,7 @@ public function testUndefinedMethod($error, $translatedMessage) $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(\Symfony\Component\Debug\Exception\UndefinedMethodException::class, $exception); $this->assertSame($translatedMessage, $exception->getMessage()); $this->assertSame($error['type'], $exception->getSeverity()); $this->assertSame($error['file'], $exception->getFile()); From af4987aa4a5630e9615be9d9c3ed1b0f24ca449c Mon Sep 17 00:00:00 2001 From: Oskar Stark Date: Fri, 22 Jan 2021 13:09:22 +0100 Subject: [PATCH 6/6] Use createMock() and use import instead of FQCN --- Tests/DebugClassLoaderTest.php | 3 ++- Tests/ErrorHandlerTest.php | 22 ++++++++++--------- .../ClassNotFoundFatalErrorHandlerTest.php | 5 +++-- ...UndefinedFunctionFatalErrorHandlerTest.php | 3 ++- .../UndefinedMethodFatalErrorHandlerTest.php | 3 ++- 5 files changed, 21 insertions(+), 15 deletions(-) diff --git a/Tests/DebugClassLoaderTest.php b/Tests/DebugClassLoaderTest.php index dc9617d..0e91ef0 100644 --- a/Tests/DebugClassLoaderTest.php +++ b/Tests/DebugClassLoaderTest.php @@ -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; /** @@ -179,7 +180,7 @@ public function testDeprecatedSuperInSameNamespace() $e = error_reporting(0); trigger_error('', E_USER_NOTICE); - class_exists(\Symfony\Bridge\Debug\Tests\Fixtures\ExtendsDeprecatedParent::class, true); + class_exists(ExtendsDeprecatedParent::class, true); error_reporting($e); restore_error_handler(); diff --git a/Tests/ErrorHandlerTest.php b/Tests/ErrorHandlerTest.php index 6c2b31a..1fa2ca1 100644 --- a/Tests/ErrorHandlerTest.php +++ b/Tests/ErrorHandlerTest.php @@ -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; @@ -72,7 +74,7 @@ public function testRegister() public function testErrorGetLast() { - $logger = $this->getMockBuilder(\Psr\Log\LoggerInterface::class)->getMock(); + $logger = $this->createMock(LoggerInterface::class); $handler = ErrorHandler::register(); $handler->setDefaultLogger($logger); $handler->screamAt(\E_ALL); @@ -150,7 +152,7 @@ public function testConstruct() public function testDefaultLogger() { try { - $logger = $this->getMockBuilder(\Psr\Log\LoggerInterface::class)->getMock(); + $logger = $this->createMock(LoggerInterface::class); $handler = ErrorHandler::register(); $handler->setDefaultLogger($logger, \E_NOTICE); @@ -225,7 +227,7 @@ public function testHandleError() restore_error_handler(); restore_exception_handler(); - $logger = $this->getMockBuilder(\Psr\Log\LoggerInterface::class)->getMock(); + $logger = $this->createMock(LoggerInterface::class); $warnArgCheck = function ($logLevel, $message, $context) { $this->assertEquals('info', $logLevel); @@ -250,7 +252,7 @@ public function testHandleError() restore_error_handler(); restore_exception_handler(); - $logger = $this->getMockBuilder(\Psr\Log\LoggerInterface::class)->getMock(); + $logger = $this->createMock(LoggerInterface::class); $line = null; $logArgCheck = function ($level, $message, $context) use (&$line) { @@ -355,7 +357,7 @@ public function testHandleDeprecation() $this->assertSame('User Deprecated: Foo deprecation', $exception->getMessage()); }; - $logger = $this->getMockBuilder(\Psr\Log\LoggerInterface::class)->getMock(); + $logger = $this->createMock(LoggerInterface::class); $logger ->expects($this->once()) ->method('log') @@ -370,7 +372,7 @@ public function testHandleDeprecation() public function testHandleException() { try { - $logger = $this->getMockBuilder(\Psr\Log\LoggerInterface::class)->getMock(); + $logger = $this->createMock(LoggerInterface::class); $handler = ErrorHandler::register(); $exception = new \Exception('foo'); @@ -450,7 +452,7 @@ public function testBootstrappingLogger() $bootLogger->log(LogLevel::WARNING, 'Foo message', ['exception' => $exception]); - $mockLogger = $this->getMockBuilder(\Psr\Log\LoggerInterface::class)->getMock(); + $mockLogger = $this->createMock(LoggerInterface::class); $mockLogger->expects($this->once()) ->method('log') ->with(LogLevel::WARNING, 'Foo message', ['exception' => $exception]); @@ -465,7 +467,7 @@ public function testSettingLoggerWhenExceptionIsBuffered() $exception = new \Exception('Foo message'); - $mockLogger = $this->getMockBuilder(\Psr\Log\LoggerInterface::class)->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 @@ public function testSettingLoggerWhenExceptionIsBuffered() public function testHandleFatalError() { try { - $logger = $this->getMockBuilder(\Psr\Log\LoggerInterface::class)->getMock(); + $logger = $this->createMock(LoggerInterface::class); $handler = ErrorHandler::register(); $error = [ @@ -527,7 +529,7 @@ public function testHandleErrorException() $handler->handleException($exception); - $this->assertInstanceOf(\Symfony\Component\Debug\Exception\ClassNotFoundException::class, $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()); } diff --git a/Tests/FatalErrorHandler/ClassNotFoundFatalErrorHandlerTest.php b/Tests/FatalErrorHandler/ClassNotFoundFatalErrorHandlerTest.php index 592a1eb..7e2406d 100644 --- a/Tests/FatalErrorHandler/ClassNotFoundFatalErrorHandlerTest.php +++ b/Tests/FatalErrorHandler/ClassNotFoundFatalErrorHandlerTest.php @@ -14,6 +14,7 @@ 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 @@ public function testHandleClassNotFound($error, $translatedMessage, $autoloader array_map('spl_autoload_register', $autoloaders); } - $this->assertInstanceOf(\Symfony\Component\Debug\Exception\ClassNotFoundException::class, $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 @@ public function testCannotRedeclareClass() $handler = new ClassNotFoundFatalErrorHandler(); $exception = $handler->handleError($error, new FatalErrorException('', 0, $error['type'], $error['file'], $error['line'])); - $this->assertInstanceOf(\Symfony\Component\Debug\Exception\ClassNotFoundException::class, $exception); + $this->assertInstanceOf(ClassNotFoundException::class, $exception); } } diff --git a/Tests/FatalErrorHandler/UndefinedFunctionFatalErrorHandlerTest.php b/Tests/FatalErrorHandler/UndefinedFunctionFatalErrorHandlerTest.php index e46b429..7406d7f 100644 --- a/Tests/FatalErrorHandler/UndefinedFunctionFatalErrorHandlerTest.php +++ b/Tests/FatalErrorHandler/UndefinedFunctionFatalErrorHandlerTest.php @@ -13,6 +13,7 @@ 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 @@ public function testUndefinedFunction($error, $translatedMessage) $handler = new UndefinedFunctionFatalErrorHandler(); $exception = $handler->handleError($error, new FatalErrorException('', 0, $error['type'], $error['file'], $error['line'])); - $this->assertInstanceOf(\Symfony\Component\Debug\Exception\UndefinedFunctionException::class, $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()); diff --git a/Tests/FatalErrorHandler/UndefinedMethodFatalErrorHandlerTest.php b/Tests/FatalErrorHandler/UndefinedMethodFatalErrorHandlerTest.php index d1b8018..55f2f62 100644 --- a/Tests/FatalErrorHandler/UndefinedMethodFatalErrorHandlerTest.php +++ b/Tests/FatalErrorHandler/UndefinedMethodFatalErrorHandlerTest.php @@ -13,6 +13,7 @@ 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 @@ public function testUndefinedMethod($error, $translatedMessage) $handler = new UndefinedMethodFatalErrorHandler(); $exception = $handler->handleError($error, new FatalErrorException('', 0, $error['type'], $error['file'], $error['line'])); - $this->assertInstanceOf(\Symfony\Component\Debug\Exception\UndefinedMethodException::class, $exception); + $this->assertInstanceOf(UndefinedMethodException::class, $exception); $this->assertSame($translatedMessage, $exception->getMessage()); $this->assertSame($error['type'], $exception->getSeverity()); $this->assertSame($error['file'], $exception->getFile());