@@ -298,6 +298,25 @@ public function completeStatement(Statement $statement): Statement
298298 $ arguments = $ statement ->arguments ;
299299 $ definitions = $ this ->builder ->getDefinitions ();
300300
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+
301320 if (is_string ($ entity ) && Strings::contains ($ entity , '? ' )) { // PHP literal
302321
303322 } elseif ($ entity instanceof Reference) { // factory calling
@@ -371,20 +390,6 @@ public function completeStatement(Statement $statement): Statement
371390
372391 } elseif ($ val instanceof Reference) {
373392 $ 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 );
388393 }
389394 });
390395
0 commit comments