Created
March 30, 2023 06:47
-
-
Save mauriciogofas/93c9c140c8235e29f1f976f5760585c6 to your computer and use it in GitHub Desktop.
#php get protected property in objetc array
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if(!function_exists('gib_get_protected_property')){ | |
function gib_get_protected_property($object, $property){ | |
$reflectedClass = new \ReflectionClass($object); | |
$reflection = $reflectedClass->getProperty($property); | |
$reflection->setAccessible(true); | |
return $reflection->getValue($object); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment