Skip to content

Commit 082fd04

Browse files
committed
Use ::class keyword when possible
1 parent 7efb538 commit 082fd04

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
@@ -332,7 +332,7 @@ private function displayDeprecations($groups, $configuration)
332332
private static function getPhpUnitErrorHandler()
333333
{
334334
if (!isset(self::$isAtLeastPhpUnit83)) {
335-
self::$isAtLeastPhpUnit83 = class_exists('PHPUnit\Util\ErrorHandler') && method_exists('PHPUnit\Util\ErrorHandler', '__invoke');
335+
self::$isAtLeastPhpUnit83 = class_exists(ErrorHandler::class) && method_exists(ErrorHandler::class, '__invoke');
336336
}
337337
if (!self::$isAtLeastPhpUnit83) {
338338
return 'PHPUnit\Util\ErrorHandler::handleError';

Legacy/SymfonyTestsListenerTrait.php

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

136-
if (!class_exists('Doctrine\Common\Annotations\AnnotationRegistry', false) && class_exists('Doctrine\Common\Annotations\AnnotationRegistry')) {
137-
if (method_exists('Doctrine\Common\Annotations\AnnotationRegistry', 'registerUniqueLoader')) {
136+
if (!class_exists(AnnotationRegistry::class, false) && class_exists(AnnotationRegistry::class)) {
137+
if (method_exists(AnnotationRegistry::class, 'registerUniqueLoader')) {
138138
AnnotationRegistry::registerUniqueLoader('class_exists');
139139
} else {
140140
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
@@ -262,17 +262,17 @@
262262
define('PHPUNIT_COMPOSER_INSTALL', __DIR__.'/vendor/autoload.php');
263263
require PHPUNIT_COMPOSER_INSTALL;
264264
265-
if (!class_exists('SymfonyExcludeListPhpunit', false)) {
265+
if (!class_exists(\SymfonyExcludeListPhpunit::class, false)) {
266266
class SymfonyExcludeListPhpunit {}
267267
}
268-
if (method_exists('PHPUnit\Util\ExcludeList', 'addDirectory')) {
268+
if (method_exists(\PHPUnit\Util\ExcludeList::class, 'addDirectory')) {
269269
(new PHPUnit\Util\Excludelist())->getExcludedDirectories();
270-
PHPUnit\Util\ExcludeList::addDirectory(\dirname((new \ReflectionClass('SymfonyExcludeListPhpunit'))->getFileName()));
271-
class_exists('SymfonyExcludeListSimplePhpunit', false) && PHPUnit\Util\ExcludeList::addDirectory(\dirname((new \ReflectionClass('SymfonyExcludeListSimplePhpunit'))->getFileName()));
272-
} elseif (method_exists('PHPUnit\Util\Blacklist', 'addDirectory')) {
270+
PHPUnit\Util\ExcludeList::addDirectory(\dirname((new \ReflectionClass(\SymfonyExcludeListPhpunit::class))->getFileName()));
271+
class_exists(\SymfonyExcludeListSimplePhpunit::class, false) && PHPUnit\Util\ExcludeList::addDirectory(\dirname((new \ReflectionClass(\SymfonyExcludeListSimplePhpunit::class))->getFileName()));
272+
} elseif (method_exists(\PHPUnit\Util\Blacklist::class, 'addDirectory')) {
273273
(new PHPUnit\Util\BlackList())->getBlacklistedDirectories();
274-
PHPUnit\Util\Blacklist::addDirectory(\dirname((new \ReflectionClass('SymfonyExcludeListPhpunit'))->getFileName()));
275-
class_exists('SymfonyExcludeListSimplePhpunit', false) && PHPUnit\Util\Blacklist::addDirectory(\dirname((new \ReflectionClass('SymfonyExcludeListSimplePhpunit'))->getFileName()));
274+
PHPUnit\Util\Blacklist::addDirectory(\dirname((new \ReflectionClass(\SymfonyExcludeListPhpunit::class))->getFileName()));
275+
class_exists(\SymfonyExcludeListSimplePhpunit::class, false) && PHPUnit\Util\Blacklist::addDirectory(\dirname((new \ReflectionClass(\SymfonyExcludeListSimplePhpunit::class))->getFileName()));
276276
} else {
277277
PHPUnit\Util\Blacklist::$blacklistedClassNames['SymfonyExcludeListPhpunit'] = 1;
278278
PHPUnit\Util\Blacklist::$blacklistedClassNames['SymfonyExcludeListSimplePhpunit'] = 1;
@@ -397,7 +397,7 @@ class_exists('SymfonyExcludeListSimplePhpunit', false) && PHPUnit\Util\Blacklist
397397
}
398398
}
399399
} elseif (!isset($argv[1]) || 'install' !== $argv[1] || file_exists('install')) {
400-
if (!class_exists('SymfonyExcludeListSimplePhpunit', false)) {
400+
if (!class_exists(\SymfonyExcludeListSimplePhpunit::class, false)) {
401401
class SymfonyExcludeListSimplePhpunit
402402
{
403403
}

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)