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 8acfd3a

Browse filesBrowse files
Merge branch '5.0'
* 5.0: [Debug] fix ClassNotFoundFatalErrorHandler [FrameworkBundle] Document the router.cache_class_prefix parameter removal [Routing] Fix using a custom matcher & generator dumper class [Notifier] Add more specific types at documentation level when php engine can't [Serializer] Fix cache in MetadataAwareNameConverter [Dotenv] Fixed infinite loop with missing quote followed by quoted value [HttpClient] Added missing sprintf [TwigBridge] button_widget now has its title attr translated even if its label = null or false [PhpUnitBridge] When using phpenv + phpenv-composer plugin, composer executable is wrapped into a bash script [Messenger] Added check if json_encode succeeded [Messenger] Added check if json_encode succeeded [FrameworkBundle][ContainerLintCommand] Only skip .errored. services [HttpClient] fix exception in case of PSR17 discovery failure [DependencyInjection] Handle ServiceClosureArgument for callable in container linting fix processing chain adapter based cache pool [HttpKernel] release lock explicitly [Security] Prevent canceled remember-me cookie from being accepted [FrameworkBundle][TranslationUpdateCommand] Do not output positive feedback on stderr [Security\Guard] Fix missing typehints do not render preferred choices as selected
2 parents 20bf17f + d65de0f commit 8acfd3a
Copy full SHA for 8acfd3a

File tree

Expand file treeCollapse file tree

35 files changed

+225
-48
lines changed
Filter options
Expand file treeCollapse file tree

35 files changed

+225
-48
lines changed

‎UPGRADE-4.2.md

Copy file name to clipboardExpand all lines: UPGRADE-4.2.md
+11-11Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -192,15 +192,15 @@ HttpKernel
192192

193193
* The `Kernel::getRootDir()` and the `kernel.root_dir` parameter have been deprecated
194194
* The `KernelInterface::getName()` and the `kernel.name` parameter have been deprecated
195-
* Deprecated the first and second constructor argument of `ConfigDataCollector`
196-
* Deprecated `ConfigDataCollector::getApplicationName()`
195+
* Deprecated the first and second constructor argument of `ConfigDataCollector`
196+
* Deprecated `ConfigDataCollector::getApplicationName()`
197197
* Deprecated `ConfigDataCollector::getApplicationVersion()`
198198

199199
Messenger
200200
---------
201201

202202
* The `MiddlewareInterface::handle()` and `SenderInterface::send()` methods must now return an `Envelope` instance.
203-
* The return value of handlers isn't forwarded anymore by middleware and buses.
203+
* The return value of handlers isn't forwarded anymore by middleware and buses.
204204
If you used to return a value, e.g in query bus handlers, you can either:
205205
- get the result from the `HandledStamp` in the envelope returned by the bus.
206206
- use the `HandleTrait` to leverage a message bus, expecting a single, synchronous message handling and returning its result.
@@ -214,23 +214,23 @@ Messenger
214214
$query->setResult($yourResult);
215215
```
216216
* The `EnvelopeAwareInterface` was removed and the `MiddlewareInterface::handle()` method now requires an `Envelope` object
217-
as first argument. When using built-in middleware with the provided `MessageBus`, you will not have to do anything.
218-
If you use your own `MessageBusInterface` implementation, you must wrap the message in an `Envelope` before passing it to middleware.
217+
as first argument. When using built-in middleware with the provided `MessageBus`, you will not have to do anything.
218+
If you use your own `MessageBusInterface` implementation, you must wrap the message in an `Envelope` before passing it to middleware.
219219
If you created your own middleware, you must change the signature to always expect an `Envelope`.
220220
* The `MiddlewareInterface::handle()` second argument (`callable $next`) has changed in favor of a `StackInterface` instance.
221-
When using built-in middleware with the provided `MessageBus`, you will not have to do anything.
222-
If you use your own `MessageBusInterface` implementation, you can use the `StackMiddleware` implementation.
221+
When using built-in middleware with the provided `MessageBus`, you will not have to do anything.
222+
If you use your own `MessageBusInterface` implementation, you can use the `StackMiddleware` implementation.
223223
If you created your own middleware, you must change the signature to always expect an `StackInterface` instance
224224
and call `$stack->next()->handle($envelope, $stack)` instead of `$next` to call the next middleware:
225-
225+
226226
Before:
227227
```php
228228
public function handle($message, callable $next): Envelope
229229
{
230230
// do something before
231231
$message = $next($message);
232232
// do something after
233-
233+
234234
return $message;
235235
}
236236
```
@@ -242,7 +242,7 @@ Messenger
242242
// do something before
243243
$envelope = $stack->next()->handle($envelope, $stack);
244244
// do something after
245-
245+
246246
return $envelope;
247247
}
248248
```
@@ -251,7 +251,7 @@ Messenger
251251
respectively `ReceivedStamp`, `ValidationStamp`, `SerializerStamp` and moved to the `Stamp` namespace.
252252
* `AllowNoHandlerMiddleware` has been removed in favor of a new constructor argument on `HandleMessageMiddleware`
253253
* The `ConsumeMessagesCommand` class now takes an instance of `Psr\Container\ContainerInterface`
254-
as first constructor argument, i.e a message bus locator. The CLI command now expects a mandatory
254+
as first constructor argument, i.e a message bus locator. The CLI command now expects a mandatory
255255
`--bus` option value if there is more than one bus in the locator.
256256
* `MessageSubscriberInterface::getHandledMessages()` return value has changed. The value of an array item
257257
needs to be an associative array or the method name.

‎UPGRADE-5.0.md

Copy file name to clipboardExpand all lines: UPGRADE-5.0.md
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,7 @@ FrameworkBundle
243243
* Removed `routing.loader.service`.
244244
* Added support for PHPUnit 8. A `void` return-type was added to the `KernelTestCase::tearDown()` and `WebTestCase::tearDown()` method.
245245
* Removed the `lock.store.flock`, `lock.store.semaphore`, `lock.store.memcached.abstract` and `lock.store.redis.abstract` services.
246+
* Removed the `router.cache_class_prefix` parameter.
246247

247248
HttpClient
248249
----------

‎src/Symfony/Bridge/PhpUnit/bin/simple-phpunit.php

Copy file name to clipboardExpand all lines: src/Symfony/Bridge/PhpUnit/bin/simple-phpunit.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@
106106
|| ($COMPOSER = rtrim('\\' === DIRECTORY_SEPARATOR ? preg_replace('/[\r\n].*/', '', `where.exe composer.phar`) : `which composer.phar 2> /dev/null`))
107107
|| ($COMPOSER = rtrim('\\' === DIRECTORY_SEPARATOR ? preg_replace('/[\r\n].*/', '', `where.exe composer`) : `which composer 2> /dev/null`))
108108
|| file_exists($COMPOSER = rtrim('\\' === DIRECTORY_SEPARATOR ? `git rev-parse --show-toplevel 2> NUL` : `git rev-parse --show-toplevel 2> /dev/null`).DIRECTORY_SEPARATOR.'composer.phar')
109-
? $PHP.' '.escapeshellarg($COMPOSER)
109+
? (file_get_contents($COMPOSER, null, 0, 18) === '#!/usr/bin/env php' ? $PHP : '').' '.escapeshellarg($COMPOSER) // detect shell wrappers by looking at the shebang
110110
: 'composer';
111111

112112
$SYMFONY_PHPUNIT_REMOVE = $getEnvVar('SYMFONY_PHPUNIT_REMOVE', 'phpspec/prophecy'.($PHPUNIT_VERSION < 6.0 ? ' symfony/yaml': ''));

‎src/Symfony/Bridge/Twig/Resources/views/Form/form_div_layout.html.twig

Copy file name to clipboardExpand all lines: src/Symfony/Bridge/Twig/Resources/views/Form/form_div_layout.html.twig
+5-5Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -65,12 +65,14 @@
6565
{%- endif -%}
6666
{%- if preferred_choices|length > 0 -%}
6767
{% set options = preferred_choices %}
68+
{% set render_preferred_choices = true %}
6869
{{- block('choice_widget_options') -}}
6970
{%- if choices|length > 0 and separator is not none -%}
7071
<option disabled="disabled">{{ separator }}</option>
7172
{%- endif -%}
7273
{%- endif -%}
7374
{%- set options = choices -%}
75+
{%- set render_preferred_choices = false -%}
7476
{{- block('choice_widget_options') -}}
7577
</select>
7678
{%- endblock choice_widget_collapsed -%}
@@ -83,7 +85,7 @@
8385
{{- block('choice_widget_options') -}}
8486
</optgroup>
8587
{%- else -%}
86-
<option value="{{ choice.value }}"{% if choice.attr %}{% with { attr: choice.attr } %}{{ block('attributes') }}{% endwith %}{% endif %}{% if choice is selectedchoice(value) %} selected="selected"{% endif %}>{{ choice_translation_domain is same as(false) ? choice.label : choice.label|trans({}, choice_translation_domain) }}</option>
88+
<option value="{{ choice.value }}"{% if choice.attr %}{% with { attr: choice.attr } %}{{ block('attributes') }}{% endwith %}{% endif %}{% if not render_preferred_choices|default(false) and choice is selectedchoice(value) %} selected="selected"{% endif %}>{{ choice_translation_domain is same as(false) ? choice.label : choice.label|trans({}, choice_translation_domain) }}</option>
8789
{%- endif -%}
8890
{% endfor %}
8991
{%- endblock choice_widget_options -%}
@@ -226,13 +228,11 @@
226228
'%name%': name,
227229
'%id%': id,
228230
}) %}
229-
{%- elseif label is same as(false) -%}
230-
{% set translation_domain = false %}
231-
{%- else -%}
231+
{%- elseif label is not same as(false) -%}
232232
{% set label = name|humanize %}
233233
{%- endif -%}
234234
{%- endif -%}
235-
<button type="{{ type|default('button') }}" {{ block('button_attributes') }}>{{ translation_domain is same as(false) ? label : label|trans(label_translation_parameters, translation_domain) }}</button>
235+
<button type="{{ type|default('button') }}" {{ block('button_attributes') }}>{{ translation_domain is same as(false) or label is same as(false) ? label : label|trans(label_translation_parameters, translation_domain) }}</button>
236236
{%- endblock button_widget -%}
237237

238238
{%- block submit_widget -%}

‎src/Symfony/Bridge/Twig/Resources/views/Form/foundation_5_layout.html.twig

Copy file name to clipboardExpand all lines: src/Symfony/Bridge/Twig/Resources/views/Form/foundation_5_layout.html.twig
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,12 +160,14 @@
160160
{%- endif %}
161161
{%- if preferred_choices|length > 0 -%}
162162
{% set options = preferred_choices %}
163+
{% set render_preferred_choices = true %}
163164
{{- block('choice_widget_options') -}}
164165
{% if choices|length > 0 and separator is not none -%}
165166
<option disabled="disabled">{{ separator }}</option>
166167
{%- endif %}
167168
{%- endif -%}
168169
{% set options = choices -%}
170+
{%- set render_preferred_choices = false -%}
169171
{{- block('choice_widget_options') -}}
170172
</select>
171173
{%- endblock choice_widget_collapsed %}

‎src/Symfony/Bridge/Twig/Tests/Extension/AbstractBootstrap3LayoutTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Bridge/Twig/Tests/Extension/AbstractBootstrap3LayoutTest.php
+25Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -546,6 +546,31 @@ public function testSingleChoiceWithPreferred()
546546
);
547547
}
548548

549+
public function testSingleChoiceWithSelectedPreferred()
550+
{
551+
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', '&a', [
552+
'choices' => ['Choice&A' => '&a', 'Choice&B' => '&b'],
553+
'preferred_choices' => ['&a'],
554+
'multiple' => false,
555+
'expanded' => false,
556+
]);
557+
558+
$this->assertWidgetMatchesXpath($form->createView(), ['separator' => '-- sep --', 'attr' => ['class' => 'my&class']],
559+
'/select
560+
[@name="name"]
561+
[@class="my&class form-control"]
562+
[not(@required)]
563+
[
564+
./option[@value="&a"][not(@selected)][.="[trans]Choice&A[/trans]"]
565+
/following-sibling::option[@disabled="disabled"][not(@selected)][.="-- sep --"]
566+
/following-sibling::option[@value="&a"][@selected="selected"][.="[trans]Choice&A[/trans]"]
567+
/following-sibling::option[@value="&b"][.="[trans]Choice&B[/trans]"]
568+
]
569+
[count(./option)=4]
570+
'
571+
);
572+
}
573+
549574
public function testSingleChoiceWithPreferredAndNoSeparator()
550575
{
551576
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', '&a', [

‎src/Symfony/Bundle/FrameworkBundle/CHANGELOG.md

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/CHANGELOG.md
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ CHANGELOG
2929
* Service route loaders must be tagged with `routing.route_loader`.
3030
* Added `slugger` service and `SluggerInterface` alias
3131
* Removed the `lock.store.flock`, `lock.store.semaphore`, `lock.store.memcached.abstract` and `lock.store.redis.abstract` services.
32+
* Removed the `router.cache_class_prefix` parameter.
3233

3334
4.4.0
3435
-----

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

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/Command/ContainerLintCommand.php
+6-5Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -102,11 +102,12 @@ private function getContainerBuilder(): ContainerBuilder
102102
$refl->setAccessible(true);
103103
$refl->setValue($parameterBag, true);
104104

105-
$passConfig = $container->getCompilerPassConfig();
106-
$passConfig->setRemovingPasses([]);
107-
$passConfig->setAfterRemovingPasses([]);
108-
109-
$skippedIds = $kernelContainer->getRemovedIds();
105+
$skippedIds = [];
106+
foreach ($container->getServiceIds() as $serviceId) {
107+
if (0 === strpos($serviceId, '.errored.')) {
108+
$skippedIds[$serviceId] = true;
109+
}
110+
}
110111
}
111112

112113
$container->setParameter('container.build_hash', 'lint_container');

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

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/Command/TranslationUpdateCommand.php
+7-7Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -175,12 +175,12 @@ protected function execute(InputInterface $input, OutputInterface $output): int
175175
}
176176
}
177177

178-
$errorIo->title('Translation Messages Extractor and Dumper');
179-
$errorIo->comment(sprintf('Generating "<info>%s</info>" translation files for "<info>%s</info>"', $input->getArgument('locale'), $currentName));
178+
$io->title('Translation Messages Extractor and Dumper');
179+
$io->comment(sprintf('Generating "<info>%s</info>" translation files for "<info>%s</info>"', $input->getArgument('locale'), $currentName));
180180

181181
// load any messages from templates
182182
$extractedCatalogue = new MessageCatalogue($input->getArgument('locale'));
183-
$errorIo->comment('Parsing templates...');
183+
$io->comment('Parsing templates...');
184184
$this->extractor->setPrefix($input->getOption('prefix'));
185185
foreach ($viewsPaths as $path) {
186186
if (is_dir($path) || is_file($path)) {
@@ -190,7 +190,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
190190

191191
// load any existing messages from the translation files
192192
$currentCatalogue = new MessageCatalogue($input->getArgument('locale'));
193-
$errorIo->comment('Loading translation files...');
193+
$io->comment('Loading translation files...');
194194
foreach ($transPaths as $path) {
195195
if (is_dir($path)) {
196196
$this->reader->read($path, $currentCatalogue);
@@ -258,7 +258,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
258258
}
259259

260260
if ('xlf' === $input->getOption('output-format')) {
261-
$errorIo->comment(sprintf('Xliff output version is <info>%s</info>', $input->getOption('xliff-version')));
261+
$io->comment(sprintf('Xliff output version is <info>%s</info>', $input->getOption('xliff-version')));
262262
}
263263

264264
$resultMessage = sprintf('%d message%s successfully extracted', $extractedMessagesCount, $extractedMessagesCount > 1 ? 's were' : ' was');
@@ -270,7 +270,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
270270

271271
// save the files
272272
if (true === $input->getOption('force')) {
273-
$errorIo->comment('Writing files...');
273+
$io->comment('Writing files...');
274274

275275
$bundleTransPath = false;
276276
foreach ($transPaths as $path) {
@@ -290,7 +290,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
290290
}
291291
}
292292

293-
$errorIo->success($resultMessage.'.');
293+
$io->success($resultMessage.'.');
294294

295295
return 0;
296296
}

‎src/Symfony/Bundle/SecurityBundle/Tests/Functional/ClearRememberMeTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/SecurityBundle/Tests/Functional/ClearRememberMeTest.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public function testUserChangeClearsCookie()
3333
$this->assertNotNull($cookieJar->get('REMEMBERME'));
3434

3535
$client->request('GET', '/foo');
36-
$this->assertSame(200, $client->getResponse()->getStatusCode());
36+
$this->assertRedirect($client->getResponse(), '/login');
3737
$this->assertNull($cookieJar->get('REMEMBERME'));
3838
}
3939
}

‎src/Symfony/Component/Cache/DependencyInjection/CachePoolPass.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Cache/DependencyInjection/CachePoolPass.php
+6-1Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,12 @@ public function process(ContainerBuilder $container)
103103
if (ChainAdapter::class === $class) {
104104
$adapters = [];
105105
foreach ($adapter->getArgument(0) as $provider => $adapter) {
106-
$chainedPool = $adapter = new ChildDefinition($adapter);
106+
if ($adapter instanceof ChildDefinition) {
107+
$chainedPool = $adapter;
108+
} else {
109+
$chainedPool = $adapter = new ChildDefinition($adapter);
110+
}
111+
107112
$chainedTags = [\is_int($provider) ? [] : ['provider' => $provider]];
108113
$chainedClass = '';
109114

‎src/Symfony/Component/Cache/Tests/DependencyInjection/CachePoolPassTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Cache/Tests/DependencyInjection/CachePoolPassTest.php
+40Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@
1212
namespace Symfony\Component\Cache\Tests\DependencyInjection;
1313

1414
use PHPUnit\Framework\TestCase;
15+
use Symfony\Component\Cache\Adapter\ApcuAdapter;
1516
use Symfony\Component\Cache\Adapter\ArrayAdapter;
17+
use Symfony\Component\Cache\Adapter\ChainAdapter;
1618
use Symfony\Component\Cache\Adapter\RedisAdapter;
1719
use Symfony\Component\Cache\DependencyInjection\CachePoolPass;
1820
use Symfony\Component\DependencyInjection\ChildDefinition;
@@ -174,4 +176,42 @@ public function testThrowsExceptionWhenCachePoolTagHasUnknownAttributes()
174176

175177
$this->cachePoolPass->process($container);
176178
}
179+
180+
public function testChainAdapterPool()
181+
{
182+
$container = new ContainerBuilder();
183+
$container->setParameter('kernel.container_class', 'app');
184+
$container->setParameter('kernel.project_dir', 'foo');
185+
186+
$container->register('cache.adapter.array', ArrayAdapter::class)
187+
->addTag('cache.pool');
188+
$container->register('cache.adapter.apcu', ApcuAdapter::class)
189+
->setArguments([null, 0, null])
190+
->addTag('cache.pool');
191+
$container->register('cache.chain', ChainAdapter::class)
192+
->addArgument(['cache.adapter.array', 'cache.adapter.apcu'])
193+
->addTag('cache.pool');
194+
$container->setDefinition('cache.app', new ChildDefinition('cache.chain'))
195+
->addTag('cache.pool');
196+
$container->setDefinition('doctrine.result_cache_pool', new ChildDefinition('cache.app'))
197+
->addTag('cache.pool');
198+
199+
$this->cachePoolPass->process($container);
200+
201+
$appCachePool = $container->getDefinition('cache.app');
202+
$this->assertInstanceOf(ChildDefinition::class, $appCachePool);
203+
$this->assertSame('cache.chain', $appCachePool->getParent());
204+
205+
$chainCachePool = $container->getDefinition('cache.chain');
206+
$this->assertNotInstanceOf(ChildDefinition::class, $chainCachePool);
207+
$this->assertCount(2, $chainCachePool->getArgument(0));
208+
$this->assertInstanceOf(ChildDefinition::class, $chainCachePool->getArgument(0)[0]);
209+
$this->assertSame('cache.adapter.array', $chainCachePool->getArgument(0)[0]->getParent());
210+
$this->assertInstanceOf(ChildDefinition::class, $chainCachePool->getArgument(0)[1]);
211+
$this->assertSame('cache.adapter.apcu', $chainCachePool->getArgument(0)[1]->getParent());
212+
213+
$doctrineCachePool = $container->getDefinition('doctrine.result_cache_pool');
214+
$this->assertInstanceOf(ChildDefinition::class, $doctrineCachePool);
215+
$this->assertSame('cache.app', $doctrineCachePool->getParent());
216+
}
177217
}

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

Copy file name to clipboardExpand all lines: src/Symfony/Component/DependencyInjection/Compiler/CheckTypeDeclarationsPass.php
+5Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
namespace Symfony\Component\DependencyInjection\Compiler;
1313

1414
use Symfony\Component\DependencyInjection\Argument\IteratorArgument;
15+
use Symfony\Component\DependencyInjection\Argument\ServiceClosureArgument;
1516
use Symfony\Component\DependencyInjection\Container;
1617
use Symfony\Component\DependencyInjection\Definition;
1718
use Symfony\Component\DependencyInjection\Exception\EnvNotFoundException;
@@ -219,6 +220,10 @@ private function checkType(Definition $checkedDefinition, $value, \ReflectionPar
219220
return;
220221
}
221222

223+
if (\in_array($type, ['callable', 'Closure'], true) && $value instanceof ServiceClosureArgument) {
224+
return;
225+
}
226+
222227
if ('iterable' === $type && (\is_array($value) || $value instanceof \Traversable || $value instanceof IteratorArgument)) {
223228
return;
224229
}

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

Copy file name to clipboardExpand all lines: src/Symfony/Component/DependencyInjection/Tests/Compiler/CheckTypeDeclarationsPassTest.php
+25Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
use PHPUnit\Framework\TestCase;
1515
use Symfony\Component\DependencyInjection\Argument\IteratorArgument;
16+
use Symfony\Component\DependencyInjection\Argument\ServiceClosureArgument;
1617
use Symfony\Component\DependencyInjection\Compiler\CheckTypeDeclarationsPass;
1718
use Symfony\Component\DependencyInjection\Compiler\ResolveParameterPlaceHoldersPass;
1819
use Symfony\Component\DependencyInjection\ContainerBuilder;
@@ -697,4 +698,28 @@ public function testProcessHandleClosureForCallable()
697698

698699
$this->addToAssertionCount(1);
699700
}
701+
702+
public function testProcessSuccessWhenPassingServiceClosureArgumentToCallable()
703+
{
704+
$container = new ContainerBuilder();
705+
706+
$container->register('bar', BarMethodCall::class)
707+
->addMethodCall('setCallable', [new ServiceClosureArgument(new Reference('foo'))]);
708+
709+
(new CheckTypeDeclarationsPass(true))->process($container);
710+
711+
$this->addToAssertionCount(1);
712+
}
713+
714+
public function testProcessSuccessWhenPassingServiceClosureArgumentToClosure()
715+
{
716+
$container = new ContainerBuilder();
717+
718+
$container->register('bar', BarMethodCall::class)
719+
->addMethodCall('setClosure', [new ServiceClosureArgument(new Reference('foo'))]);
720+
721+
(new CheckTypeDeclarationsPass(true))->process($container);
722+
723+
$this->addToAssertionCount(1);
724+
}
700725
}

‎src/Symfony/Component/DependencyInjection/Tests/Fixtures/CheckTypeDeclarationsPass/BarMethodCall.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/DependencyInjection/Tests/Fixtures/CheckTypeDeclarationsPass/BarMethodCall.php
+4Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,4 +40,8 @@ public function setIterable(iterable $iterable)
4040
public function setCallable(callable $callable): void
4141
{
4242
}
43+
44+
public function setClosure(\Closure $closure): void
45+
{
46+
}
4347
}

0 commit comments

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