@@ -591,15 +591,16 @@ private function addServiceConfigurator($id, Definition $definition, $variableNa
591591 */
592592 private function addService ($ id , Definition $ definition )
593593 {
594+ if ($ definition ->isSynthetic ()) {
595+ return '' ;
596+ }
594597 $ this ->definitionVariables = new \SplObjectStorage ();
595598 $ this ->referenceVariables = array ();
596599 $ this ->variableCount = 0 ;
597600
598601 $ return = array ();
599602
600- if ($ definition ->isSynthetic ()) {
601- $ return [] = '@throws RuntimeException always since this service is expected to be injected dynamically ' ;
602- } elseif ($ class = $ definition ->getClass ()) {
603+ if ($ class = $ definition ->getClass ()) {
603604 $ class = $ this ->container ->resolveEnvPlaceholders ($ class );
604605 $ return [] = sprintf ('@return %s A %s instance ' , 0 === strpos ($ class , '% ' ) ? 'object ' : '\\' .ltrim ($ class , '\\' ), ltrim ($ class , '\\' ));
605606 } elseif ($ definition ->getFactory ()) {
@@ -680,26 +681,22 @@ private function addService($id, Definition $definition)
680681
681682 $ code .= $ isProxyCandidate ? $ this ->getProxyDumper ()->getProxyFactoryCode ($ definition , $ id , $ methodName ) : '' ;
682683
683- if ($ definition ->isSynthetic ()) {
684- $ code .= sprintf (" throw new RuntimeException('You have requested a synthetic service ( \"%s \"). The DIC does not know how to construct this service.'); \n } \n" , $ id );
685- } else {
686- if ($ definition ->isDeprecated ()) {
687- $ code .= sprintf (" @trigger_error(%s, E_USER_DEPRECATED); \n\n" , $ this ->export ($ definition ->getDeprecationMessage ($ id )));
688- }
689-
690- $ code .=
691- $ this ->addServiceInclude ($ id , $ definition ).
692- $ this ->addServiceLocalTempVariables ($ id , $ definition ).
693- $ this ->addServiceInlinedDefinitions ($ id , $ definition ).
694- $ this ->addServiceInstance ($ id , $ definition ).
695- $ this ->addServiceInlinedDefinitionsSetup ($ id , $ definition ).
696- $ this ->addServiceProperties ($ id , $ definition ).
697- $ this ->addServiceMethodCalls ($ id , $ definition ).
698- $ this ->addServiceConfigurator ($ id , $ definition ).
699- $ this ->addServiceReturn ($ id , $ definition )
700- ;
684+ if ($ definition ->isDeprecated ()) {
685+ $ code .= sprintf (" @trigger_error(%s, E_USER_DEPRECATED); \n\n" , $ this ->export ($ definition ->getDeprecationMessage ($ id )));
701686 }
702687
688+ $ code .=
689+ $ this ->addServiceInclude ($ id , $ definition ).
690+ $ this ->addServiceLocalTempVariables ($ id , $ definition ).
691+ $ this ->addServiceInlinedDefinitions ($ id , $ definition ).
692+ $ this ->addServiceInstance ($ id , $ definition ).
693+ $ this ->addServiceInlinedDefinitionsSetup ($ id , $ definition ).
694+ $ this ->addServiceProperties ($ id , $ definition ).
695+ $ this ->addServiceMethodCalls ($ id , $ definition ).
696+ $ this ->addServiceConfigurator ($ id , $ definition ).
697+ $ this ->addServiceReturn ($ id , $ definition )
698+ ;
699+
703700 $ this ->definitionVariables = null ;
704701 $ this ->referenceVariables = null ;
705702
@@ -950,7 +947,8 @@ private function addNormalizedIds()
950947 */
951948 private function addMethodMap ()
952949 {
953- if (!$ definitions = $ this ->container ->getDefinitions ()) {
950+ $ definitions = $ this ->container ->getDefinitions ();
951+ if (!$ definitions || !$ definitions = array_filter ($ definitions , function ($ def ) { return !$ def ->isSynthetic (); })) {
954952 return '' ;
955953 }
956954
0 commit comments