src/Helper/SerializationHelper.php
public static function getProperties($obj)
    {
        $properties = array();
        try {
            $rc = new ReflectionClass($obj);
            do {
                $rp = array();

                // Note that we will not include any properties in traits
                $traits = $rc->getTraits();
                $skipProperties = array();
                if (!empty($traits)) {
                    foreach ($traits as $trait) {
                        foreach ($trait->getProperties() as $traitProperty) {
                            $skipProperties[] = $traitProperty->getName();
                        }
                    }
                }
                /* @var $p \ReflectionProperty */
                foreach ($rc->getProperties() as $p) {
                    if (in_array($p->getName(), $skipProperties, true)) {
                        continue;
                    }
                    $p->setAccessible(true);
                    $rp[$p->getName()] = $p->getValue($obj);
                }
                $properties = array_merge($rp, $properties);
            } while ($rc = $rc->getParentClass());
        } catch (ReflectionException $e) {
            //
        }
        return $properties;
    }
public static function getProperties($obj)
    {
        $properties = array();
        try {
            $rc = new ReflectionClass($obj);
            do {
                $rp = array();

                // Note that we will not include any properties in traits
                $traits = $rc->getTraits();
                $skipProperties = array();
                if (!empty($traits)) {
                    foreach ($traits as $trait) {
                        foreach ($trait->getProperties() as $traitProperty) {
                            $skipProperties[] = $traitProperty->getName();
                        }
                    }
                }
                /* @var $p \ReflectionProperty */
                foreach ($rc->getProperties() as $p) {
                    if (in_array($p->getName(), $skipProperties, true)) {
                        continue;
                    }
                    $p->setAccessible(true);
                    $rp[$p->getName()] = $p->getValue($obj);
                }
                $properties = array_merge($rp, $properties);
            } while ($rc = $rc->getParentClass());
        } catch (ReflectionException $e) {
            //
        }
        return $properties;
    }
public static function getProperties ( $ obj ) { $ properties = array ( ) ; try { $ rc = new ReflectionClass ( $ obj ) ; do { $ rp = array ( ) ; // Note that we will not include any properties in traits $ traits = $ rc -> getTraits ( ) ; $ skipProperties = array ( ) ; if ( ! empty ( $ traits ) ) { foreach ( $ traits as $ trait ) { foreach ( $ trait -> getProperties ( ) as $ traitProperty ) { $ skipProperties [ ] = $ traitProperty -> getName ( ) ; } } } /* @var $p \ReflectionProperty */ foreach ( $ rc -> getProperties ( ) as $ p ) { if ( in_array ( $ p -> getName ( ) , $ skipProperties , true ) ) { continue ; } $ p -> setAccessible ( true ) ; $ rp [ $ p -> getName ( ) ] = $ p -> getValue ( $ obj ) ; } $ properties = array_merge ( $ rp , $ properties ) ; } while ( $ rc = $ rc -> getParentClass ( ) ) ; } catch ( ReflectionException $ e ) { // } return $ properties ; }
Recursively lists all the properties of the given class by traversing up the class hierarchy

@param $obj object the object whose properties to list
@return array the array of the keys and properties of the object
Recursively lists all the properties of the given class by traversing up the class hierarchy