src/Serialization/Json/ObjectNormalizer.php
private function extractObjectProperties($object)
    {
        $propertyToValue = [];

        if (method_exists($object, '__sleep')) {
            $properties = $object->__sleep();
            foreach ($properties as $property) {
                $propertyToValue[$property] = $object->$property;
            }

            return $propertyToValue;
        }


        $reflectedProperties = [];
        $ref = new \ReflectionClass($object);
        foreach ($ref->getProperties() as $property) {
            $property->setAccessible(true);
            $propertyToValue[$property->getName()] = $property->getValue($object);
            $reflectedProperties[] = $property->getName();
        }

        $dynamicProperties = array_diff(array_keys(get_object_vars($object)), $reflectedProperties);

        foreach ($dynamicProperties as $property) {
            $propertyToValue[$property] = $object->$property;
        }

        return $propertyToValue;
    }
private function extractObjectProperties($object)
    {
        $propertyToValue = [];

        if (method_exists($object, '__sleep')) {
            $properties = $object->__sleep();
            foreach ($properties as $property) {
                $propertyToValue[$property] = $object->$property;
            }

            return $propertyToValue;
        }


        $reflectedProperties = [];
        $ref = new \ReflectionClass($object);
        foreach ($ref->getProperties() as $property) {
            $property->setAccessible(true);
            $propertyToValue[$property->getName()] = $property->getValue($object);
            $reflectedProperties[] = $property->getName();
        }

        $dynamicProperties = array_diff(array_keys(get_object_vars($object)), $reflectedProperties);

        foreach ($dynamicProperties as $property) {
            $propertyToValue[$property] = $object->$property;
        }

        return $propertyToValue;
    }
private function extractObjectProperties ( $ object ) { $ propertyToValue = [ ] ; if ( method_exists ( $ object , '__sleep' ) ) { $ properties = $ object -> __sleep ( ) ; foreach ( $ properties as $ property ) { $ propertyToValue [ $ property ] = $ object -> $ property ; } return $ propertyToValue ; } $ reflectedProperties = [ ] ; $ ref = new \ ReflectionClass ( $ object ) ; foreach ( $ ref -> getProperties ( ) as $ property ) { $ property -> setAccessible ( true ) ; $ propertyToValue [ $ property -> getName ( ) ] = $ property -> getValue ( $ object ) ; $ reflectedProperties [ ] = $ property -> getName ( ) ; } $ dynamicProperties = array_diff ( array_keys ( get_object_vars ( $ object ) ) , $ reflectedProperties ) ; foreach ( $ dynamicProperties as $ property ) { $ propertyToValue [ $ property ] = $ object -> $ property ; } return $ propertyToValue ; }
Returns an array containing the object's properties to values

@param object $object

@return array
Returns an array containing the object s properties to values