src/Utilities/Reflection.php
private static function getPropertyValueByReflectionProperty(
        $object,
        string $property,
        ?\ReflectionProperty $reflectionProperty = null
    ) {
        $value = null;
        $valueFound = false;
        $className = self::getClassName($object);

        try {
            if (null === $reflectionProperty) {
                $reflectionProperty = new \ReflectionProperty($className, $property);
            }

            $value = $reflectionProperty->getValue($object);
            $valueFound = true;
        } catch (\ReflectionException $exception) {
        }

        if (null !== $reflectionProperty) {
            $reflectionProperty->setAccessible(true);

            $value = $reflectionProperty->getValue($object);
            $valueFound = true;

            $reflectionProperty->setAccessible(false);
        }

        return [
            $value,
            $valueFound,
        ];
    }
private static function getPropertyValueByReflectionProperty(
        $object,
        string $property,
        ?\ReflectionProperty $reflectionProperty = null
    ) {
        $value = null;
        $valueFound = false;
        $className = self::getClassName($object);

        try {
            if (null === $reflectionProperty) {
                $reflectionProperty = new \ReflectionProperty($className, $property);
            }

            $value = $reflectionProperty->getValue($object);
            $valueFound = true;
        } catch (\ReflectionException $exception) {
        }

        if (null !== $reflectionProperty) {
            $reflectionProperty->setAccessible(true);

            $value = $reflectionProperty->getValue($object);
            $valueFound = true;

            $reflectionProperty->setAccessible(false);
        }

        return [
            $value,
            $valueFound,
        ];
    }
private static function getPropertyValueByReflectionProperty ( $ object , string $ property , ? \ ReflectionProperty $ reflectionProperty = null ) { $ value = null ; $ valueFound = false ; $ className = self :: getClassName ( $ object ) ; try { if ( null === $ reflectionProperty ) { $ reflectionProperty = new \ ReflectionProperty ( $ className , $ property ) ; } $ value = $ reflectionProperty -> getValue ( $ object ) ; $ valueFound = true ; } catch ( \ ReflectionException $ exception ) { } if ( null !== $ reflectionProperty ) { $ reflectionProperty -> setAccessible ( true ) ; $ value = $ reflectionProperty -> getValue ( $ object ) ; $ valueFound = true ; $ reflectionProperty -> setAccessible ( false ) ; } return [ $ value , $ valueFound , ] ; }
Returns value of given property using the property represented by reflection.
If value cannot be fetched, makes the property accessible temporarily.

@param mixed                    $object             Object that should contains given property
@param string                   $property           Name of the property that contains a value
@param null|\ReflectionProperty $reflectionProperty (optional) Property represented by reflection
@return mixed
Returns value of given property using the property represented by reflection . If value cannot be fetched makes the property accessible temporarily .