File tree Expand file tree Collapse file tree 1 file changed +11
-18
lines changed Expand file tree Collapse file tree 1 file changed +11
-18
lines changed Original file line number Diff line number Diff line change @@ -2351,30 +2351,23 @@ public static function getObjectAttribute($object, string $attributeName)
23512351 }
23522352
23532353 try {
2354- $ attribute = new ReflectionProperty ($ object , $ attributeName );
2355- } catch (ReflectionException $ e ) {
23562354 $ reflector = new ReflectionObject ($ object );
2357-
2358- while ($ reflector = $ reflector ->getParentClass ()) {
2355+ do {
23592356 try {
23602357 $ attribute = $ reflector ->getProperty ($ attributeName );
2358+ if (!$ attribute || $ attribute ->isPublic ()) {
2359+ return $ object ->$ attributeName ;
2360+ }
2361+
2362+ $ attribute ->setAccessible (true );
2363+ $ value = $ attribute ->getValue ($ object );
2364+ $ attribute ->setAccessible (false );
23612365
2362- break ;
2366+ return $ value ;
23632367 } catch (ReflectionException $ e ) {
23642368 }
2365- }
2366- }
2367-
2368- if (isset ($ attribute )) {
2369- if (!$ attribute || $ attribute ->isPublic ()) {
2370- return $ object ->$ attributeName ;
2371- }
2372-
2373- $ attribute ->setAccessible (true );
2374- $ value = $ attribute ->getValue ($ object );
2375- $ attribute ->setAccessible (false );
2376-
2377- return $ value ;
2369+ } while ($ reflector = $ reflector ->getParentClass ());
2370+ } catch (ReflectionException $ e ) {
23782371 }
23792372
23802373 throw new Exception (
You can’t perform that action at this time.
0 commit comments