@@ -733,26 +733,28 @@ public function getProperty(string $propertyName, ClassMemberAccessAnswerer $sco
733733$ key = sprintf ('%s-%s ' , $ key , $ scope ->getClassReflection ()->getCacheKey ());
734734}
735735
736- if ($ this ->phpClassReflectionExtension ->hasProperty ($ this , $ propertyName )) {
737- $ property = $ this ->phpClassReflectionExtension ->getProperty ($ this , $ propertyName , $ scope );
738- if ($ scope ->canReadProperty ($ property )) {
739- return $ this ->properties [$ key ] = $ property ;
740- }
741- $ this ->properties [$ key ] = $ property ;
742- }
743-
744- if (!isset ($ this ->properties [$ key ]) && $ this ->allowsDynamicProperties ()) {
745- foreach ($ this ->propertiesClassReflectionExtensions as $ extension ) {
746- if (!$ extension ->hasProperty ($ this , $ propertyName )) {
747- continue ;
748- }
749-
750- $ property = $ this ->wrapExtendedProperty ($ propertyName , $ extension ->getProperty ($ this , $ propertyName ));
736+ if (!isset ($ this ->properties [$ key ])) {
737+ if ($ this ->phpClassReflectionExtension ->hasProperty ($ this , $ propertyName )) {
738+ $ property = $ this ->phpClassReflectionExtension ->getProperty ($ this , $ propertyName , $ scope );
751739if ($ scope ->canReadProperty ($ property )) {
752740return $ this ->properties [$ key ] = $ property ;
753741}
754742$ this ->properties [$ key ] = $ property ;
755743}
744+
745+ if ($ this ->allowsDynamicProperties ()) {
746+ foreach ($ this ->propertiesClassReflectionExtensions as $ extension ) {
747+ if (!$ extension ->hasProperty ($ this , $ propertyName )) {
748+ continue ;
749+ }
750+
751+ $ property = $ this ->wrapExtendedProperty ($ propertyName , $ extension ->getProperty ($ this , $ propertyName ));
752+ if ($ scope ->canReadProperty ($ property )) {
753+ return $ this ->properties [$ key ] = $ property ;
754+ }
755+ $ this ->properties [$ key ] = $ property ;
756+ }
757+ }
756758}
757759
758760// For BC purpose
@@ -787,32 +789,34 @@ public function getInstanceProperty(string $propertyName, ClassMemberAccessAnswe
787789$ key = sprintf ('%s-%s ' , $ key , $ scope ->getClassReflection ()->getCacheKey ());
788790}
789791
790- if ($ this ->phpClassReflectionExtension ->hasProperty ($ this , $ propertyName )) {
791- $ property = $ this ->phpClassReflectionExtension ->getProperty ($ this , $ propertyName , $ scope );
792- if (!$ property ->isStatic ()) {
793- if ($ scope ->canReadProperty ($ property )) {
794- return $ this ->instanceProperties [$ key ] = $ property ;
792+ if (!isset ($ this ->instanceProperties [$ key ])) {
793+ if ($ this ->phpClassReflectionExtension ->hasProperty ($ this , $ propertyName )) {
794+ $ property = $ this ->phpClassReflectionExtension ->getProperty ($ this , $ propertyName , $ scope );
795+ if (!$ property ->isStatic ()) {
796+ if ($ scope ->canReadProperty ($ property )) {
797+ return $ this ->instanceProperties [$ key ] = $ property ;
798+ }
799+ $ this ->instanceProperties [$ key ] = $ property ;
795800}
796- $ this ->instanceProperties [$ key ] = $ property ;
797801}
798- }
799802
800- if (! isset ( $ this -> instanceProperties [ $ key ]) && $ this ->allowsDynamicProperties ()) {
801- foreach ($ this ->propertiesClassReflectionExtensions as $ extension ) {
802- if (!$ extension ->hasProperty ($ this , $ propertyName )) {
803- continue ;
804- }
803+ if ($ this ->allowsDynamicProperties ()) {
804+ foreach ($ this ->propertiesClassReflectionExtensions as $ extension ) {
805+ if (!$ extension ->hasProperty ($ this , $ propertyName )) {
806+ continue ;
807+ }
805808
806- $ nakedProperty = $ extension ->getProperty ($ this , $ propertyName );
807- if ($ nakedProperty ->isStatic ()) {
808- continue ;
809- }
809+ $ nakedProperty = $ extension ->getProperty ($ this , $ propertyName );
810+ if ($ nakedProperty ->isStatic ()) {
811+ continue ;
812+ }
810813
811- $ property = $ this ->wrapExtendedProperty ($ propertyName , $ nakedProperty );
812- if ($ scope ->canReadProperty ($ property )) {
813- return $ this ->instanceProperties [$ key ] = $ property ;
814+ $ property = $ this ->wrapExtendedProperty ($ propertyName , $ nakedProperty );
815+ if ($ scope ->canReadProperty ($ property )) {
816+ return $ this ->instanceProperties [$ key ] = $ property ;
817+ }
818+ $ this ->instanceProperties [$ key ] = $ property ;
814819}
815- $ this ->instanceProperties [$ key ] = $ property ;
816820}
817821}
818822
0 commit comments