8000 minor #39785 Use ::class keyword when possible (fabpot) · symfony/symfony@ecfa4bd · GitHub
[go: up one dir, main page]

Skip to content

Commit ecfa4bd

Browse files
committed
minor #39785 Use ::class keyword when possible (fabpot)
This PR was merged into the 5.3-dev branch. Discussion ---------- Use ::class keyword when possible | Q | A | ------------- | --- | Branch? | 5.x <!-- see below --> | Bug fix? | no | New feature? | no <!-- please update src/**/CHANGELOG.md files --> | Deprecations? | no <!-- please update UPGRADE-*.md and src/**/CHANGELOG.md files --> | Tickets | n/a <!-- prefix each issue number with "Fix #", no need to create an issue if none exist, explain below instead --> | License | MIT | Doc PR | n/a Commits ------- 6b6f777 Use ::class keyword when possible
2 parents cce5a42 + 6b6f777 commit ecfa4bd

File tree

9 files changed

+18
-18
lines changed

9 files changed

+18
-18
lines changed

src/Symfony/Bridge/PhpUnit/bootstrap.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,15 @@
2020
}
2121

2222
// Detect if we're loaded by an actual run of phpunit
23-
if (!defined('PHPUNIT_COMPOSER_INSTALL') && !class_exists('PHPUnit\TextUI\Command', false)) {
23+
if (!defined('PHPUNIT_COMPOSER_INSTALL') && !class_exists(\PHPUnit\TextUI\Command::class, false)) {
2424
return;
2525
}
2626

2727
// Enforce a consistent locale
2828
setlocale(\LC_ALL, 'C');
2929

30-
if (!class_exists('Doctrine\Common\Annotations\AnnotationRegistry', false) && class_exists('Doctrine\Common\Annotations\AnnotationRegistry')) {
31-
if (method_exists('Doctrine\Common\Annotations\AnnotationRegistry', 'registerUniqueLoader')) {
30+
if (!class_exists(AnnotationRegistry::class, false) && class_exists(AnnotationRegistry::class)) {
31+
if (method_exists(AnnotationRegistry::class, 'registerUniqueLoader')) {
3232
AnnotationRegistry::registerUniqueLoader('class_exists');
3333
} else {
3434
AnnotationRegistry::registerLoader('class_exists');

src/Symfony/Component/Asset/Tests/VersionStrategy/JsonManifestVersionStrategyTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public function testApplyVersionWhenKeyDoesNotExistInManifest(JsonManifestVersio
4747
*/
4848
public function testMissingManifestFileThrowsException(JsonManifestVersionStrategy $strategy)
4949
{
50-
$this->expectException('RuntimeException');
50+
$this->expectException(\RuntimeException::class);
5151
$strategy->getVersion('main.js');
5252
}
5353

@@ -56,7 +56,7 @@ public function testMissingManifestFileThrowsException(JsonManifestVersionStrate
5656
*/
5757
public function testManifestFileWithBadJSONThrowsException(JsonManifestVersionStrategy $strategy)
5858
{
59-
$this->expectException('RuntimeException');
59+
$this->expectException(\RuntimeException::class);
6060
$this->expectExceptionMessage('Error parsing JSON');
6161
$strategy->getVersion('main.js');
6262
}

src/Symfony/Component/Cache/Tests/Adapter/RedisAdapterSentinelTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public static function setUpBeforeClass(): void
3636

3737
public function testInvalidDSNHasBothClusterAndSentinel()
3838
{
39-
57AE $this->expectException('Symfony\Component\Cache\Exception\InvalidArgumentException');
39+
$this->expectException(\Symfony\Component\Cache\Exception\InvalidArgumentException::class);
4040
$this->expectExceptionMessage('Cannot use both "redis_cluster" and "redis_sentinel" at the same time:');
4141
$dsn = 'redis:?host[redis1]&host[redis2]&host[redis3]&redis_cluster=1&redis_sentinel=mymaster';
4242
RedisAdapter::createConnection($dsn);
@@ -46,7 +46,7 @@ public function testExceptionMessageWhenFailingToRetrieveMasterInformation()
4646
{
4747
$hosts = getenv('REDIS_SENTINEL_HOSTS');
4848
$firstHost = explode(' ', $hosts)[0];
49-
$this->expectException('Symfony\Component\Cache\Exception\InvalidArgumentException');
49+
$this->expectException(\Symfony\Component\Cache\Exception\InvalidArgumentException::class);
5050
$this->expectExceptionMessage('Failed to retrieve master information from master name "invalid-masterset-name" and address "'.$firstHost.'".');
5151
AbstractAdapter::createConnection('redis:?host['.str_replace(' ', ']&host[', $hosts B41A ).']', ['redis_sentinel' => 'invalid-masterset-name']);
5252
}

src/Symfony/Component/Console/Tests/Input/ArgvInputTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ public function testInvalidInput($argv, $definition, $expectedExceptionMessage)
234234
*/
235235
public function testInvalidInputNegatable($argv, $definition, $expectedExceptionMessage)
236236
{
237-
$this->expectException('RuntimeException');
237+
$this->expectException(\RuntimeException::class);
238238
$this->expectExceptionMessage($expectedExceptionMessage);
239239

240240
$input = new ArgvInput($argv);

src/Symfony/Component/Console/Tests/Input/InputDefinitionTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ public function testAddDuplicateOption()
244244

245245
public function testAddDuplicateNegatedOption()
246246
{
247-
$this->expectException('LogicException');
247+
$this->expectException(\LogicException::class);
248248
$this->expectExceptionMessage('An option named "no-foo" already exists.');
249249

250250
$definition = new InputDefinition();
@@ -254,7 +254,7 @@ public function testAddDuplicateNegatedOption()
254254

255255
public function testAddDuplicateNegatedReverseOption()
256256
{
257-
$this->expectException('LogicException');
257+
$this->expectException(\LogicException::class);
258258
$this->expectExceptionMessage('An option named "no-foo" already exists.');
259259

260260
$definition = new InputDefinition();

src/Symfony/Component/Console/Tests/Input/InputOptionTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,14 @@ public function testArrayModeWithoutValue()
3333

3434
public function testBooleanWithRequired()
3535
{
36-
$this->expectException('InvalidArgumentException');
36+
$this->expectException(\InvalidArgumentException::class);
3737
$this->expectExceptionMessage('Impossible to have an option mode VALUE_NEGATABLE if the option also accepts a value.');
3838
new InputOption('foo', 'f', InputOption::VALUE_REQUIRED | InputOption::VALUE_NEGATABLE);
3939
}
4040

4141
public function testBooleanWithOptional()
4242
{
43-
$this->expectException('InvalidArgumentException');
43+
$this->expectException(\InvalidArgumentException::class);
4444
$this->expectExceptionMessage('Impossible to have an option mode VALUE_NEGATABLE if the option also accepts a value.');
4545
new InputOption('foo', 'f', InputOption::VALUE_OPTIONAL | InputOption::VALUE_NEGATABLE);
4646
}
@@ -166,7 +166,7 @@ public function testDefaultValueWithValueNoneMode()
166166

167167
public function testDefaultValueWithValueBooleanMode()
168168
{
169-
$this->expectException('LogicException');
169+
$this->expectException(\LogicException::class);
170170
$this->expectExceptionMessage('Cannot set a default value when using InputOption::VALUE_NEGATABLE mode.');
171171
$option = new InputOption('foo', 'f', InputOption::VALUE_NEGATABLE);
172172
$option->setDefault('default');

src/Symfony/Component/Lock/Tests/Store/FlockStoreTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ protected function getStore(): PersistingStoreInterface
3434

3535
public function testConstructWhenRepositoryCannotBeCreated()
3636
{
37-
$this->expectException('Symfony\Component\Lock\Exception\InvalidArgumentException');
37+
$this->expectException(\Symfony\Component\Lock\Exception\InvalidArgumentException::class);
3838
$this->expectExceptionMessage('The FlockStore directory "/a/b/c/d/e" does not exists and cannot be created.');
3939
if (!getenv('USER') || 'root' === getenv('USER')) {
4040
$this->markTestSkipped('This test will fail if run under superuser');
@@ -45,7 +45,7 @@ public function testConstructWhenRepositoryCannotBeCreated()
4545

4646
public function testConstructWhenRepositoryIsNotWriteable()
4747
{
48-
$this->expectException('Symfony\Component\Lock\Exception\InvalidArgumentException');
48+
$this->expectException(\Symfony\Component\Lock\Exception\InvalidArgumentException::class);
4949
$this->expectExceptionMessage('The FlockStore directory "/" is not writable.');
5050
if (!getenv('USER') || 'root' === getenv('USER')) {
5151
$this->markTestSkipped('This test will fail if run under superuser');

src/Symfony/Component/PropertyInfo/Tests/TypeTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,15 +107,15 @@ public function testArrayCollection()
107107

108108
public function testInvalidCollectionArgument()
109109
{
110-
$this->expectException('TypeError');
110+
$this E377 ->expectException(\TypeError::class);
111111
$this->expectExceptionMessage('"Symfony\Component\PropertyInfo\Type::validateCollectionArgument()": Argument #5 ($collectionKeyType) must be of type "Symfony\Component\PropertyInfo\Type[]", "Symfony\Component\PropertyInfo\Type" or "null", "stdClass" given.');
112112

113113
new Type('array', false, null, true, new \stdClass(), [new Type('string')]);
114114
}
115115

116116
public function testInvalidCollectionValueArgument()
117117
{
118-
$this->expectException('TypeError');
118+
$this->expectException(\TypeError::class);
119119
$this->expectExceptionMessage('"Symfony\Component\PropertyInfo\Type::validateCollectionArgument()": Argument #5 ($collectionKeyType) must be of type "Symfony\Component\PropertyInfo\Type[]", "Symfony\Component\PropertyInfo\Type" or "null", array value "array" given.');
120120

121121
new Type('array', false, null, true, [new \stdClass()], [new Type('string')]);

src/Symfony/Component/Security/Core/Tests/Authorization/AccessDecisionManagerTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public function testStrategies($strategy, $voters, $allowIfAllAbstainDecisions,
4343
*/
4444
public function testDeprecatedVoter($strategy)
4545
{
46-
$token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock();
46+
$token = $this->getMockBuilder(\Symfony\Component\Security\Core\Authentication\Token\TokenInterface::class)->getMock();
4747
$manager = new AccessDecisionManager([$this->getVoter(3)], $strategy);
4848

4949
$this->expectDeprecation('Since symfony/security-core 5.3: Returning "3" in "%s::vote()" is deprecated, return one of "Symfony\Component\Security\Core\Authorization\Voter\VoterInterface" constants: "ACCESS_GRANTED", "ACCESS_DENIED" or "ACCESS_ABSTAIN".');

0 commit comments

Comments
 (0)
0