Skip to content

Commit a0fc232

Browse files
committed
Merge branch '4.4' into 5.1
* 4.4: Use ::class keyword when possible
2 parents f110812 + 0969043 commit a0fc232

File tree

3 files changed

+19
-19
lines changed

3 files changed

+19
-19
lines changed

DebugClassLoader.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -231,8 +231,8 @@ public function getClassLoader(): callable
231231
public static function enable(): void
232232
{
233233
// Ensures we don't hit https://bugs.php.net/42098
234-
class_exists('Symfony\Component\ErrorHandler\ErrorHandler');
235-
class_exists('Psr\Log\LogLevel');
234+
class_exists(\Symfony\Component\ErrorHandler\ErrorHandler::class);
235+
class_exists(\Psr\Log\LogLevel::class);
236236

237237
if (!\is_array($functions = spl_autoload_functions())) {
238238
return;

Tests/DebugClassLoaderTest.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public function testIdempotence()
5151
$reflProp = $reflClass->getProperty('classLoader');
5252
$reflProp->setAccessible(true);
5353

54-
$this->assertNotInstanceOf('Symfony\Component\ErrorHandler\DebugClassLoader', $reflProp->getValue($function[0]));
54+
$this->assertNotInstanceOf(DebugClassLoader::class, $reflProp->getValue($function[0]));
5555

5656
return;
5757
}
@@ -62,7 +62,7 @@ public function testIdempotence()
6262

6363
public function testThrowingClass()
6464
{
65-
$this->expectException('Exception');
65+
$this->expectException(\Exception::class);
6666
$this->expectExceptionMessage('boo');
6767
try {
6868
class_exists(Fixtures\Throwing::class);
@@ -77,14 +77,14 @@ class_exists(Fixtures\Throwing::class);
7777

7878
public function testNameCaseMismatch()
7979
{
80-
$this->expectException('RuntimeException');
80+
$this->expectException(\RuntimeException::class);
8181
$this->expectExceptionMessage('Case mismatch between loaded and declared class names');
8282
class_exists(TestingCaseMismatch::class, true);
8383
}
8484

8585
public function testFileCaseMismatch()
8686
{
87-
$this->expectException('RuntimeException');
87+
$this->expectException(\RuntimeException::class);
8888
$this->expectExceptionMessage('Case mismatch between class and real file names');
8989
if (!file_exists(__DIR__.'/Fixtures/CaseMismatch.php')) {
9090
$this->markTestSkipped('Can only be run on case insensitive filesystems');
@@ -95,7 +95,7 @@ class_exists(Fixtures\CaseMismatch::class, true);
9595

9696
public function testPsr4CaseMismatch()
9797
{
98-
$this->expectException('RuntimeException');
98+
$this->expectException(\RuntimeException::class);
9999
$this->expectExceptionMessage('Case mismatch between loaded and declared class names');
100100
class_exists(__NAMESPACE__.'\Fixtures\Psr4CaseMismatch', true);
101101
}
@@ -176,7 +176,7 @@ public function testDeprecatedSuperInSameNamespace()
176176
$e = error_reporting(0);
177177
trigger_error('', E_USER_NOTICE);
178178

179-
class_exists('Symfony\Bridge\ErrorHandler\Tests\Fixtures\ExtendsDeprecatedParent', true);
179+
class_exists(\Symfony\Bridge\ErrorHandler\Tests\Fixtures\ExtendsDeprecatedParent::class, true);
180180

181181
error_reporting($e);
182182
restore_error_handler();

Tests/ErrorHandlerTest.php

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public function testRegister()
3535
$handler = ErrorHandler::register();
3636

3737
try {
38-
$this->assertInstanceOf('Symfony\Component\ErrorHandler\ErrorHandler', $handler);
38+
$this->assertInstanceOf(ErrorHandler::class, $handler);
3939
$this->assertSame($handler, ErrorHandler::register());
4040

4141
$newHandler = new ErrorHandler();
@@ -62,7 +62,7 @@ public function testRegister()
6262

6363
public function testErrorGetLast()
6464
{
65-
$logger = $this->getMockBuilder('Psr\Log\LoggerInterface')->getMock();
65+
$logger = $this->getMockBuilder(\Psr\Log\LoggerInterface::class)->getMock();
6666
$handler = ErrorHandler::register();
6767
$handler->setDefaultLogger($logger);
6868
$handler->screamAt(\E_ALL);
@@ -194,7 +194,7 @@ public function testConstruct()
194194
public function testDefaultLogger()
195195
{
196196
try {
197-
$logger = $this->getMockBuilder('Psr\Log\LoggerInterface')->getMock();
197+
$logger = $this->getMockBuilder(\Psr\Log\LoggerInterface::class)->getMock();
198198
$handler = ErrorHandler::register();
199199

200200
$handler->setDefaultLogger($logger, \E_NOTICE);
@@ -269,7 +269,7 @@ public function testHandleError()
269269
restore_error_handler();
270270
restore_exception_handler();
271271

272-
$logger = $this->getMockBuilder('Psr\Log\LoggerInterface')->getMock();
272+
$logger = $this->getMockBuilder(\Psr\Log\LoggerInterface::class)->getMock();
273273

274274
$warnArgCheck = function ($logLevel, $message, $context) {
275275
$this->assertEquals('info', $logLevel);
@@ -294,7 +294,7 @@ public function testHandleError()
294294
restore_error_handler();
295295
restore_exception_handler();
296296

297-
$logger = $this->getMockBuilder('Psr\Log\LoggerInterface')->getMock();
297+
$logger = $this->getMockBuilder(\Psr\Log\LoggerInterface::class)->getMock();
298298

299299
$line = null;
300300
$logArgCheck = function ($level, $message, $context) use (&$line) {
@@ -395,7 +395,7 @@ public function testHandleDeprecation()
395395
$this->assertSame('User Deprecated: Foo deprecation', $exception->getMessage());
396396
};
397397

398-
$logger = $this->getMockBuilder('Psr\Log\LoggerInterface')->getMock();
398+
$logger = $this->getMockBuilder(\Psr\Log\LoggerInterface::class)->getMock();
399399
$logger
400400
->expects($this->once())
401401
->method('log')
@@ -413,7 +413,7 @@ public function testHandleDeprecation()
413413
public function testHandleException(string $expectedMessage, \Throwable $exception)
414414
{
415415
try {
416-
$logger = $this->getMockBuilder('Psr\Log\LoggerInterface')->getMock();
416+
$logger = $this->getMockBuilder(\Psr\Log\LoggerInterface::class)->getMock();
417417
$handler = ErrorHandler::register();
418418

419419
$logArgCheck = function ($level, $message, $context) use ($expectedMessage, $exception) {
@@ -505,7 +505,7 @@ public function testBootstrappingLogger()
505505

506506
$bootLogger->log(LogLevel::WARNING, 'Foo message', ['exception' => $exception]);
507507

508-
$mockLogger = $this->getMockBuilder('Psr\Log\LoggerInterface')->getMock();
508+
$mockLogger = $this->getMockBuilder(\Psr\Log\LoggerInterface::class)->getMock();
509509
$mockLogger->expects($this->once())
510510
->method('log')
511511
->with(LogLevel::WARNING, 'Foo message', ['exception' => $exception]);
@@ -520,7 +520,7 @@ public function testSettingLoggerWhenExceptionIsBuffered()
520520

521521
$exception = new \Exception('Foo message');
522522

523-
$mockLogger = $this->getMockBuilder('Psr\Log\LoggerInterface')->getMock();
523+
$mockLogger = $this->getMockBuilder(\Psr\Log\LoggerInterface::class)->getMock();
524524
$mockLogger->expects($this->once())
525525
->method('log')
526526
->with(LogLevel::CRITICAL, 'Uncaught Exception: Foo message', ['exception' => $exception]);
@@ -535,7 +535,7 @@ public function testSettingLoggerWhenExceptionIsBuffered()
535535
public function testHandleFatalError()
536536
{
537537
try {
538-
$logger = $this->getMockBuilder('Psr\Log\LoggerInterface')->getMock();
538+
$logger = $this->getMockBuilder(\Psr\Log\LoggerInterface::class)->getMock();
539539
$handler = ErrorHandler::register();
540540

541541
$error = [
@@ -584,7 +584,7 @@ public function testHandleErrorException()
584584

585585
public function testCustomExceptionHandler()
586586
{
587-
$this->expectException('Exception');
587+
$this->expectException(\Exception::class);
588588
$handler = new ErrorHandler();
589589
$handler->setExceptionHandler(function ($e) use ($handler) {
590590
$handler->setExceptionHandler(null);

0 commit comments

Comments
 (0)