Skip to content

Commit 75935aa

Browse files
committed
Merge branch '4.4' into 5.1
* 4.4: Use ::class keyword when possible
2 parents 1ef2845 + 81b62bd commit 75935aa

Some content is hidden

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

44 files changed

+163
-163
lines changed

ContainerBuilder.php

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

148-
$this->trackResources = interface_exists('Symfony\Component\Config\Resource\ResourceInterface');
148+
$this->trackResources = interface_exists(ResourceInterface::class);
149149
$this->setDefinition('service_container', (new Definition(ContainerInterface::class))->setSynthetic(true)->setPublic(true));
150150
$this->setAlias(PsrContainerInterface::class, new Alias('service_container', false))->setDeprecated('symfony/dependency-injection', '5.1', $deprecationMessage = 'The "%alias_id%" autowiring alias is deprecated. Define it explicitly in your app if you want to keep using it.');
151151
$this->setAlias(ContainerInterface::class, new Alias('service_container', false))->setDeprecated('symfony/dependency-injection', '5.1', $deprecationMessage);
@@ -1587,7 +1587,7 @@ private function shareService(Definition $definition, $service, ?string $id, arr
15871587
private function getExpressionLanguage(): ExpressionLanguage
15881588
{
15891589
if (null === $this->expressionLanguage) {
1590-
if (!class_exists('Symfony\Component\ExpressionLanguage\ExpressionLanguage')) {
1590+
if (!class_exists(\Symfony\Component\ExpressionLanguage\ExpressionLanguage::class)) {
15911591
throw new LogicException('Unable to use expressions as the Symfony ExpressionLanguage component is not installed.');
15921592
}
15931593
$this->expressionLanguage = new ExpressionLanguage(null, $this->expressionLanguageProviders);

Dumper/PhpDumper.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -553,7 +553,7 @@ private function generateProxyClasses(): array
553553
$proxyClasses = [];
554554
$alreadyGenerated = [];
555555
$definitions = $this->container->getDefinitions();
556-
$strip = '' === $this->docStar && method_exists('Symfony\Component\HttpKernel\Kernel', 'stripComments');
556+
$strip = '' === $this->docStar && method_exists(Kernel::class, 'stripComments');
557557
$proxyDumper = $this->getProxyDumper();
558558
ksort($definitions);
559559
foreach ($definitions as $definition) {
@@ -2051,7 +2051,7 @@ private function getNextVariableName(): string
20512051
private function getExpressionLanguage(): ExpressionLanguage
20522052
{
20532053
if (null === $this->expressionLanguage) {
2054-
if (!class_exists('Symfony\Component\ExpressionLanguage\ExpressionLanguage')) {
2054+
if (!class_exists(\Symfony\Component\ExpressionLanguage\ExpressionLanguage::class)) {
20552055
throw new LogicException('Unable to use expressions as the Symfony ExpressionLanguage component is not installed.');
20562056
}
20572057
$providers = $this->container->getExpressionLanguageProviders();

Dumper/YamlDumper.php

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

Loader/YamlFileLoader.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -723,7 +723,7 @@ private function parseCallable($callable, string $parameter, string $id, string
723723
*/
724724
protected function loadFile($file)
725725
{
726-
if (!class_exists('Symfony\Component\Yaml\Parser')) {
726+
if (!class_exists(\Symfony\Component\Yaml\Parser::class)) {
727727
throw new RuntimeException('Unable to load YAML config files as the Symfony Yaml Component is not installed.');
728728
}
729729

Tests/AliasTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ public function testCanOverrideDeprecation()
122122
*/
123123
public function testCannotDeprecateWithAnInvalidTemplate($message)
124124
{
125-
$this->expectException('Symfony\Component\DependencyInjection\Exception\InvalidArgumentException');
125+
$this->expectException(\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException::class);
126126
$def = new Alias('foo');
127127
$def->setDeprecated('package', '1.1', $message);
128128
}

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'));

Tests/Compiler/CheckDefinitionValidityPassTest.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class CheckDefinitionValidityPassTest extends TestCase
2020
{
2121
public function testProcessDetectsSyntheticNonPublicDefinitions()
2222
{
23-
$this->expectException('Symfony\Component\DependencyInjection\Exception\RuntimeException');
23+
$this->expectException(RuntimeException::class);
2424
$container = new ContainerBuilder();
2525
$container->register('a')->setSynthetic(true)->setPublic(false);
2626

@@ -29,7 +29,7 @@ public function testProcessDetectsSyntheticNonPublicDefinitions()
2929

3030
public function testProcessDetectsNonSyntheticNonAbstractDefinitionWithoutClass()
3131
{
32-
$this->expectException('Symfony\Component\DependencyInjection\Exception\RuntimeException');
32+
$this->expectException(RuntimeException::class);
3333
$container = new ContainerBuilder();
3434
$container->register('a')->setSynthetic(false)->setAbstract(false);
3535

@@ -77,7 +77,7 @@ public function testValidTags()
7777

7878
public function testInvalidTags()
7979
{
80-
$this->expectException('Symfony\Component\DependencyInjection\Exception\RuntimeException');
80+
$this->expectException(RuntimeException::class);
8181
$container = new ContainerBuilder();
8282
$container->register('a', 'class')->addTag('foo', ['bar' => ['baz' => 'baz']]);
8383

@@ -86,7 +86,7 @@ public function testInvalidTags()
8686

8787
public function testDynamicPublicServiceName()
8888
{
89-
$this->expectException('Symfony\Component\DependencyInjection\Exception\EnvParameterException');
89+
$this->expectException(\Symfony\Component\DependencyInjection\Exception\EnvParameterException::class);
9090
$container = new ContainerBuilder();
9191
$env = $container->getParameterBag()->get('env(BAR)');
9292
$container->register("foo.$env", 'class')->setPublic(true);
@@ -96,7 +96,7 @@ public function testDynamicPublicServiceName()
9696

9797
public function testDynamicPublicAliasName()
9898
{
99-
$this->expectException('Symfony\Component\DependencyInjection\Exception\EnvParameterException');
99+
$this->expectException(\Symfony\Component\DependencyInjection\Exception\EnvParameterException::class);
100100
$container = new ContainerBuilder();
101101
$env = $container->getParameterBag()->get('env(BAR)');
102102
$container->setAlias("foo.$env", 'class')->setPublic(true);

0 commit comments

Comments
 (0)