24
24
use Symfony \Component \DependencyInjection \Reference ;
25
25
use Symfony \Component \DependencyInjection \ServiceLocator ;
26
26
use Symfony \Component \DependencyInjection \Tests \Fixtures \CustomDefinition ;
27
- use Symfony \Component \DependencyInjection \Tests \Fixtures \LegacyTestServiceSubscriberChild ;
28
- use Symfony \Component \DependencyInjection \Tests \Fixtures \LegacyTestServiceSubscriberParent ;
29
27
use Symfony \Component \DependencyInjection \Tests \Fixtures \TestDefinition1 ;
30
28
use Symfony \Component \DependencyInjection \Tests \Fixtures \TestDefinition2 ;
31
29
use Symfony \Component \DependencyInjection \Tests \Fixtures \TestDefinition3 ;
@@ -146,67 +144,6 @@ public function testExtraServiceSubscriber()
146
144
$ container ->compile ();
147
145
}
148
146
149
- /**
150
- * @group legacy
151
- */
152
- public function testServiceSubscriberTrait ()
153
- {
154
- $ container = new ContainerBuilder ();
155
-
156
- $ container ->register ('foo ' , LegacyTestServiceSubscriberChild::class)
157
- ->addMethodCall ('setContainer ' , [new Reference (PsrContainerInterface::class)])
158
- ->addTag ('container.service_subscriber ' )
159
- ;
160
-
161
- (new RegisterServiceSubscribersPass ())->process ($ container );
162
- (new ResolveServiceSubscribersPass ())->process ($ container );
163
-
164
- $ foo = $ container ->getDefinition ('foo ' );
165
- $ locator = $ container ->getDefinition ((string ) $ foo ->getMethodCalls ()[0 ][1 ][0 ]);
166
-
167
- $ expected = [
168
- LegacyTestServiceSubscriberChild::class.'::invalidDefinition ' => new ServiceClosureArgument (new TypedReference ('Symfony\Component\DependencyInjection\Tests\Fixtures\InvalidDefinition ' , 'Symfony\Component\DependencyInjection\Tests\Fixtures\InvalidDefinition ' , ContainerInterface::IGNORE_ON_INVALID_REFERENCE )),
169
- LegacyTestServiceSubscriberChild::class.'::testDefinition2 ' => new ServiceClosureArgument (new TypedReference (TestDefinition2::class, TestDefinition2::class, ContainerInterface::IGNORE_ON_INVALID_REFERENCE )),
170
- LegacyTestServiceSubscriberChild::class.'::testDefinition3 ' => new ServiceClosureArgument (new TypedReference (TestDefinition3::class, TestDefinition3::class, ContainerInterface::IGNORE_ON_INVALID_REFERENCE )),
171
- LegacyTestServiceSubscriberParent::class.'::testDefinition1 ' => new ServiceClosureArgument (new TypedReference (TestDefinition1::class, TestDefinition1::class, ContainerInterface::IGNORE_ON_INVALID_REFERENCE )),
172
- ];
173
-
174
- $ this ->assertEquals ($ expected , $ container ->getDefinition ((string ) $ locator ->getFactory ()[0 ])->getArgument (0 ));
175
- }
176
-
177
- /**
178
- * @group legacy
179
- */
180
- public function testServiceSubscriberTraitWithGetter ()
181
- {
182
- $ container = new ContainerBuilder ();
183
-
184
- $ subscriber = new class () implements ServiceSubscriberInterface {
185
- use ServiceSubscriberTrait;
186
-
187
- public function getFoo (): \stdClass
188
- {
189
- }
190
- };
191
- $ container ->register ('foo ' , \get_class ($ subscriber ))
192
- ->addMethodCall ('setContainer ' , [new Reference (PsrContainerInterface::class)])
193
- ->addTag ('container.service_subscriber ' );
194
-
195
- (new RegisterServiceSubscribersPass ())->process ($ container );
196
- (new ResolveServiceSubscribersPass ())->process ($ container );
197
-
198
- $ foo = $ container ->getDefinition ('foo ' );
199
- $ locator = $ container ->getDefinition ((string ) $ foo ->getMethodCalls ()[0 ][1 ][0 ]);
200
-
201
- $ expected = [
202
- \get_class ($ subscriber ).'::getFoo ' => new ServiceClosureArgument (new TypedReference ('stdClass ' , 'stdClass ' , ContainerInterface::IGNORE_ON_INVALID_REFERENCE , 'foo ' )),
203
- ];
204
- $ this ->assertEquals ($ expected , $ container ->getDefinition ((string ) $ locator ->getFactory ()[0 ])->getArgument (0 ));
205
- }
206
-
207
- /**
208
- * @requires PHP 8
209
- */
210
147
public function testServiceSubscriberTraitWithSubscribedServiceAttribute ()
211
148
{
212
149
if (!class_exists (SubscribedService::class)) {
@@ -237,9 +174,6 @@ public function testServiceSubscriberTraitWithSubscribedServiceAttribute()
237
174
$ this ->assertEquals ($ expected , $ container ->getDefinition ((string ) $ locator ->getFactory ()[0 ])->getArgument (0 ));
238
175
}
239
176
240
- /**
241
- * @requires PHP 8
242
- */
243
177
public function testServiceSubscriberTraitWithSubscribedServiceAttributeOnStaticMethod ()
244
178
{
245
179
if (!class_exists (SubscribedService::class)) {
@@ -260,9 +194,6 @@ public static function method(): TestDefinition1
260
194
$ subscriber ::getSubscribedServices ();
261
195
}
262
196
263
- /**
264
- * @requires PHP 8
265
- */
266
197
public function testServiceSubscriberTraitWithSubscribedServiceAttributeOnMethodWithRequiredParameters ()
267
198
{
268
199
if (!class_exists (SubscribedService::class)) {
@@ -283,9 +214,6 @@ public function method($param1, $param2 = null): TestDefinition1
283
214
$ subscriber ::getSubscribedServices ();
284
215
}
285
216
286
- /**
287
- * @requires PHP 8
288
- */
289
217
public function testServiceSubscriberTraitWithSubscribedServiceAttributeOnMethodMissingReturnType ()
290
218
{
291
219
if (!class_exists (SubscribedService::class)) {
0 commit comments