Skip to content

Commit 81b62bd

Browse files
committed
Use ::class keyword when possible
1 parent 361f15a commit 81b62bd

File tree

49 files changed

+230
-230
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+230
-230
lines changed

ContainerBuilder.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ public function __construct(ParameterBagInterface $parameterBag = null)
144144
{
145145
parent::__construct($parameterBag);
146146

147-
$this->trackResources = interface_exists('Symfony\Component\Config\Resource\ResourceInterface');
147+
$this->trackResources = interface_exists(ResourceInterface::class);
148148
$this->setDefinition('service_container', (new Definition(ContainerInterface::class))->setSynthetic(true)->setPublic(true));
149149
$this->setAlias(PsrContainerInterface::class, new Alias('service_container', false));
150150
$this->setAlias(ContainerInterface::class, new Alias('service_container', false));
@@ -1643,7 +1643,7 @@ private function shareService(Definition $definition, $service, ?string $id, arr
16431643
private function getExpressionLanguage(): ExpressionLanguage
16441644
{
16451645
if (null === $this->expressionLanguage) {
1646-
if (!class_exists('Symfony\Component\ExpressionLanguage\ExpressionLanguage')) {
1646+
if (!class_exists(\Symfony\Component\ExpressionLanguage\ExpressionLanguage::class)) {
16471647
throw new LogicException('Unable to use expressions as the Symfony ExpressionLanguage component is not installed.');
16481648
}
16491649
$this->expressionLanguage = new ExpressionLanguage(null, $this->expressionLanguageProviders);

Dumper/PhpDumper.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -534,7 +534,7 @@ private function generateProxyClasses(): array
534534
$proxyClasses = [];
535535
$alreadyGenerated = [];
536536
$definitions = $this->container->getDefinitions();
537-
$strip = '' === $this->docStar && method_exists('Symfony\Component\HttpKernel\Kernel', 'stripComments');
537+
$strip = '' === $this->docStar && method_exists(Kernel::class, 'stripComments');
538538
$proxyDumper = $this->getProxyDumper();
539539
ksort($definitions);
540540
foreach ($definitions as $definition) {
@@ -1989,7 +1989,7 @@ private function getNextVariableName(): string
19891989
private function getExpressionLanguage(): ExpressionLanguage
19901990
{
19911991
if (null === $this->expressionLanguage) {
1992-
if (!class_exists('Symfony\Component\ExpressionLanguage\ExpressionLanguage')) {
1992+
if (!class_exists(\Symfony\Component\ExpressionLanguage\ExpressionLanguage::class)) {
19931993
throw new LogicException('Unable to use expressions as the Symfony ExpressionLanguage component is not installed.');
19941994
}
19951995
$providers = $this->container->getExpressionLanguageProviders();

Dumper/YamlDumper.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ class YamlDumper extends Dumper
4545
*/
4646
public function dump(array $options = [])
4747
{
48-
if (!class_exists('Symfony\Component\Yaml\Dumper')) {
48+
if (!class_exists(\Symfony\Component\Yaml\Dumper::class)) {
4949
throw new LogicException('Unable to dump the container as the Symfony Yaml Component is not installed.');
5050
}
5151

Loader/YamlFileLoader.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -671,7 +671,7 @@ private function parseCallable($callable, string $parameter, string $id, string
671671
*/
672672
protected function loadFile($file)
673673
{
674-
if (!class_exists('Symfony\Component\Yaml\Parser')) {
674+
if (!class_exists(\Symfony\Component\Yaml\Parser::class)) {
675675
throw new RuntimeException('Unable to load YAML config files as the Symfony Yaml Component is not installed.');
676676
}
677677

Tests/AliasTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ public function testCanOverrideDeprecation()
9090
*/
9191
public function testCannotDeprecateWithAnInvalidTemplate($message)
9292
{
93-
$this->expectException('Symfony\Component\DependencyInjection\Exception\InvalidArgumentException');
93+
$this->expectException(\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException::class);
9494
$def = new Alias('foo');
9595
$def->setDeprecated(true, $message);
9696
}

Tests/ChildDefinitionTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ public function testSetArgument()
9191

9292
public function testReplaceArgumentShouldRequireIntegerIndex()
9393
{
94-
$this->expectException('InvalidArgumentException');
94+
$this->expectException(\InvalidArgumentException::class);
9595
$def = new ChildDefinition('foo');
9696

9797
$def->replaceArgument('0', 'foo');
@@ -118,7 +118,7 @@ public function testReplaceArgument()
118118

119119
public function testGetArgumentShouldCheckBounds()
120120
{
121-
$this->expectException('OutOfBoundsException');
121+
$this->expectException(\OutOfBoundsException::class);
122122
$def = new ChildDefinition('foo');
123123

124124
$def->setArguments([0 => 'foo']);
@@ -129,14 +129,14 @@ public function testGetArgumentShouldCheckBounds()
129129

130130
public function testCannotCallSetAutoconfigured()
131131
{
132-
$this->expectException('Symfony\Component\DependencyInjection\Exception\BadMethodCallException');
132+
$this->expectException(\Symfony\Component\DependencyInjection\Exception\BadMethodCallException::class);
133133
$def = new ChildDefinition('foo');
134134
$def->setAutoconfigured(true);
135135
}
136136

137137
public function testCannotCallSetInstanceofConditionals()
138138
{
139-
$this->expectException('Symfony\Component\DependencyInjection\Exception\BadMethodCallException');
139+
$this->expectException(\Symfony\Component\DependencyInjection\Exception\BadMethodCallException::class);
140140
$def = new ChildDefinition('foo');
141141
$def->setInstanceofConditionals(['Foo' => new ChildDefinition('')]);
142142
}

Tests/Compiler/AutoAliasServicePassTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class AutoAliasServicePassTest extends TestCase
1919
{
2020
public function testProcessWithMissingParameter()
2121
{
22-
$this->expectException('Symfony\Component\DependencyInjection\Exception\ParameterNotFoundException');
22+
$this->expectException(\Symfony\Component\DependencyInjection\Exception\ParameterNotFoundException::class);
2323
$container = new ContainerBuilder();
2424

2525
$container->register('example')
@@ -31,7 +31,7 @@ public function testProcessWithMissingParameter()
3131

3232
public function testProcessWithMissingFormat()
3333
{
34-
$this->expectException('Symfony\Component\DependencyInjection\Exception\InvalidArgumentException');
34+
$this->expectException(\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException::class);
3535
$container = new ContainerBuilder();
3636

3737
$container->register('example')

Tests/Compiler/AutowirePassTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ public function testTypeNotGuessableNoServicesFound()
241241
*/
242242
public function testTypeNotGuessableUnionType()
243243
{
244-
$this->expectException('Symfony\Component\DependencyInjection\Exception\AutowiringFailedException');
244+
$this->expectException(AutowiringFailedException::class);
245245
$this->expectExceptionMessage('Cannot autowire service "a": argument "$collision" of method "Symfony\Component\DependencyInjection\Tests\Compiler\UnionClasses::__construct()" has type "Symfony\Component\DependencyInjection\Tests\Compiler\CollisionA|Symfony\Component\DependencyInjection\Tests\Compiler\CollisionB" but this class was not found.');
246246
$container = new ContainerBuilder();
247247

@@ -493,7 +493,7 @@ public function testScalarArgsCannotBeAutowired()
493493
*/
494494
public function testUnionScalarArgsCannotBeAutowired()
495495
{
496-
$this->expectException('Symfony\Component\DependencyInjection\Exception\AutowiringFailedException');
496+
$this->expectException(AutowiringFailedException::class);
497497
$this->expectExceptionMessage('Cannot autowire service "union_scalars": argument "$timeout" of method "Symfony\Component\DependencyInjection\Tests\Compiler\UnionScalars::__construct()" is type-hinted "int|float", you should configure its value explicitly.');
498498
$container = new ContainerBuilder();
499499

Tests/Compiler/CheckArgumentsValidityPassTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public function testProcess()
4545
*/
4646
public function testException(array $arguments, array $methodCalls)
4747
{
48-
$this->expectException('Symfony\Component\DependencyInjection\Exception\RuntimeException');
48+
$this->expectException(\Symfony\Component\DependencyInjection\Exception\RuntimeException::class);
4949
$container = new ContainerBuilder();
5050
$definition = $container->register('foo');
5151
$definition->setArguments($arguments);

Tests/Compiler/CheckCircularReferencesPassTest.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ class CheckCircularReferencesPassTest extends TestCase
2323
{
2424
public function testProcess()
2525
{
26-
$this->expectException('Symfony\Component\DependencyInjection\Exception\ServiceCircularReferenceException');
26+
$this->expectException(\Symfony\Component\DependencyInjection\Exception\ServiceCircularReferenceException::class);
2727
$container = new ContainerBuilder();
2828
$container->register('a')->addArgument(new Reference('b'));
2929
$container->register('b')->addArgument(new Reference('a'));
@@ -33,7 +33,7 @@ public function testProcess()
3333

3434
public function testProcessWithAliases()
3535
{
36-
$this->expectException('Symfony\Component\DependencyInjection\Exception\ServiceCircularReferenceException');
36+
$this->expectException(\Symfony\Component\DependencyInjection\Exception\ServiceCircularReferenceException::class);
3737
$container = new ContainerBuilder();
3838
$container->register('a')->addArgument(new Reference('b'));
3939
$container->setAlias('b', 'c');
@@ -44,7 +44,7 @@ public function testProcessWithAliases()
4444

4545
public function testProcessWithFactory()
4646
{
47-
$this->expectException('Symfony\Component\DependencyInjection\Exception\ServiceCircularReferenceException');
47+
$this->expectException(\Symfony\Component\DependencyInjection\Exception\ServiceCircularReferenceException::class);
4848
$container = new ContainerBuilder();
4949

5050
$container
@@ -60,7 +60,7 @@ public function testProcessWithFactory()
6060

6161
public function testProcessDetectsIndirectCircularReference()
6262
{
63-
$this->expectException('Symfony\Component\DependencyInjection\Exception\ServiceCircularReferenceException');
63+
$this->expectException(\Symfony\Component\DependencyInjection\Exception\ServiceCircularReferenceException::class);
6464
$container = new ContainerBuilder();
6565
$container->register('a')->addArgument(new Reference('b'));
6666
$container->register('b')->addArgument(new Reference('c'));
@@ -71,7 +71,7 @@ public function testProcessDetectsIndirectCircularReference()
7171

7272
public function testProcessDetectsIndirectCircularReferenceWithFactory()
7373
{
74-
$this->expectException('Symfony\Component\DependencyInjection\Exception\ServiceCircularReferenceException');
74+
$this->expectException(\Symfony\Component\DependencyInjection\Exception\ServiceCircularReferenceException::class);
7575
$container = new ContainerBuilder();
7676

7777
$container->register('a')->addArgument(new Reference('b'));
@@ -87,7 +87,7 @@ public function testProcessDetectsIndirectCircularReferenceWithFactory()
8787

8888
public function testDeepCircularReference()
8989
{
90-
$this->expectException('Symfony\Component\DependencyInjection\Exception\ServiceCircularReferenceException');
90+
$this->expectException(\Symfony\Component\DependencyInjection\Exception\ServiceCircularReferenceException::class);
9191
$container = new ContainerBuilder();
9292
$container->register('a')->addArgument(new Reference('b'));
9393
$container->register('b')->addArgument(new Reference('c'));

0 commit comments

Comments
 (0)