Skip to content

Commit a9e9512

Browse files
committed
Merge branch '5.3' into 5.4
* 5.3: cs fix [Security][Validator] Add missing translations for Indonesian (id) [Notifier] fix typo firebase Add trailing Line return if last line is non empty Report mismatches between trans-unit id and source text via status script Do not add namespace argument to NullAdapter in CachePoolPass [FrameworkBundle] Update cache:clear help Fix ExecutionContextInterface::setParameter phpdoc example Don't pass null to preg_replace() Don't pass null to strpos() Remove preloading of unused class [Messenger] Separate unit tests from integration tests Fix ServiceLocator indexing when service is decorated always close open stopwatch section after handling kernel.request events
2 parents 1200d38 + a665946 commit a9e9512

File tree

2 files changed

+56
-1
lines changed

2 files changed

+56
-1
lines changed

Compiler/PassConfig.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,10 @@ public function __construct()
6262
new AutowireRequiredMethodsPass(),
6363
new AutowireRequiredPropertiesPass(),
6464
new ResolveBindingsPass(),
65-
new DecoratorServicePass(),
6665
new CheckDefinitionValidityPass(),
6766
new AutowirePass(false),
6867
new ServiceLocatorTagPass(),
68+
new DecoratorServicePass(),
6969
new ResolveTaggedIteratorArgumentPass(),
7070
new ResolveServiceSubscribersPass(),
7171
new ResolveReferencesToAliasesPass(),

Tests/Compiler/ServiceLocatorTagPassTest.php

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,11 @@
1313

1414
use PHPUnit\Framework\TestCase;
1515
use Symfony\Component\DependencyInjection\Argument\BoundArgument;
16+
use Symfony\Component\DependencyInjection\Argument\ServiceLocatorArgument;
17+
use Symfony\Component\DependencyInjection\Argument\TaggedIteratorArgument;
1618
use Symfony\Component\DependencyInjection\Compiler\ServiceLocatorTagPass;
1719
use Symfony\Component\DependencyInjection\ContainerBuilder;
20+
use Symfony\Component\DependencyInjection\Definition;
1821
use Symfony\Component\DependencyInjection\Exception\InvalidArgumentException;
1922
use Symfony\Component\DependencyInjection\Reference;
2023
use Symfony\Component\DependencyInjection\ServiceLocator;
@@ -143,4 +146,56 @@ public function testBindingsAreCopied()
143146
$this->assertSame(['foo'], array_keys($locator->getBindings()));
144147
$this->assertInstanceOf(BoundArgument::class, $locator->getBindings()['foo']);
145148
}
149+
150+
public function testIndexedByServiceIdWithDecoration()
151+
{
152+
$container = new ContainerBuilder();
153+
154+
$locator = new Definition(Locator::class);
155+
$locator->setPublic(true);
156+
$locator->addArgument(new ServiceLocatorArgument(new TaggedIteratorArgument('test_tag', null, null, true)));
157+
158+
$container->setDefinition(Locator::class, $locator);
159+
160+
$service = new Definition(Service::class);
161+
$service->setPublic(true);
162+
$service->addTag('test_tag');
163+
164+
$container->setDefinition(Service::class, $service);
165+
166+
$decorated = new Definition(Decorated::class);
167+
$decorated->setPublic(true);
168+
$decorated->setDecoratedService(Service::class);
169+
170+
$container->setDefinition(Decorated::class, $decorated);
171+
172+
$container->compile();
173+
174+
/** @var ServiceLocator $locator */
175+
$locator = $container->get(Locator::class)->locator;
176+
static::assertTrue($locator->has(Service::class));
177+
static::assertFalse($locator->has(Decorated::class));
178+
static::assertInstanceOf(Decorated::class, $locator->get(Service::class));
179+
}
180+
}
181+
182+
class Locator
183+
{
184+
/**
185+
* @var ServiceLocator
186+
*/
187+
public $locator;
188+
189+
public function __construct(ServiceLocator $locator)
190+
{
191+
$this->locator = $locator;
192+
}
193+
}
194+
195+
class Service
196+
{
197+
}
198+
199+
class DecoratedService
200+
{
146201
}

0 commit comments

Comments
 (0)