You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: UPGRADE-4.4.md
+12Lines changed: 12 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -41,6 +41,18 @@ DependencyInjection
41
41
arguments: [!tagged_iterator app.handler]
42
42
```
43
43
44
+
* Passing an instance of `Symfony\Component\DependencyInjection\Parameter` as class name to `Symfony\Component\DependencyInjection\Definition` is deprecated.
Copy file name to clipboardExpand all lines: src/Symfony/Component/DependencyInjection/CHANGELOG.md
+1Lines changed: 1 addition & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,6 +6,7 @@ CHANGELOG
6
6
7
7
* deprecated support for short factories and short configurators in Yaml
8
8
* deprecated `tagged` in favor of `tagged_iterator`
9
+
* deprecated passing an instance of `Symfony\Component\DependencyInjection\Parameter` as class name to `Symfony\Component\DependencyInjection\Definition`
Copy file name to clipboardExpand all lines: src/Symfony/Component/DependencyInjection/Definition.php
+7Lines changed: 7 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -171,6 +171,13 @@ public function getDecoratedService()
171
171
*/
172
172
publicfunctionsetClass($class)
173
173
{
174
+
if ($classinstanceof 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);
@@ -27,6 +28,18 @@ public function testConstructor()
27
28
$this->assertEquals(['foo'], $def->getArguments(), '__construct() takes an optional array of arguments as its second argument');
28
29
}
29
30
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.
@@ -49,6 +62,28 @@ public function testSetGetClass()
49
62
$this->assertEquals('foo', $def->getClass(), '->getClass() returns the class name');
50
63
}
51
64
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
+
publicfunctiontestSetGetClassWithParameter()
70
+
{
71
+
$def = newDefinition();
72
+
$parameter = newParameter('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
+
publicfunctiontestSetGetClassWithObject()
81
+
{
82
+
$def = newDefinition();
83
+
$classObject = new \stdClass();
84
+
$this->assertSame($classObject, $def->setClass($classObject)->getClass(), '->getClass() returns the parameterized class name');
0 commit comments