public static function getProperty($subject, $propertyName, bool $forceDirectAccess = false)
    {
        if (!is_object($subject) && !is_array($subject)) {
            throw new \InvalidArgumentException('$subject must be an object or array, ' . gettype($subject) . ' given.', 1237301367);
        }
        if (!is_string($propertyName) && !is_int($propertyName)) {
            throw new \InvalidArgumentException('Given property name/index is not of type string or integer.', 1231178303);
        }

        $propertyExists = false;
        $propertyValue = self::getPropertyInternal($subject, $propertyName, $forceDirectAccess, $propertyExists);
        if ($propertyExists === true) {
            return $propertyValue;
        }
        throw new PropertyNotAccessibleException('The property "' . $propertyName . '" on the subject was not accessible.', 1263391473);
    }
public static function getProperty($subject, $propertyName, bool $forceDirectAccess = false)
    {
        if (!is_object($subject) && !is_array($subject)) {
            throw new \InvalidArgumentException('$subject must be an object or array, ' . gettype($subject) . ' given.', 1237301367);
        }
        if (!is_string($propertyName) && !is_int($propertyName)) {
            throw new \InvalidArgumentException('Given property name/index is not of type string or integer.', 1231178303);
        }

        $propertyExists = false;
        $propertyValue = self::getPropertyInternal($subject, $propertyName, $forceDirectAccess, $propertyExists);
        if ($propertyExists === true) {
            return $propertyValue;
        }
        throw new PropertyNotAccessibleException('The property "' . $propertyName . '" on the subject was not accessible.', 1263391473);
    }
public static function getProperty ( $ subject , $ propertyName , bool $ forceDirectAccess = false ) { if ( ! is_object ( $ subject ) && ! is_array ( $ subject ) ) { throw new \ InvalidArgumentException ( '$subject must be an object or array, ' . gettype ( $ subject ) . ' given.' , 1237301367 ) ; } if ( ! is_string ( $ propertyName ) && ! is_int ( $ propertyName ) ) { throw new \ InvalidArgumentException ( 'Given property name/index is not of type string or integer.' , 1231178303 ) ; } $ propertyExists = false ; $ propertyValue = self :: getPropertyInternal ( $ subject , $ propertyName , $ forceDirectAccess , $ propertyExists ) ; if ( $ propertyExists === true ) { return $ propertyValue ; } throw new PropertyNotAccessibleException ( 'The property "' . $ propertyName . '" on the subject was not accessible.' , 1263391473 ) ; }
Get a property of a given object or array.

Tries to get the property the following ways:

- if the target is an array, and has this property, we return it.
- if super cow powers should be used, fetch value through reflection
- if public getter method exists, call it.
- if the target object is an instance of ArrayAccess, it gets the property
on it if it exists.
- if public property exists, return the value of it.
- else, throw exception

@param mixed $subject Object or array to get the property from
@param string|integer $propertyName Name or index of the property to retrieve
@param boolean $forceDirectAccess Directly access property using reflection(!)
@return mixed Value of the property
@throws \InvalidArgumentException in case $subject was not an object or $propertyName was not a string
@throws PropertyNotAccessibleException if the property was not accessible
Get a property of a given object or array .