Skip to content

Navigation Menu

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 a057029

Browse filesBrowse files
Merge branch '6.1' into 6.2
* 6.1: Fix merge Fix merge [FrameworkBundle] fix tests [FrameworkBundle] fix wiring of annotations.cached_reader [SecurityBundle] Remove dead `class_exists` checks Fix BC break [DependencyInjection] Ignore unused bindings defined by attribute [ErrorHandler] update tentative types
2 parents 4dde161 + 90164c1 commit a057029
Copy full SHA for a057029

18 files changed

+63
-41
lines changed

‎src/Symfony/Bundle/FrameworkBundle/Command/AbstractConfigCommand.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/Command/AbstractConfigCommand.php
+3-2Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
use Symfony\Component\Console\Helper\Table;
1717
use Symfony\Component\Console\Output\OutputInterface;
1818
use Symfony\Component\Console\Style\StyleInterface;
19-
use Symfony\Component\DependencyInjection\ContainerBuilder;
2019
use Symfony\Component\DependencyInjection\Extension\ConfigurationExtensionInterface;
2120
use Symfony\Component\DependencyInjection\Extension\ExtensionInterface;
2221

@@ -55,7 +54,7 @@ protected function listBundles(OutputInterface|StyleInterface $output)
5554
}
5655
}
5756

58-
protected function findExtension(string $name, ContainerBuilder $container): ExtensionInterface
57+
protected function findExtension(string $name): ExtensionInterface
5958
{
6059
$bundles = $this->initializeBundles();
6160
$minScore = \INF;
@@ -93,6 +92,8 @@ protected function findExtension(string $name, ContainerBuilder $container): Ext
9392
}
9493
}
9594

95+
$container = $this->getContainerBuilder($kernel);
96+
9697
if ($container->hasExtension($name)) {
9798
return $container->getExtension($name);
9899
}

‎src/Symfony/Bundle/FrameworkBundle/Command/ConfigDebugCommand.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/Command/ConfigDebugCommand.php
+3-4Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -90,9 +90,9 @@ protected function execute(InputInterface $input, OutputInterface $output): int
9090
return 0;
9191
}
9292

93-
$container = $this->compileContainer();
94-
$extension = $this->findExtension($name, $container);
93+
$extension = $this->findExtension($name);
9594
$extensionAlias = $extension->getAlias();
95+
$container = $this->compileContainer();
9696

9797
$config = $this->getConfig($extension, $container);
9898

@@ -192,8 +192,7 @@ public function complete(CompletionInput $input, CompletionSuggestions $suggesti
192192

193193
if ($input->mustSuggestArgumentValuesFor('path') && null !== $name = $input->getArgument('name')) {
194194
try {
195-
$container = $this->compileContainer();
196-
$config = $this->getConfig($this->findExtension($name, $container), $container);
195+
$config = $this->getConfig($this->findExtension($name), $this->compileContainer());
197196
$paths = array_keys(self::buildPathsCompletion($config));
198197
$suggestions->suggestValues($paths);
199198
} catch (LogicException) {

‎src/Symfony/Bundle/FrameworkBundle/Command/ConfigDumpReferenceCommand.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/Command/ConfigDumpReferenceCommand.php
+2-3Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -103,13 +103,12 @@ protected function execute(InputInterface $input, OutputInterface $output): int
103103
return 0;
104104
}
105105

106-
$container = $this->getContainerBuilder($this->getApplication()->getKernel());
107-
$extension = $this->findExtension($name, $container);
106+
$extension = $this->findExtension($name);
108107

109108
if ($extension instanceof ConfigurationInterface) {
110109
$configuration = $extension;
111110
} else {
112-
$configuration = $extension->getConfiguration([], $container);
111+
$configuration = $extension->getConfiguration([], $this->getContainerBuilder($this->getApplication()->getKernel()));
113112
}
114113

115114
$this->validateConfiguration($extension, $configuration);

‎src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler/AddAnnotationsCachedReaderPass.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler/AddAnnotationsCachedReaderPass.php
-1Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ public function process(ContainerBuilder $container)
2929
// "annotation_reader" at build time don't get any cache
3030
foreach ($container->findTaggedServiceIds('annotations.cached_reader') as $id => $tags) {
3131
$reader = $container->getDefinition($id);
32-
$reader->setPublic(false);
3332
$properties = $reader->getProperties();
3433

3534
if (isset($properties['cacheProviderBackup'])) {

‎src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler/UnusedTagsPass.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler/UnusedTagsPass.php
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ class UnusedTagsPass implements CompilerPassInterface
3131
'chatter.transport_factory',
3232
'config_cache.resource_checker',
3333
'console.command',
34+
'container.do_not_inline',
3435
'container.env_var_loader',
3536
'container.env_var_processor',
3637
'container.hot_path',

‎src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -675,6 +675,8 @@ public function load(array $configs, ContainerBuilder $container)
675675
->addTag('routing.route_loader');
676676

677677
$container->setParameter('container.behavior_describing_tags', [
678+
'annotations.cached_reader',
679+
'container.do_not_inline',
678680
'container.service_locator',
679681
'container.service_subscriber',
680682
'kernel.event_subscriber',
@@ -1657,11 +1659,9 @@ private function registerAnnotationsConfiguration(array $config, ContainerBuilde
16571659

16581660
$container
16591661
->getDefinition('annotations.cached_reader')
1660-
->setPublic(true) // set to false in AddAnnotationsCachedReaderPass
16611662
->replaceArgument(2, $config['debug'])
16621663
// reference the cache provider without using it until AddAnnotationsCachedReaderPass runs
16631664
->addArgument(new ServiceClosureArgument(new Reference($cacheService)))
1664-
->addTag('annotations.cached_reader')
16651665
;
16661666

16671667
$container->setAlias('annotation_reader', 'annotations.cached_reader');

‎src/Symfony/Bundle/FrameworkBundle/Resources/config/annotations.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/Resources/config/annotations.php
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@
3737
inline_service(ArrayAdapter::class),
3838
abstract_arg('Debug-Flag'),
3939
])
40+
->tag('annotations.cached_reader')
41+
->tag('container.do_not_inline')
4042

4143
->set('annotations.filesystem_cache_adapter', FilesystemAdapter::class)
4244
->args([

‎src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1947,6 +1947,8 @@ public function testRegisterParameterCollectingBehaviorDescribingTags()
19471947

19481948
$this->assertTrue($container->hasParameter('container.behavior_describing_tags'));
19491949
$this->assertEquals([
1950+
'annotations.cached_reader',
1951+
'container.do_not_inline',
19501952
'container.service_locator',
19511953
'container.service_subscriber',
19521954
'kernel.event_subscriber',

‎src/Symfony/Bundle/SecurityBundle/DependencyInjection/Security/Factory/LdapFactoryTrait.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/SecurityBundle/DependencyInjection/Security/Factory/LdapFactoryTrait.php
-4Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,6 @@ public function getKey(): string
3535
public function createAuthenticator(ContainerBuilder $container, string $firewallName, array $config, string $userProviderId): string
3636
{
3737
$key = str_replace('-', '_', $this->getKey());
38-
if (!class_exists(LdapAuthenticator::class)) {
39-
throw new \LogicException(sprintf('The "%s" authenticator requires the "symfony/ldap" package version "5.1" or higher.', $key));
40-
}
41-
4238
$authenticatorId = parent::createAuthenticator($container, $firewallName, $config, $userProviderId);
4339

4440
$container->setDefinition('security.listener.'.$key.'.'.$firewallName, new Definition(CheckLdapCredentialsListener::class))

‎src/Symfony/Bundle/SecurityBundle/DependencyInjection/Security/Factory/LoginLinkFactory.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/SecurityBundle/DependencyInjection/Security/Factory/LoginLinkFactory.php
-5Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
use Symfony\Component\DependencyInjection\Reference;
2121
use Symfony\Component\Security\Http\Authentication\AuthenticationFailureHandlerInterface;
2222
use Symfony\Component\Security\Http\Authentication\AuthenticationSuccessHandlerInterface;
23-
use Symfony\Component\Security\Http\LoginLink\LoginLinkHandler;
2423

2524
/**
2625
* @internal
@@ -88,10 +87,6 @@ public function getKey(): string
8887

8988
public function createAuthenticator(ContainerBuilder $container, string $firewallName, array $config, string $userProviderId): string
9089
{
91-
if (!class_exists(LoginLinkHandler::class)) {
92-
throw new \LogicException('Login login link requires symfony/security-http:^5.2.');
93-
}
94-
9590
if (!$container->hasDefinition('security.authenticator.login_link')) {
9691
$loader = new PhpFileLoader($container, new FileLocator(\dirname(__DIR__).'/../../Resources/config'));
9792
$loader->load('security_authenticator_login_link.php');

‎src/Symfony/Bundle/SecurityBundle/DependencyInjection/Security/Factory/LoginThrottlingFactory.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/SecurityBundle/DependencyInjection/Security/Factory/LoginThrottlingFactory.php
-5Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
use Symfony\Component\DependencyInjection\Reference;
2020
use Symfony\Component\HttpFoundation\RateLimiter\RequestRateLimiterInterface;
2121
use Symfony\Component\RateLimiter\RateLimiterFactory;
22-
use Symfony\Component\Security\Http\EventListener\LoginThrottlingListener;
2322
use Symfony\Component\Security\Http\RateLimiter\DefaultLoginRateLimiter;
2423

2524
/**
@@ -56,10 +55,6 @@ public function addConfiguration(NodeDefinition $builder)
5655

5756
public function createAuthenticator(ContainerBuilder $container, string $firewallName, array $config, string $userProviderId): array
5857
{
59-
if (!class_exists(LoginThrottlingListener::class)) {
60-
throw new \LogicException('Login throttling requires symfony/security-http:^5.2.');
61-
}
62-
6358
if (!class_exists(RateLimiterFactory::class)) {
6459
throw new \LogicException('Login throttling requires the Rate Limiter component. Try running "composer require symfony/rate-limiter".');
6560
}

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

Copy file name to clipboardExpand all lines: src/Symfony/Component/DependencyInjection/Compiler/DecoratorServicePass.php
+6-2Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,10 @@ public function process(ContainerBuilder $container)
4040
}
4141
$decoratingDefinitions = [];
4242

43+
$tagsToKeep = $container->hasParameter('container.behavior_describing_tags')
44+
? $container->getParameter('container.behavior_describing_tags')
45+
: ['container.do_not_inline', 'container.service_locator', 'container.service_subscriber'];
46+
4347
foreach ($definitions as [$id, $definition]) {
4448
$decoratedService = $definition->getDecoratedService();
4549
[$inner, $renamedId] = $decoratedService;
@@ -90,8 +94,8 @@ public function process(ContainerBuilder $container)
9094
$decoratingTags = $decoratingDefinition->getTags();
9195
$resetTags = [];
9296

93-
// container.service_locator and container.service_subscriber have special logic and they must not be transferred out to decorators
94-
foreach (['container.service_locator', 'container.service_subscriber'] as $containerTag) {
97+
// Behavior-describing tags must not be transferred out to decorators
98+
foreach ($tagsToKeep as $containerTag) {
9599
if (isset($decoratingTags[$containerTag])) {
96100
$resetTags[$containerTag] = $decoratingTags[$containerTag];
97101
unset($decoratingTags[$containerTag]);

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

Copy file name to clipboardExpand all lines: src/Symfony/Component/DependencyInjection/Compiler/InlineServiceDefinitionsPass.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ protected function processValue(mixed $value, bool $isRoot = false): mixed
163163
*/
164164
private function isInlineableDefinition(string $id, Definition $definition): bool
165165
{
166-
if ($definition->hasErrors() || $definition->isDeprecated() || $definition->isLazy() || $definition->isSynthetic()) {
166+
if ($definition->hasErrors() || $definition->isDeprecated() || $definition->isLazy() || $definition->isSynthetic() || $definition->hasTag('container.do_not_inline')) {
167167
return false;
168168
}
169169

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

Copy file name to clipboardExpand all lines: src/Symfony/Component/DependencyInjection/Compiler/RegisterAutoconfigureAttributesPass.php
+2-1Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,8 @@ private static function registerForAutoconfiguration(ContainerBuilder $container
7777
],
7878
],
7979
],
80-
$class->getFileName()
80+
$class->getFileName(),
81+
false
8182
);
8283
};
8384

‎src/Symfony/Component/DependencyInjection/Loader/YamlFileLoader.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/DependencyInjection/Loader/YamlFileLoader.php
+5-5Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ private function parseImports(array $content, string $file)
220220
}
221221
}
222222

223-
private function parseDefinitions(array $content, string $file)
223+
private function parseDefinitions(array $content, string $file, bool $trackBindings = true)
224224
{
225225
if (!isset($content['services'])) {
226226
return;
@@ -246,14 +246,14 @@ private function parseDefinitions(array $content, string $file)
246246
if (\is_string($service) && str_starts_with($service, '@')) {
247247
throw new InvalidArgumentException(sprintf('Type definition "%s" cannot be an alias within "_instanceof" in "%s". Check your YAML syntax.', $id, $file));
248248
}
249-
$this->parseDefinition($id, $service, $file, []);
249+
$this->parseDefinition($id, $service, $file, [], false, $trackBindings);
250250
}
251251
}
252252

253253
$this->isLoadingInstanceof = false;
254254
$defaults = $this->parseDefaults($content, $file);
255255
foreach ($content['services'] as $id => $service) {
256-
$this->parseDefinition($id, $service, $file, $defaults);
256+
$this->parseDefinition($id, $service, $file, $defaults, false, $trackBindings);
257257
}
258258
}
259259

@@ -338,7 +338,7 @@ private function isUsingShortSyntax(array $service): bool
338338
/**
339339
* @throws InvalidArgumentException When tags are invalid
340340
*/
341-
private function parseDefinition(string $id, array|string|null $service, string $file, array $defaults, bool $return = false)
341+
private function parseDefinition(string $id, array|string|null $service, string $file, array $defaults, bool $return = false, bool $trackBindings = true)
342342
{
343343
if (preg_match('/^_[a-zA-Z0-9_]*$/', $id)) {
344344
throw new InvalidArgumentException(sprintf('Service names that start with an underscore are reserved. Rename the "%s" service or define it in XML instead.', $id));
@@ -662,7 +662,7 @@ private function parseDefinition(string $id, array|string|null $service, string
662662
$bindingType = $this->isLoadingInstanceof ? BoundArgument::INSTANCEOF_BINDING : BoundArgument::SERVICE_BINDING;
663663
foreach ($bindings as $argument => $value) {
664664
if (!$value instanceof BoundArgument) {
665-
$bindings[$argument] = new BoundArgument($value, true, $bindingType, $file);
665+
$bindings[$argument] = new BoundArgument($value, $trackBindings, $bindingType, $file);
666666
}
667667
}
668668
}

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

Copy file name to clipboardExpand all lines: src/Symfony/Component/DependencyInjection/Tests/Compiler/InlineServiceDefinitionsPassTest.php
+28Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -323,6 +323,34 @@ public function testProcessDoesNotSetLazyArgumentValuesAfterInlining()
323323
$this->assertSame('inline', (string) $values[0]);
324324
}
325325

326+
public function testDoNotInline()
327+
{
328+
$container = new ContainerBuilder();
329+
$container->register('decorated1', 'decorated1')->addTag('container.do_not_inline');
330+
$container->register('decorated2', 'decorated2')->addTag('container.do_not_inline');
331+
$container->setAlias('alias2', 'decorated2');
332+
333+
$container
334+
->register('s1', 's1')
335+
->setDecoratedService('decorated1')
336+
->setPublic(true)
337+
->setProperties(['inner' => new Reference('s1.inner')]);
338+
339+
$container
340+
->register('s2', 's2')
341+
->setDecoratedService('alias2')
342+
->setPublic(true)
343+
->setProperties(['inner' => new Reference('s2.inner')]);
344+
345+
$container->compile();
346+
347+
$this->assertFalse($container->hasAlias('alias2'));
348+
$this->assertEquals(new Reference('decorated2'), $container->getDefinition('s2')->getProperties()['inner']);
349+
$this->assertEquals(new Reference('s1.inner'), $container->getDefinition('s1')->getProperties()['inner']);
350+
$this->assertSame('decorated2', $container->getDefinition('decorated2')->getClass());
351+
$this->assertSame('decorated1', $container->getDefinition('s1.inner')->getClass());
352+
}
353+
326354
protected function process(ContainerBuilder $container)
327355
{
328356
(new InlineServiceDefinitionsPass(new AnalyzeServiceReferencesPass()))->process($container);

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

Copy file name to clipboardExpand all lines: src/Symfony/Component/DependencyInjection/Tests/Compiler/RegisterAutoconfigureAttributesPassTest.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public function testProcess()
3131

3232
(new RegisterAutoconfigureAttributesPass())->process($container);
3333

34-
$argument = new BoundArgument(1, true, BoundArgument::INSTANCEOF_BINDING, realpath(__DIR__.'/../Fixtures/AutoconfigureAttributed.php'));
34+
$argument = new BoundArgument(1, false, BoundArgument::INSTANCEOF_BINDING, realpath(__DIR__.'/../Fixtures/AutoconfigureAttributed.php'));
3535
$values = $argument->getValues();
3636
--$values[1];
3737
$argument->setValues($values);

‎src/Symfony/Component/ErrorHandler/Internal/TentativeTypes.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/ErrorHandler/Internal/TentativeTypes.php
+5-5Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ class TentativeTypes
3737
'DateTime' => [
3838
'__wakeup' => 'void',
3939
'__set_state' => 'DateTime',
40-
'createFromImmutable' => 'DateTime',
40+
'createFromImmutable' => 'static',
4141
'createFromFormat' => 'DateTime|false',
4242
'getLastErrors' => 'array|false',
4343
'format' => 'string',
@@ -72,7 +72,7 @@ class TentativeTypes
7272
'setDate' => 'DateTimeImmutable',
7373
'setISODate' => 'DateTimeImmutable',
7474
'setTimestamp' => 'DateTimeImmutable',
75-
'createFromMutable' => 'DateTimeImmutable',
75+
'createFromMutable' => 'static',
7676
],
7777
'DateTimeZone' => [
7878
'getName' => 'string',
@@ -1150,8 +1150,8 @@ class TentativeTypes
11501150
'getFlags' => 'int',
11511151
'setMaxLineLen' => 'void',
11521152
'getMaxLineLen' => 'int',
1153-
'hasChildren' => 'bool',
1154-
'getChildren' => '?RecursiveIterator',
1153+
'hasChildren' => 'false',
1154+
'getChildren' => 'null',
11551155
'seek' => 'void',
11561156
'getCurrentLine' => 'string',
11571157
],
@@ -1240,7 +1240,7 @@ class TentativeTypes
12401240
'current' => 'never',
12411241
'next' => 'void',
12421242
'key' => 'never',
1243-
'valid' => 'bool',
1243+
'valid' => 'false',
12441244
'rewind' => 'void',
12451245
],
12461246
'CallbackFilterIterator' => [

0 commit comments

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