@@ -79,10 +79,13 @@ final public function set($id, $class = null)
79
79
$ allowParent = !$ defaults ->getChanges () && empty ($ this ->instanceof );
80
80
81
81
$ definition = new Definition ();
82
- $ definition ->setPublic ($ defaults ->isPublic ());
82
+ if (!$ defaults ->isPublic () || !$ defaults ->isPrivate ()) {
83
+ $ definition ->setPublic ($ defaults ->isPublic () && !$ defaults ->isPrivate ());
84
+ }
83
85
$ definition ->setAutowired ($ defaults ->isAutowired ());
84
86
$ definition ->setAutoconfigured ($ defaults ->isAutoconfigured ());
85
- $ definition ->setBindings ($ defaults ->getBindings ());
87
+ // deep clone, to avoid multiple process of the same instance in the passes
88
+ $ definition ->setBindings (unserialize (serialize ($ defaults ->getBindings ())));
86
89
$ definition ->setChanges ([]);
87
90
88
91
$ configurator = new ServiceConfigurator ($ this ->container , $ this ->instanceof , $ allowParent , $ this , $ definition , $ id , $ defaults ->getTags ());
@@ -101,7 +104,10 @@ final public function set($id, $class = null)
101
104
final public function alias ($ id , $ referencedId )
102
105
{
103
106
$ ref = static ::processValue ($ referencedId , true );
104
- $ alias = new Alias ((string ) $ ref , $ this ->defaults ->isPublic ());
107
+ $ alias = new Alias ((string ) $ ref );
108
+ if (!$ this ->defaults ->isPublic () || !$ this ->defaults ->isPrivate ()) {
109
+ $ alias ->setPublic ($ this ->defaults ->isPublic ());
110
+ }
105
111
$ this ->container ->setAlias ($ id , $ alias );
106
112
107
113
return new AliasConfigurator ($ this , $ alias );
0 commit comments