public static function readAttributes($object)
    {
        // Bail out if a non-object was passed.
        if (!is_object($object)) {
            throw self::getInvalidArgumentException(1, 'object');
        }

        $reflector = new ReflectionObject($object);
        $result    = [];

        // Iterate over the attributes of the object.
        foreach ($reflector->getProperties() as $attribute) {
            $attribute->setAccessible(true);
            $result[$attribute->getName()] = $attribute->getValue($object);
        }

        return $result;
    }
public static function readAttributes($object)
    {
        // Bail out if a non-object was passed.
        if (!is_object($object)) {
            throw self::getInvalidArgumentException(1, 'object');
        }

        $reflector = new ReflectionObject($object);
        $result    = [];

        // Iterate over the attributes of the object.
        foreach ($reflector->getProperties() as $attribute) {
            $attribute->setAccessible(true);
            $result[$attribute->getName()] = $attribute->getValue($object);
        }

        return $result;
    }
public static function readAttributes ( $ object ) { // Bail out if a non-object was passed. if ( ! is_object ( $ object ) ) { throw self :: getInvalidArgumentException ( 1 , 'object' ) ; } $ reflector = new ReflectionObject ( $ object ) ; $ result = [ ] ; // Iterate over the attributes of the object. foreach ( $ reflector -> getProperties ( ) as $ attribute ) { $ attribute -> setAccessible ( true ) ; $ result [ $ attribute -> getName ( ) ] = $ attribute -> getValue ( $ object ) ; } return $ result ; }
Returns an associative array of all attributes of an object,
including those declared as protected or private.

@param object $object The object for which all attributes are returned.

@return array

@throws InvalidArgumentException
Returns an associative array of all attributes of an object including those declared as protected or private .