8000 add legacy test and class for ScalarSetter with annotation · symfony/symfony@06ad958 · GitHub
[go: up one dir, main page]

Skip to content

Commit 06ad958

Browse files
add legacy test and class for ScalarSetter with annotation
1 parent 5ae88bb commit 06ad958

File tree

2 files changed

+23
-2
lines changed

2 files changed

+23
-2
lines changed

src/Symfony/Component/DependencyInjection/Tests/Compiler/ResolveBindingsPassTest.php

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,12 +149,25 @@ public function testTypedReferenceSupport()
149149
/**
150150
* @group legacy
151151
*/
152-
public function testScalarSetter()
152+
public function testScalarSetterAnnotation()
153153
{
154154
$this->expectDeprecation('Since symfony/dependency-injection 6.3: The "@required" annotation on methods is deprecated, use the "Symfony\Contracts\Service\Attribute\Required" attribute instead.');
155155

156156
$container = new ContainerBuilder();
157157

158+
$definition = $container->autowire('foo' 8000 ;, ScalarSetterAnnotation::class);
159+
$definition->setBindings(['$defaultLocale' => 'fr']);
160+
161+
(new AutowireRequiredMethodsPass())->process($container);
162+
(new ResolveBindingsPass())->process($container);
163+
164+
$this->assertEquals([['setDefaultLocale', ['fr']]], $definition->getMethodCalls());
165+
}
166+
167+
public function testScalarSetterAttribute()
168+
{
169+
$container = new ContainerBuilder();
170+
158171
$definition = $container->autowire('foo', ScalarSetter::class);
159172
$definition->setBindings(['$defaultLocale' => 'fr']);
160173

src/Symfony/Component/DependencyInjection/Tests/Fixtures/includes/autowiring_classes.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -460,7 +460,7 @@ private function __construct()
460460
}
461461

462462
// @deprecated since Symfony 6.3, to be removed in 7.0
463-
class ScalarSetter
463+
class ScalarSetterAnnotation
464464
{
465465
/**
466466
* @required
@@ -470,6 +470,14 @@ public function setDefaultLocale($defaultLocale)
470470
}
471471
}
472472

473+
class ScalarSetter
474+
{
475+
#[Required]
476+
public function setDefaultLocale($defaultLocale)
477+
{
478< 5BE2 /code>+
}
479+
}
480+
473481
interface DecoratorInterface
474482
{
475483
}

0 commit comments

Comments
 (0)
0