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 123d5b2

Browse filesBrowse files
committed
Merge branch '4.4'
2 parents 4786098 + 6811aaa commit 123d5b2
Copy full SHA for 123d5b2

File tree

8 files changed

+68
-5
lines changed
Filter options

8 files changed

+68
-5
lines changed

‎UPGRADE-4.4.md

Copy file name to clipboardExpand all lines: UPGRADE-4.4.md
+12Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,18 @@ DependencyInjection
4141
arguments: [!tagged_iterator app.handler]
4242
```
4343

44+
* Passing an instance of `Symfony\Component\DependencyInjection\Parameter` as class name to `Symfony\Component\DependencyInjection\Definition` is deprecated.
45+
46+
Before:
47+
```php
48+
new Definition(new Parameter('my_class'));
49+
```
50+
51+
After:
52+
```php
53+
new Definition('%my_class%');
54+
```
55+
4456
Filesystem
4557
----------
4658

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

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php
+5Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
use Http\Client\HttpClient;
1717
use Psr\Cache\CacheItemPoolInterface;
1818
use Psr\Container\ContainerInterface as PsrContainerInterface;
19+
use Psr\EventDispatcher\EventDispatcherInterface as PsrEventDispatcherInterface;
1920
use Psr\Http\Client\ClientInterface;
2021
use Psr\Log\LoggerAwareInterface;
2122
use Symfony\Bridge\Monolog\Processor\DebugProcessor;
@@ -145,6 +146,10 @@ public function load(array $configs, ContainerBuilder $container)
145146
$loader->load('fragment_renderer.xml');
146147
$loader->load('error_catcher.xml');
147148

149+
if (interface_exists(PsrEventDispatcherInterface::class)) {
150+
$container->setAlias(PsrEventDispatcherInterface::class, 'event_dispatcher');
151+
}
152+
148153
$container->registerAliasForArgument('parameter_bag', PsrContainerInterface::class);
149154

150155
if (class_exists(Application::class)) {

‎src/Symfony/Bundle/SecurityBundle/DependencyInjection/SecurityExtension.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/SecurityBundle/DependencyInjection/SecurityExtension.php
+6-1Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
use Symfony\Component\Security\Core\Encoder\SodiumPasswordEncoder;
3434
use Symfony\Component\Security\Core\User\UserProviderInterface;
3535
use Symfony\Component\Security\Http\Controller\UserValueResolver;
36+
use Twig\Extension\AbstractExtension;
3637

3738
/**
3839
* SecurityExtension.
@@ -98,7 +99,11 @@ public function load(array $configs, ContainerBuilder $container)
9899
$loader->load('security.xml');
99100
$loader->load('security_listeners.xml');
100101
$loader->load('security_rememberme.xml');
101-
$loader->load('templating_twig.xml');
102+
103+
if (class_exists(AbstractExtension::class)) {
104+
$loader->load('templating_twig.xml');
105+
}
106+
102107
$loader->load('collectors.xml');
103108
$loader->load('guard.xml');
104109

‎src/Symfony/Component/DependencyInjection/CHANGELOG.md

Copy file name to clipboardExpand all lines: src/Symfony/Component/DependencyInjection/CHANGELOG.md
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ CHANGELOG
1818

1919
* deprecated support for short factories and short configurators in Yaml
2020
* deprecated `tagged` in favor of `tagged_iterator`
21+
* deprecated passing an instance of `Symfony\Component\DependencyInjection\Parameter` as class name to `Symfony\Component\DependencyInjection\Definition`
2122

2223
4.3.0
2324
-----

‎src/Symfony/Component/DependencyInjection/Definition.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/DependencyInjection/Definition.php
+7Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,13 @@ public function getDecoratedService()
171171
*/
172172
public function setClass($class)
173173
{
174+
if ($class instanceof Parameter) {
175+
@trigger_error(sprintf('Passing an instance of %s as class name to %s in deprecated in Symfony 4.4 and will result in a TypeError in 5.0. Please pass the string "%%%s%%" instead.', Parameter::class, __CLASS__, (string) $class), E_USER_DEPRECATED);
176+
}
177+
if (null !== $class && !\is_string($class)) {
178+
@trigger_error(sprintf('The class name passed to %s is expected to be a string. Passing a %s is deprecated in Symfony 4.4 and will result in a TypeError in 5.0.', __CLASS__, \is_object($class) ? \get_class($class) : \gettype($class)), E_USER_DEPRECATED);
179+
}
180+
174181
$this->changes['class'] = true;
175182

176183
$this->class = $class;

‎src/Symfony/Component/DependencyInjection/Tests/DefinitionTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/DependencyInjection/Tests/DefinitionTest.php
+35Lines changed: 35 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\Definition;
16+
use Symfony\Component\DependencyInjection\Parameter;
1617
use Symfony\Component\DependencyInjection\Reference;
1718

1819
class DefinitionTest extends TestCase
@@ -27,6 +28,18 @@ public function testConstructor()
2728
$this->assertEquals(['foo'], $def->getArguments(), '__construct() takes an optional array of arguments as its second argument');
2829
}
2930

31+
/**
32+
* @group legacy
33+
* @expectedDeprecation Passing an instance of Symfony\Component\DependencyInjection\Parameter as class name to Symfony\Component\DependencyInjection\Definition in deprecated in Symfony 4.4 and will result in a TypeError in 5.0. Please pass the string "%parameter%" instead.
34+
*/
35+
public function testConstructorWithParameter()
36+
{
37+
$parameter = new Parameter('parameter');
38+
39+
$def = new Definition($parameter);
40+
$this->assertSame($parameter, $def->getClass(), '__construct() accepts Parameter instances');
41+
}
42+
3043
public function testSetGetFactory()
3144
{
3245
$def = new Definition();
@@ -49,6 +62,28 @@ public function testSetGetClass()
4962
$this->assertEquals('foo', $def->getClass(), '->getClass() returns the class name');
5063
}
5164

65+
/**
66+
* @group legacy
67+
* @expectedDeprecation Passing an instance of Symfony\Component\DependencyInjection\Parameter as class name to Symfony\Component\DependencyInjection\Definition in deprecated in Symfony 4.4 and will result in a TypeError in 5.0. Please pass the string "%parameter%" instead.
68+
*/
69+
public function testSetGetClassWithParameter()
70+
{
71+
$def = new Definition();
72+
$parameter = new Parameter('parameter');
73+
$this->assertSame($parameter, $def->setClass($parameter)->getClass(), '->getClass() returns the parameterized class name');
74+
}
75+
76+
/**
77+
* @group legacy
78+
* @expectedDeprecation The class name passed to Symfony\Component\DependencyInjection\Definition is expected to be a string. Passing a stdClass is deprecated in Symfony 4.4 and will result in a TypeError in 5.0.
79+
*/
80+
public function testSetGetClassWithObject()
81+
{
82+
$def = new Definition();
83+
$classObject = new \stdClass();
84+
$this->assertSame($classObject, $def->setClass($classObject)->getClass(), '->getClass() returns the parameterized class name');
85+
}
86+
5287
public function testSetGetDecoratedService()
5388
{
5489
$def = new Definition('stdClass');

‎src/Symfony/Component/DependencyInjection/Tests/Dumper/PhpDumperTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/DependencyInjection/Tests/Dumper/PhpDumperTest.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1082,7 +1082,7 @@ public function testDumpHandlesObjectClassNames()
10821082
'class' => 'stdClass',
10831083
]));
10841084

1085-
$container->setDefinition('foo', new Definition(new Parameter('class')));
1085+
$container->setDefinition('foo', new Definition('%class%'));
10861086
$container->setDefinition('bar', new Definition('stdClass', [
10871087
new Reference('foo'),
10881088
]))->setPublic(true);

‎src/Symfony/Component/Messenger/Tests/DependencyInjection/MessengerPassTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Messenger/Tests/DependencyInjection/MessengerPassTest.php
+1-3Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -494,10 +494,8 @@ public function testNeedsToHandleAtLeastOneMessage()
494494

495495
public function testRegistersTraceableBusesToCollector()
496496
{
497-
$dataCollector = $this->getMockBuilder(MessengerDataCollector::class)->getMock();
498-
499497
$container = $this->getContainerBuilder($fooBusId = 'messenger.bus.foo');
500-
$container->register('data_collector.messenger', $dataCollector);
498+
$container->register('data_collector.messenger', MessengerDataCollector::class);
501499
$container->setParameter('kernel.debug', true);
502500

503501
(new MessengerPass())->process($container);

0 commit comments

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