@@ -890,13 +890,14 @@ private function newBean(string $beanName, string $id = '')
890890
891891 // Get object definition
892892 $ objectDefinition = $ this ->getNewObjectDefinition ($ beanName );
893+ $ propertyInjects = $ objectDefinition ->getPropertyInjections ();
893894
894- $ scope = $ objectDefinition ->getScope ();
895- $ alias = $ objectDefinition ->getAlias ();
896- $ className = $ objectDefinition ->getClassName ();
895+ $ scope = $ objectDefinition ->getScope ();
896+ $ alias = $ objectDefinition ->getAlias ();
897897
898898 // Cache reflection class info
899- Reflections::cache ($ className );
899+ $ className = $ objectDefinition ->getClassName ();
900+ $ reflectClass = Reflections::cache ($ className );
900901
901902 // Before initialize bean
902903 $ this ->beforeInit ($ beanName , $ className , $ objectDefinition );
@@ -907,18 +908,21 @@ private function newBean(string $beanName, string $id = '')
907908 $ constructArgs = $ this ->getConstructParams ($ constructInject , $ id );
908909 }
909910
910- $ propertyInjects = $ objectDefinition ->getPropertyInjections ();
911-
912- // Proxy class
911+ // It's proxy class. eg: AOP, RPC client class
913912 if ($ this ->handler ) {
913+ $ oldCName = $ className ;
914914 $ className = $ this ->handler ->classProxy ($ className );
915+
916+ // New class name from handler->classProxy()
917+ if ($ oldCName !== $ className ) {
918+ $ reflectClass = new ReflectionClass ($ className );
919+ }
915920 }
916921
917- $ reflectionClass = new ReflectionClass ($ className );
918- $ reflectObject = $ this ->newInstance ($ reflectionClass , $ constructArgs );
922+ $ reflectObject = $ this ->newInstance ($ reflectClass , $ constructArgs );
919923
920924 // Inject properties values
921- $ this ->newProperty ($ reflectObject , $ reflectionClass , $ propertyInjects , $ id );
925+ $ this ->newProperty ($ reflectObject , $ reflectClass , $ propertyInjects , $ id );
922926
923927 // Alias name
924928 // Fix: $aliasId !== $id for deny loop get
@@ -927,7 +931,7 @@ private function newBean(string $beanName, string $id = '')
927931 }
928932
929933 // Call init method if exist
930- if ($ reflectionClass ->hasMethod (self ::INIT_METHOD )) {
934+ if ($ reflectClass ->hasMethod (self ::INIT_METHOD )) {
931935 $ reflectObject ->{self ::INIT_METHOD }();
932936 }
933937
@@ -1147,7 +1151,7 @@ private function getRefValue($value, string $id = '')
11471151 $ value = substr ($ value , 1 );
11481152
11491153 // Other: read config reference
1150- if ($ this ->handler !== null ) {
1154+ if ($ this ->handler ) {
11511155 $ value = $ this ->handler ->getReferenceValue ($ value );
11521156 }
11531157
0 commit comments