Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit d4b812c

Browse filesBrowse files
longwavenicolas-grekas
authored andcommitted
Allow service locators to be ordered by priority.
1 parent b6ec960 commit d4b812c
Copy full SHA for d4b812c

File tree

Expand file treeCollapse file tree

5 files changed

+9
-10
lines changed
Filter options
Expand file treeCollapse file tree

5 files changed

+9
-10
lines changed

‎src/Symfony/Component/DependencyInjection/Compiler/ServiceLocatorTagPass.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/DependencyInjection/Compiler/ServiceLocatorTagPass.php
-1Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,6 @@ public static function map(array $services): array
131131

132132
$services[$k] = new ServiceClosureArgument($v);
133133
}
134-
ksort($services);
135134

136135
return $services;
137136
}

‎src/Symfony/Component/DependencyInjection/Tests/Compiler/IntegrationTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/DependencyInjection/Tests/Compiler/IntegrationTest.php
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -623,7 +623,7 @@ public function testTaggedLocatorWithDefaultPriorityMethodConfiguredViaAttribute
623623
// We need to check priority of instances in the factories
624624
$factories = (new \ReflectionClass($locator))->getProperty('factories');
625625

626-
self::assertSame([BarTagClass::class, FooTagClass::class], array_keys($factories->getValue($locator)));
626+
self::assertSame([FooTagClass::class, BarTagClass::class], array_keys($factories->getValue($locator)));
627627
}
628628

629629
public function testTaggedLocatorWithDefaultIndexMethodAndWithDefaultPriorityMethodConfiguredViaAttribute()
@@ -652,7 +652,7 @@ public function testTaggedLocatorWithDefaultIndexMethodAndWithDefaultPriorityMet
652652
// We need to check priority of instances in the factories
653653
$factories = (new \ReflectionClass($locator))->getProperty('factories');
654654

655-
self::assertSame(['bar_tag_class', 'foo_tag_class'], array_keys($factories->getValue($locator)));
655+
self::assertSame(['foo_tag_class', 'bar_tag_class'], array_keys($factories->getValue($locator)));
656656
self::assertSame($container->get(BarTagClass::class), $locator->get('bar_tag_class'));
657657
self::assertSame($container->get(FooTagClass::class), $locator->get('foo_tag_class'));
658658
}

‎src/Symfony/Component/DependencyInjection/Tests/Compiler/RegisterServiceSubscribersPassTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/DependencyInjection/Tests/Compiler/RegisterServiceSubscribersPassTest.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -462,7 +462,7 @@ public static function getSubscribedServices(): array
462462
'autowired' => new ServiceClosureArgument(new TypedReference('service.id', 'stdClass', ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE, 'autowired', [new Autowire(service: 'service.id')])),
463463
'autowired.nullable' => new ServiceClosureArgument(new TypedReference('service.id', 'stdClass', ContainerInterface::IGNORE_ON_INVALID_REFERENCE, 'autowired.nullable', [new Autowire(service: 'service.id')])),
464464
'autowired.parameter' => new ServiceClosureArgument('foobar'),
465-
'autowire.decorated' => new ServiceClosureArgument(new Reference('.service_locator.oO4rxCy.inner', ContainerInterface::NULL_ON_INVALID_REFERENCE)),
465+
'autowire.decorated' => new ServiceClosureArgument(new Reference('.service_locator.0tSxobl.inner', ContainerInterface::NULL_ON_INVALID_REFERENCE)),
466466
'target' => new ServiceClosureArgument(new TypedReference('stdClass', 'stdClass', ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE, 'target', [new Target('someTarget')])),
467467
];
468468
$this->assertEquals($expected, $container->getDefinition((string) $locator->getFactory()[0])->getArgument(0));

‎src/Symfony/Component/DependencyInjection/Tests/Compiler/ServiceLocatorTagPassTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/DependencyInjection/Tests/Compiler/ServiceLocatorTagPassTest.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ public function testDefinitionOrderIsTheSame()
214214
$locator = $container->getDefinition($locator);
215215
$factories = $locator->getArguments()[0];
216216

217-
static::assertSame(['service-1', 'service-2'], array_keys($factories));
217+
static::assertSame(['service-2', 'service-1'], array_keys($factories));
218218
}
219219

220220
public function testBindingsAreProcessed()

‎src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_subscriber.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_subscriber.php
+5-5Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,9 @@ public function isCompiled(): bool
4343
public function getRemovedIds(): array
4444
{
4545
return [
46-
'.service_locator.2hyyc9y' => true,
47-
'.service_locator.KGUGnmw' => true,
48-
'.service_locator.KGUGnmw.foo_service' => true,
46+
'.service_locator.0H1ht0q' => true,
47+
'.service_locator.0H1ht0q.foo_service' => true,
48+
'.service_locator.tfSHZa1' => true,
4949
'Symfony\\Component\\DependencyInjection\\Tests\\Fixtures\\CustomDefinition' => true,
5050
];
5151
}
@@ -68,14 +68,14 @@ protected static function getTestServiceSubscriberService($container)
6868
protected static function getFooServiceService($container)
6969
{
7070
return $container->services['foo_service'] = new \Symfony\Component\DependencyInjection\Tests\Fixtures\TestServiceSubscriber((new \Symfony\Component\DependencyInjection\Argument\ServiceLocator($container->getService ??= $container->getService(...), [
71-
'Symfony\\Component\\DependencyInjection\\Tests\\Fixtures\\CustomDefinition' => ['privates', 'Symfony\\Component\\DependencyInjection\\Tests\\Fixtures\\CustomDefinition', 'getCustomDefinitionService', false],
7271
'Symfony\\Component\\DependencyInjection\\Tests\\Fixtures\\TestServiceSubscriber' => ['services', 'Symfony\\Component\\DependencyInjection\\Tests\\Fixtures\\TestServiceSubscriber', 'getTestServiceSubscriberService', false],
72+
'Symfony\\Component\\DependencyInjection\\Tests\\Fixtures\\CustomDefinition' => ['privates', 'Symfony\\Component\\DependencyInjection\\Tests\\Fixtures\\CustomDefinition', 'getCustomDefinitionService', false],
7373
'bar' => ['services', 'Symfony\\Component\\DependencyInjection\\Tests\\Fixtures\\TestServiceSubscriber', 'getTestServiceSubscriberService', false],
7474
'baz' => ['privates', 'Symfony\\Component\\DependencyInjection\\Tests\\Fixtures\\CustomDefinition', 'getCustomDefinitionService', false],
7575
'late_alias' => ['services', 'late_alias', 'getLateAliasService', false],
7676
], [
77-
'Symfony\\Component\\DependencyInjection\\Tests\\Fixtures\\CustomDefinition' => 'Symfony\\Component\\DependencyInjection\\Tests\\Fixtures\\CustomDefinition',
7877
'Symfony\\Component\\DependencyInjection\\Tests\\Fixtures\\TestServiceSubscriber' => 'Symfony\\Component\\DependencyInjection\\Tests\\Fixtures\\TestServiceSubscriber',
78+
'Symfony\\Component\\DependencyInjection\\Tests\\Fixtures\\CustomDefinition' => 'Symfony\\Component\\DependencyInjection\\Tests\\Fixtures\\CustomDefinition',
7979
'bar' => 'Symfony\\Component\\DependencyInjection\\Tests\\Fixtures\\CustomDefinition',
8080
'baz' => 'Symfony\\Component\\DependencyInjection\\Tests\\Fixtures\\CustomDefinition',
8181
'late_alias' => 'Symfony\\Component\\DependencyInjection\\Tests\\Fixtures\\TestDefinition1',

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.