Skip to content

Commit 02f05bf

Browse files
BASAKSemihnicolas-grekas
authored andcommitted
Use ::class for Full Qualified Class Names
1 parent d8d93c6 commit 02f05bf

27 files changed

+108
-62
lines changed

src/Symfony/Bundle/DebugBundle/Tests/DependencyInjection/Compiler/DumpDataCollectorPassTest.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
use Symfony\Component\DependencyInjection\ContainerBuilder;
1818
use Symfony\Component\DependencyInjection\Definition;
1919
use Symfony\Component\HttpFoundation\RequestStack;
20+
use Symfony\Component\HttpKernel\DataCollector\DumpDataCollector;
2021

2122
class DumpDataCollectorPassTest extends TestCase
2223
{
@@ -25,7 +26,7 @@ public function testProcessWithoutFileLinkFormatParameter()
2526
$container = new ContainerBuilder();
2627
$container->addCompilerPass(new DumpDataCollectorPass());
2728

28-
$definition = new Definition('Symfony\Component\HttpKernel\DataCollector\DumpDataCollector', [null, null, null, null]);
29+
$definition = new Definition(DumpDataCollector::class, [null, null, null, null]);
2930
$container->setDefinition('data_collector.dump', $definition);
3031

3132
$container->compile();
@@ -39,7 +40,7 @@ public function testProcessWithToolbarEnabled()
3940
$container->addCompilerPass(new DumpDataCollectorPass());
4041
$requestStack = new RequestStack();
4142

42-
$definition = new Definition('Symfony\Component\HttpKernel\DataCollector\DumpDataCollector', [null, null, null, $requestStack]);
43+
$definition = new Definition(DumpDataCollector::class, [null, null, null, $requestStack]);
4344
$container->setDefinition('data_collector.dump', $definition);
4445
$container->setParameter('web_profiler.debug_toolbar.mode', WebDebugToolbarListener::ENABLED);
4546

@@ -53,7 +54,7 @@ public function testProcessWithToolbarDisabled()
5354
$container = new ContainerBuilder();
5455
$container->addCompilerPass(new DumpDataCollectorPass());
5556

56-
$definition = new Definition('Symfony\Component\HttpKernel\DataCollector\DumpDataCollector', [null, null, null, new RequestStack()]);
57+
$definition = new Definition(DumpDataCollector::class, [null, null, null, new RequestStack()]);
5758
$container->setDefinition('data_collector.dump', $definition);
5859
$container->setParameter('web_profiler.debug_toolbar.mode', WebDebugToolbarListener::DISABLED);
5960

@@ -67,7 +68,7 @@ public function testProcessWithoutToolbar()
6768
$container = new ContainerBuilder();
6869
$container->addCompilerPass(new DumpDataCollectorPass());
6970

70-
$definition = new Definition('Symfony\Component\HttpKernel\DataCollector\DumpDataCollector', [null, null, null, new RequestStack()]);
71+
$definition = new Definition(DumpDataCollector::class, [null, null, null, new RequestStack()]);
7172
$container->setDefinition('data_collector.dump', $definition);
7273

7374
$container->compile();

src/Symfony/Bundle/DebugBundle/Tests/DependencyInjection/DebugExtensionTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
namespace Symfony\Bundle\DebugBundle\Tests\DependencyInjection;
1313

1414
use PHPUnit\Framework\TestCase;
15+
use Symfony\Bundle\DebugBundle\DebugBundle;
1516
use Symfony\Bundle\DebugBundle\DependencyInjection\DebugExtension;
1617
use Symfony\Component\DependencyInjection\ContainerBuilder;
1718
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBag;
@@ -114,7 +115,7 @@ private function createContainer()
114115
'kernel.charset' => 'UTF-8',
115116
'kernel.debug' => true,
116117
'kernel.project_dir' => __DIR__,
117-
'kernel.bundles' => ['DebugBundle' => 'Symfony\\Bundle\\DebugBundle\\DebugBundle'],
118+
'kernel.bundles' => ['DebugBundle' => DebugBundle::class],
118119
]));
119120

120121
return $container;

src/Symfony/Bundle/FrameworkBundle/Tests/Command/EventDispatcherDebugCommandTest.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
use Symfony\Component\Console\Tester\CommandCompletionTester;
1717
use Symfony\Component\DependencyInjection\ServiceLocator;
1818
use Symfony\Component\EventDispatcher\EventDispatcher;
19+
use Symfony\Component\Mailer\Event\MessageEvent;
1920

2021
class EventDispatcherDebugCommandTest extends TestCase
2122
{
@@ -33,7 +34,7 @@ public function testComplete(array $input, array $expectedSuggestions)
3334

3435
public function provideCompletionSuggestions()
3536
{
36-
yield 'event' => [[''], ['Symfony\Component\Mailer\Event\MessageEvent', 'console.command']];
37+
yield 'event' => [[''], [MessageEvent::class, 'console.command']];
3738
yield 'event for other dispatcher' => [['--dispatcher', 'other_event_dispatcher', ''], ['other_event', 'App\OtherEvent']];
3839
yield 'dispatcher' => [['--dispatcher='], ['event_dispatcher', 'other_event_dispatcher']];
3940
yield 'format' => [['--format='], ['txt', 'xml', 'json', 'md']];
@@ -44,7 +45,7 @@ private function createCommandCompletionTester(): CommandCompletionTester
4445
$dispatchers = new ServiceLocator([
4546
'event_dispatcher' => function () {
4647
$dispatcher = new EventDispatcher();
47-
$dispatcher->addListener('Symfony\Component\Mailer\Event\MessageEvent', 'var_dump');
48+
$dispatcher->addListener(MessageEvent::class, 'var_dump');
4849
$dispatcher->addListener('console.command', 'var_dump');
4950

5051
return $dispatcher;

src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/AddExpressionLanguageProvidersPassTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,11 @@ public function testProcessForRouter()
2424
$container = new ContainerBuilder();
2525
$container->addCompilerPass(new AddExpressionLanguageProvidersPass());
2626

27-
$definition = new Definition('\stdClass');
27+
$definition = new Definition(\stdClass::class);
2828
$definition->addTag('routing.expression_language_provider');
2929
$container->setDefinition('some_routing_provider', $definition->setPublic(true));
3030

31-
$container->register('router.default', '\stdClass')->setPublic(true);
31+
$container->register('router.default', \stdClass::class)->setPublic(true);
3232
$container->compile();
3333

3434
$router = $container->getDefinition('router.default');
@@ -43,11 +43,11 @@ public function testProcessForRouterAlias()
4343
$container = new ContainerBuilder();
4444
$container->addCompilerPass(new AddExpressionLanguageProvidersPass());
4545

46-
$definition = new Definition('\stdClass');
46+
$definition = new Definition(\stdClass::class);
4747
$definition->addTag('routing.expression_language_provider');
4848
$container->setDefinition('some_routing_provider', $definition->setPublic(true));
4949

50-
$container->register('my_router', '\stdClass')->setPublic(true);
50+
$container->register('my_router', \stdClass::class)->setPublic(true);
5151
$container->setAlias('router.default', 'my_router');
5252
$container->compile();
5353

src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/DataCollectorTranslatorPassTest.php

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@
1515
use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\DataCollectorTranslatorPass;
1616
use Symfony\Component\DependencyInjection\ContainerBuilder;
1717
use Symfony\Component\DependencyInjection\Reference;
18+
use Symfony\Component\Translation\DataCollector\TranslationDataCollector;
19+
use Symfony\Component\Translation\DataCollectorTranslator;
20+
use Symfony\Component\Translation\Translator;
1821
use Symfony\Contracts\Translation\TranslatorInterface;
1922

2023
class DataCollectorTranslatorPassTest extends TestCase
@@ -27,16 +30,16 @@ protected function setUp(): void
2730
$this->container = new ContainerBuilder();
2831
$this->dataCollectorTranslatorPass = new DataCollectorTranslatorPass();
2932

30-
$this->container->setParameter('translator_implementing_bag', 'Symfony\Component\Translation\Translator');
33+
$this->container->setParameter('translator_implementing_bag', Translator::class);
3134
$this->container->setParameter('translator_not_implementing_bag', 'Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\Compiler\TranslatorWithTranslatorBag');
3235

33-
$this->container->register('translator.data_collector', 'Symfony\Component\Translation\DataCollectorTranslator')
36+
$this->container->register('translator.data_collector', DataCollectorTranslator::class)
3437
->setPublic(false)
3538
->setDecoratedService('translator')
3639
->setArguments([new Reference('translator.data_collector.inner')])
3740
;
3841

39-
$this->container->register('data_collector.translation', 'Symfony\Component\Translation\DataCollector\TranslationDataCollector')
42+
$this->container->register('data_collector.translation', TranslationDataCollector::class)
4043
->setArguments([new Reference('translator.data_collector')])
4144
;
4245
}
@@ -68,7 +71,7 @@ public function testProcessKeepsDataCollectorIfTranslatorImplementsTranslatorBag
6871
public function getImplementingTranslatorBagInterfaceTranslatorClassNames()
6972
{
7073
return [
71-
['Symfony\Component\Translation\Translator'],
74+
[Translator::class],
7275
['%translator_implementing_bag%'],
7376
];
7477
}

src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/LoggingTranslatorPassTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,15 @@
1515
use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\LoggingTranslatorPass;
1616
use Symfony\Component\DependencyInjection\ContainerBuilder;
1717
use Symfony\Component\DependencyInjection\Reference;
18+
use Symfony\Component\Translation\Translator;
1819

1920
class LoggingTranslatorPassTest extends TestCase
2021
{
2122
public function testProcess()
2223
{
2324
$container = new ContainerBuilder();
2425
$container->setParameter('translator.logging', true);
25-
$container->setParameter('translator.class', 'Symfony\Component\Translation\Translator');
26+
$container->setParameter('translator.class', Translator::class);
2627
$container->register('monolog.logger');
2728
$container->setAlias('logger', 'monolog.logger');
2829
$container->register('translator.default', '%translator.class%');

src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/TestServiceContainerRefPassesTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
namespace Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\Compiler;
1313

1414
use PHPUnit\Framework\TestCase;
15+
use Psr\Container\ContainerInterface;
1516
use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\TestServiceContainerRealRefPass;
1617
use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\TestServiceContainerWeakRefPass;
1718
use Symfony\Component\DependencyInjection\Argument\ServiceClosureArgument;
@@ -58,7 +59,7 @@ public function testProcess()
5859
];
5960

6061
$privateServices = $container->getDefinition('test.private_services_locator')->getArgument(0);
61-
unset($privateServices['Symfony\Component\DependencyInjection\ContainerInterface'], $privateServices['Psr\Container\ContainerInterface']);
62+
unset($privateServices[\Symfony\Component\DependencyInjection\ContainerInterface::class], $privateServices[ContainerInterface::class]);
6263

6364
$this->assertEquals($expected, $privateServices);
6465
$this->assertFalse($container->getDefinition('Test\private_used_non_shared_service')->isShared());

src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/messenger_routing.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
<?php
22

3+
use Symfony\Bundle\FrameworkBundle\Tests\Fixtures\Messenger\DummyMessage;
4+
use Symfony\Bundle\FrameworkBundle\Tests\Fixtures\Messenger\SecondMessage;
5+
36
$container->loadFromExtension('framework', [
47
'http_method_override' => false,
58
'serializer' => true,
@@ -8,8 +11,8 @@
811
'default_serializer' => 'messenger.transport.symfony_serializer',
912
],
1013
'routing' => [
11-
'Symfony\Bundle\FrameworkBundle\Tests\Fixtures\Messenger\DummyMessage' => ['amqp', 'messenger.transport.audit'],
12-
'Symfony\Bundle\FrameworkBundle\Tests\Fixtures\Messenger\SecondMessage' => [
14+
DummyMessage::class => ['amqp', 'messenger.transport.audit'],
15+
SecondMessage::class => [
1316
'senders' => ['amqp', 'audit'],
1417
],
1518
'*' => 'amqp',

src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/messenger_routing_invalid_transport.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
use Symfony\Bundle\FrameworkBundle\Tests\Fixtures\Messenger\DummyMessage;
4+
35
$container->loadFromExtension('framework', [
46
'http_method_override' => false,
57
'serializer' => true,
@@ -8,7 +10,7 @@
810
'default_serializer' => 'messenger.transport.symfony_serializer',
911
],
1012
'routing' => [
11-
'Symfony\Bundle\FrameworkBundle\Tests\Fixtures\Messenger\DummyMessage' => 'invalid',
13+
DummyMessage::class => 'invalid',
1214
],
1315
'transports' => [
1416
'amqp' => 'amqp://localhost/%2f/messages',

src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/messenger_routing_single.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
<?php
22

3+
use Symfony\Bundle\FrameworkBundle\Tests\Fixtures\Messenger\DummyMessage;
4+
35
$container->loadFromExtension('framework', [
46
'http_method_override' => false,
57
'messenger' => [
68
'routing' => [
7-
'Symfony\Bundle\FrameworkBundle\Tests\Fixtures\Messenger\DummyMessage' => ['amqp'],
9+
DummyMessage::class => ['amqp'],
810
],
911
'transports' => [
1012
'amqp' => 'amqp://localhost/%2f/messages',

0 commit comments

Comments
 (0)