@@ -83,13 +83,14 @@ final public function set(?string $id, string $class = null): ServiceConfigurato
83
83
84
84
$ id = sprintf ('.%d_%s ' , ++$ this ->anonymousCount , preg_replace ('/^.* \\\\/ ' , '' , $ class ).'~ ' .$ this ->anonymousHash );
85
85
$ definition ->setPublic (false );
86
- } else {
87
- $ definition ->setPublic ($ defaults ->isPublic ());
86
+ } elseif (! $ defaults -> isPublic () || ! $ defaults -> isPrivate ()) {
87
+ $ definition ->setPublic ($ defaults ->isPublic () && ! $ defaults -> isPrivate () );
88
88
}
89
89
90
90
$ definition ->setAutowired ($ defaults ->isAutowired ());
91
91
$ definition ->setAutoconfigured ($ defaults ->isAutoconfigured ());
92
- $ definition ->setBindings ($ defaults ->getBindings ());
92
+ // deep clone, to avoid multiple process of the same instance in the passes
93
+ $ definition ->setBindings (unserialize (serialize ($ defaults ->getBindings ())));
93
94
$ definition ->setChanges ([]);
94
95
95
96
$ configurator = new ServiceConfigurator ($ this ->container , $ this ->instanceof , $ allowParent , $ this , $ definition , $ id , $ defaults ->getTags (), $ this ->path );
@@ -103,7 +104,10 @@ final public function set(?string $id, string $class = null): ServiceConfigurato
103
104
final public function alias (string $ id , string $ referencedId ): AliasConfigurator
104
105
{
105
106
$ ref = static ::processValue ($ referencedId , true );
106
- $ 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
+ }
107
111
$ this ->container ->setAlias ($ id , $ alias );
108
112
109
113
return new AliasConfigurator ($ this , $ alias );
0 commit comments