@@ -298,6 +298,25 @@ public function completeStatement(Statement $statement): Statement
298
298
$ arguments = $ statement ->arguments ;
299
299
$ definitions = $ this ->builder ->getDefinitions ();
300
300
301
+ // @reference -> object
302
+ array_walk_recursive ($ arguments , function (&$ val ): void {
303
+ if (is_string ($ val ) && strlen ($ val ) > 1 && $ val [0 ] === '@ ' && $ val [1 ] !== '@ ' ) {
304
+ $ pair = explode (':: ' , substr ($ val , 1 ), 2 );
305
+ if (!isset ($ pair [1 ])) { // @service
306
+ $ val = new Reference ($ pair [0 ]);
307
+ } elseif (preg_match ('#^[A-Z][A-Z0-9_]*\z# ' , $ pair [1 ], $ m )) { // @service::CONSTANT
308
+ $ ref = $ this ->resolveServiceReference (new Reference ($ pair [0 ]));
309
+ $ val = ContainerBuilder::literal ($ this ->builder ->getDefinition ($ ref ->getName ())->getType () . ':: ' . $ pair [1 ]);
310
+ } else { // @service::property
311
+ $ val = new Statement ([new Reference ($ pair [0 ]), '$ ' . $ pair [1 ]]);
312
+ }
313
+
314
+ } elseif (is_string ($ val ) && substr ($ val , 0 , 2 ) === '@@ ' ) { // escaped text @@
315
+ $ val = substr ($ val , 1 );
316
+ }
317
+ });
318
+
319
+
301
320
if (is_string ($ entity ) && Strings::contains ($ entity , '? ' )) { // PHP literal
302
321
303
322
} elseif ($ entity instanceof Reference) { // factory calling
@@ -371,20 +390,6 @@ public function completeStatement(Statement $statement): Statement
371
390
372
391
} elseif ($ val instanceof Reference) {
373
392
$ val = $ this ->resolveServiceReference ($ val );
374
-
375
- } elseif (is_string ($ val ) && strlen ($ val ) > 1 && $ val [0 ] === '@ ' && $ val [1 ] !== '@ ' ) {
376
- $ pair = explode (':: ' , $ val , 2 );
377
- $ serviceRef = $ this ->resolveServiceReference ($ pair [0 ]);
378
- if (!isset ($ pair [1 ])) { // @service
379
- $ val = $ serviceRef ;
380
- } elseif (preg_match ('#^[A-Z][A-Z0-9_]*\z# ' , $ pair [1 ], $ m )) { // @service::CONSTANT
381
- $ val = ContainerBuilder::literal ($ this ->builder ->getDefinition ($ serviceRef ->getName ())->getType () . ':: ' . $ pair [1 ]);
382
- } else { // @service::property
383
- $ val = new Statement ([$ serviceRef , '$ ' . $ pair [1 ]]);
384
- }
385
-
386
- } elseif (is_string ($ val ) && substr ($ val , 0 , 2 ) === '@@ ' ) { // escaped text @@
387
- $ val = substr ($ val , 1 );
388
393
}
389
394
});
390
395
0 commit comments