Skip to content

Commit 586e1ac

Browse files
committed
Merge branch '5.1' into 5.2
* 5.1: Use ::class keyword when possible
2 parents 94fcee7 + cff3d37 commit 586e1ac

File tree

6 files changed

+17
-17
lines changed

6 files changed

+17
-17
lines changed

DeprecationErrorHandler.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,7 @@ private function displayDeprecations($groups, $configuration, $isFailing)
338338
private static function getPhpUnitErrorHandler()
339339
{
340340
if (!isset(self::$isAtLeastPhpUnit83)) {
341-
self::$isAtLeastPhpUnit83 = class_exists('PHPUnit\Util\ErrorHandler') && method_exists('PHPUnit\Util\ErrorHandler', '__invoke');
341+
self::$isAtLeastPhpUnit83 = class_exists(ErrorHandler::class) && method_exists(ErrorHandler::class, '__invoke');
342342
}
343343
if (!self::$isAtLeastPhpUnit83) {
344344
return 'PHPUnit\Util\ErrorHandler::handleError';

Legacy/SymfonyTestsListenerTrait.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,8 +135,8 @@ public function startTestSuite($suite)
135135
echo "Testing $suiteName\n";
136136
$this->state = 0;
137137

138-
if (!class_exists('Doctrine\Common\Annotations\AnnotationRegistry', false) && class_exists('Doctrine\Common\Annotations\AnnotationRegistry')) {
139-
if (method_exists('Doctrine\Common\Annotations\AnnotationRegistry', 'registerUniqueLoader')) {
138+
if (!class_exists(AnnotationRegistry::class, false) && class_exists(AnnotationRegistry::class)) {
139+
if (method_exists(AnnotationRegistry::class, 'registerUniqueLoader')) {
140140
AnnotationRegistry::registerUniqueLoader('class_exists');
141141
} else {
142142
AnnotationRegistry::registerLoader('class_exists');

Tests/Fixtures/coverage/tests/BarCovTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ class BarCovTest extends TestCase
1717
{
1818
public function testBarCov()
1919
{
20-
if (!class_exists('PhpUnitCoverageTest\FooCov')) {
20+
if (!class_exists(\PhpUnitCoverageTest\FooCov::class)) {
2121
$this->markTestSkipped('This test is not part of the main Symfony test suite. It\'s here to test the CoverageListener.');
2222
}
2323

Tests/ProcessIsolationTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public function testIsolation()
2424

2525
public function testCallingOtherErrorHandler()
2626
{
27-
$this->expectException('PHPUnit\Framework\Exception');
27+
$this->expectException(\PHPUnit\Framework\Exception::class);
2828
$this->expectExceptionMessage('Test that PHPUnit\'s error handler fires.');
2929

3030
trigger_error('Test that PHPUnit\'s error handler fires.', \E_USER_WARNING);

bin/simple-phpunit.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -269,17 +269,17 @@
269269
define('PHPUNIT_COMPOSER_INSTALL', __DIR__.'/vendor/autoload.php');
270270
require PHPUNIT_COMPOSER_INSTALL;
271271
272-
if (!class_exists('SymfonyExcludeListPhpunit', false)) {
272+
if (!class_exists(\SymfonyExcludeListPhpunit::class, false)) {
273273
class SymfonyExcludeListPhpunit {}
274274
}
275-
if (method_exists('PHPUnit\Util\ExcludeList', 'addDirectory')) {
275+
if (method_exists(\PHPUnit\Util\ExcludeList::class, 'addDirectory')) {
276276
(new PHPUnit\Util\Excludelist())->getExcludedDirectories();
277-
PHPUnit\Util\ExcludeList::addDirectory(\dirname((new \ReflectionClass('SymfonyExcludeListPhpunit'))->getFileName()));
278-
class_exists('SymfonyExcludeListSimplePhpunit', false) && PHPUnit\Util\ExcludeList::addDirectory(\dirname((new \ReflectionClass('SymfonyExcludeListSimplePhpunit'))->getFileName()));
279-
} elseif (method_exists('PHPUnit\Util\Blacklist', 'addDirectory')) {
277+
PHPUnit\Util\ExcludeList::addDirectory(\dirname((new \ReflectionClass(\SymfonyExcludeListPhpunit::class))->getFileName()));
278+
class_exists(\SymfonyExcludeListSimplePhpunit::class, false) && PHPUnit\Util\ExcludeList::addDirectory(\dirname((new \ReflectionClass(\SymfonyExcludeListSimplePhpunit::class))->getFileName()));
279+
} elseif (method_exists(\PHPUnit\Util\Blacklist::class, 'addDirectory')) {
280280
(new PHPUnit\Util\BlackList())->getBlacklistedDirectories();
281-
PHPUnit\Util\Blacklist::addDirectory(\dirname((new \ReflectionClass('SymfonyExcludeListPhpunit'))->getFileName()));
282-
class_exists('SymfonyExcludeListSimplePhpunit', false) && PHPUnit\Util\Blacklist::addDirectory(\dirname((new \ReflectionClass('SymfonyExcludeListSimplePhpunit'))->getFileName()));
281+
PHPUnit\Util\Blacklist::addDirectory(\dirname((new \ReflectionClass(\SymfonyExcludeListPhpunit::class))->getFileName()));
282+
class_exists(\SymfonyExcludeListSimplePhpunit::class, false) && PHPUnit\Util\Blacklist::addDirectory(\dirname((new \ReflectionClass(\SymfonyExcludeListSimplePhpunit::class))->getFileName()));
283283
} else {
284284
PHPUnit\Util\Blacklist::$blacklistedClassNames['SymfonyExcludeListPhpunit'] = 1;
285285
PHPUnit\Util\Blacklist::$blacklistedClassNames['SymfonyExcludeListSimplePhpunit'] = 1;
@@ -404,7 +404,7 @@ class_exists('SymfonyExcludeListSimplePhpunit', false) && PHPUnit\Util\Blacklist
404404
}
405405
}
406406
} elseif (!isset($argv[1]) || 'install' !== $argv[1] || file_exists('install')) {
407-
if (!class_exists('SymfonyExcludeListSimplePhpunit', false)) {
407+
if (!class_exists(\SymfonyExcludeListSimplePhpunit::class, false)) {
408408
class SymfonyExcludeListSimplePhpunit
409409
{
410410
}

bootstrap.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
use Doctrine\Common\Annotations\AnnotationRegistry;
1313
use Symfony\Bridge\PhpUnit\DeprecationErrorHandler;
1414

15-
if (class_exists('PHPUnit_Runner_Version') && version_compare(\PHPUnit_Runner_Version::id(), '6.0.0', '<')) {
15+
if (class_exists(\PHPUnit_Runner_Version::class) && version_compare(\PHPUnit_Runner_Version::id(), '6.0.0', '<')) {
1616
$classes = [
1717
'PHPUnit_Framework_Assert', // override PhpUnit's ForwardCompat child class
1818
'PHPUnit_Framework_AssertionFailedError', // override PhpUnit's ForwardCompat child class
@@ -110,15 +110,15 @@ class_alias('PHPUnit_Framework_Error', 'PHPUnit\Framework\Error\Error');
110110
}
111111

112112
// Detect if we're loaded by an actual run of phpunit
113-
if (!defined('PHPUNIT_COMPOSER_INSTALL') && !class_exists('PHPUnit_TextUI_Command', false) && !class_exists('PHPUnit\TextUI\Command', false)) {
113+
if (!defined('PHPUNIT_COMPOSER_INSTALL') && !class_exists(\PHPUnit_TextUI_Command::class, false) && !class_exists(\PHPUnit\TextUI\Command::class, false)) {
114114
return;
115115
}
116116

117117
// Enforce a consistent locale
118118
setlocale(\LC_ALL, 'C');
119119

120-
if (!class_exists('Doctrine\Common\Annotations\AnnotationRegistry', false) && class_exists('Doctrine\Common\Annotations\AnnotationRegistry')) {
121-
if (method_exists('Doctrine\Common\Annotations\AnnotationRegistry', 'registerUniqueLoader')) {
120+
if (!class_exists(AnnotationRegistry::class, false) && class_exists(AnnotationRegistry::class)) {
121+
if (method_exists(AnnotationRegistry::class, 'registerUniqueLoader')) {
122122
AnnotationRegistry::registerUniqueLoader('class_exists');
123123
} else {
124124
AnnotationRegistry::registerLoader('class_exists');

0 commit comments

Comments
 (0)