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
if (false !== stripos($doc, '@required') && preg_match('#(?:^/\*\*|\n\s*+\*)\s*+@required(?:\s|\*/$)#i', $doc)) {
60
-
trigger_deprecation('symfony/dependency-injection', '6.3', 'The "@required" annotation is deprecated, use the "Symfony\Contracts\Service\Attribute\Required" attribute instead.');
60
+
trigger_deprecation('symfony/dependency-injection', '6.3', 'The "@required" annotation on methods is deprecated, use the "Symfony\Contracts\Service\Attribute\Required" attribute instead.');
trigger_deprecation('symfony/dependency-injection', '6.3', 'The "@required" annotation is deprecated, use the "Symfony\Contracts\Service\Attribute\Required" attribute instead.');
49
+
// Trigger a deprecation only when PHPDoc has been found.
50
+
if ($doc) {
51
+
trigger_deprecation('symfony/dependency-injection', '6.3', 'The "@required" annotation on methods is deprecated, use the "Symfony\Contracts\Service\Attribute\Required" attribute instead. It was found on property "%s::$%s".', $value::class, $reflectionProperty->getName());
52
+
}
49
53
if (\array_key_exists($name = $reflectionProperty->getName(), $properties)) {
Copy file name to clipboardExpand all lines: src/Symfony/Component/DependencyInjection/Tests/Compiler/AutowirePassTest.php
+75-10Lines changed: 75 additions & 10 deletions
Original file line number
Diff line number
Diff line change
@@ -698,8 +698,13 @@ public function testOptionalArgsNoRequiredForCoreClasses()
698
698
);
699
699
}
700
700
701
-
publicfunctiontestSetterInjection()
701
+
/**
702
+
* @group legacy
703
+
*/
704
+
publicfunctiontestSetterInjectionAnnotation()
702
705
{
706
+
$this->expectDeprecation('Since symfony/dependency-injection 6.3: The "@required" annotation on methods is deprecated, use the "Symfony\Contracts\Service\Attribute\Required" attribute instead.');
707
+
703
708
$container = newContainerBuilder();
704
709
$container->register(Foo::class);
705
710
$container->register(A::class);
@@ -708,7 +713,7 @@ public function testSetterInjection()
708
713
709
714
// manually configure *one* call, to override autowiring
$this->expectDeprecation('Since symfony/dependency-injection 6.3: The "@required" annotation is deprecated, use the "Symfony\Contracts\Service\Attribute\Required" attribute instead.');
778
-
779
779
$container = newContainerBuilder();
780
780
$container->register(Foo::class);
781
781
$container->register(A::class);
@@ -829,7 +829,33 @@ public function testIgnoreServiceWithClassNotExisting()
$this->expectDeprecation('Since symfony/dependency-injection 6.3: The "@required" annotation on methods is deprecated, use the "Symfony\Contracts\Service\Attribute\Required" attribute instead.');
$this->fail('AutowirePass should have thrown an exception');
853
+
} catch (AutowiringFailedException$e) {
854
+
$this->assertSame('Cannot autowire service "setter_injection_collision": argument "$collision" of method "Symfony\Component\DependencyInjection\Tests\Compiler\SetterInjectionCollisionAnnotation::setMultipleInstancesForOneArg()" references interface "Symfony\Component\DependencyInjection\Tests\Compiler\CollisionInterface" but no such service exists. You should maybe alias this interface to one of these existing services: "c1", "c2".', (string) $e->getMessage());
$this->expectDeprecation('Since symfony/dependency-injection 6.3: The "@required" annotation on methods is deprecated, use the "Symfony\Contracts\Service\Attribute\Required" attribute instead.');
$this->expectDeprecation('Since symfony/dependency-injection 6.3: The "@required" annotation on methods is deprecated, use the "Symfony\Contracts\Service\Attribute\Required" attribute instead.');
@@ -1137,6 +1172,36 @@ public function testErroredServiceLocator()
1137
1172
$this->assertSame(['Cannot autowire service "some_locator": it has type "Symfony\Component\DependencyInjection\Tests\Compiler\MissingClass" but this class was not found.'], $container->getDefinition('.errored.some_locator.'.MissingClass::class)->getErrors());
$this->expectDeprecation('Since symfony/dependency-injection 6.3: The "@required" annotation on methods is deprecated, use the "Symfony\Contracts\Service\Attribute\Required" attribute instead.');
@@ -24,17 +25,22 @@ class AutowireRequiredMethodsPassTest extends TestCase
24
25
{
25
26
use ExpectDeprecationTrait;
26
27
27
-
publicfunctiontestSetterInjection()
28
+
/**
29
+
* @group legacy
30
+
*/
31
+
publicfunctiontestSetterInjectionAnnotation()
28
32
{
33
+
$this->expectDeprecation('Since symfony/dependency-injection 6.3: The "@required" annotation on methods is deprecated, use the "Symfony\Contracts\Service\Attribute\Required" attribute instead.');
34
+
29
35
$container = newContainerBuilder();
30
-
$container->register(Foo::class);
36
+
$container->register(FooAnnotation::class);
31
37
$container->register(A::class);
32
38
$container->register(CollisionA::class);
33
39
$container->register(CollisionB::class);
34
40
35
41
// manually configure *one* call, to override autowiring
$this->expectDeprecation('Since symfony/dependency-injection 6.3: The "@required" annotation is deprecated, use the "Symfony\Contracts\Service\Attribute\Required" attribute instead.');
88
+
$this->expectDeprecation('Since symfony/dependency-injection 6.3: The "@required" annotation on methods is deprecated, use the "Symfony\Contracts\Service\Attribute\Required" attribute instead.');
@@ -103,13 +135,18 @@ public function testExplicitMethodInjection()
103
135
$this->assertEquals([], $methodCalls[0][1]);
104
136
}
105
137
138
+
/**
139
+
* @group legacy
140
+
*/
106
141
publicfunctiontestWitherInjection()
107<
3E14
/td>
142
{
143
+
$this->expectDeprecation('Since symfony/dependency-injection 6.3: The "@required" annotation on methods is deprecated, use the "Symfony\Contracts\Service\Attribute\Required" attribute instead.');
144
+
108
145
$container = newContainerBuilder();
109
-
$container->register(Foo::class);
146
+
$container->register(FooAnnotation::class);
110
147
111
148
$container
112
-
->register('wither', Wither::class)
149
+
->register('wither', WitherAnnotation::class)
113
150
->setAutowired(true);
114
151
115
152
(newResolveClassPass())->process($container);
@@ -125,6 +162,32 @@ public function testWitherInjection()
$this->expectDeprecation('Since symfony/dependency-injection 6.3: The "@required" annotation on methods is deprecated, use the "Symfony\Contracts\Service\Attribute\Required" attribute instead.');
class AutowireRequiredPropertiesPassTest extends TestCase
23
24
{
25
+
use ExpectDeprecationTrait;
26
+
27
+
/**
28
+
* @group legacy
29
+
*/
24
30
publicfunctiontestInjection()
25
31
{
32
+
$this->expectDeprecation('Since symfony/dependency-injection 6.3: The "@required" annotation on methods is deprecated, use the "Symfony\Contracts\Service\Attribute\Required" attribute instead. It was found on property "Symfony\Component\DependencyInjection\Definition::$plop".');
$this->expectDeprecation('Since symfony/dependency-injection 6.3: The "@required" annotation on methods is deprecated, use the "Symfony\Contracts\Service\Attribute\Required" attribute instead.');
0 commit comments