private function mergeObject($destinationObject, $sourceObject)
    {
        $reflectedDestination  = new \ReflectionObject($destinationObject);
        $reflectedSource       = new \ReflectionObject($sourceObject);
        $defaultPropertyValues = $reflectedDestination->getDefaultProperties();

        foreach ($reflectedSource->getProperties() as $sourceProperty) {
            $destinationObject = $this->mergeProperty(
                $destinationObject,
                $reflectedDestination->getProperty($sourceProperty->getName()),
                $sourceObject,
                $sourceProperty,
                $defaultPropertyValues
            );
        }

        return $destinationObject;
    }
private function mergeObject($destinationObject, $sourceObject)
    {
        $reflectedDestination  = new \ReflectionObject($destinationObject);
        $reflectedSource       = new \ReflectionObject($sourceObject);
        $defaultPropertyValues = $reflectedDestination->getDefaultProperties();

        foreach ($reflectedSource->getProperties() as $sourceProperty) {
            $destinationObject = $this->mergeProperty(
                $destinationObject,
                $reflectedDestination->getProperty($sourceProperty->getName()),
                $sourceObject,
                $sourceProperty,
                $defaultPropertyValues
            );
        }

        return $destinationObject;
    }
private function mergeObject ( $ destinationObject , $ sourceObject ) { $ reflectedDestination = new \ ReflectionObject ( $ destinationObject ) ; $ reflectedSource = new \ ReflectionObject ( $ sourceObject ) ; $ defaultPropertyValues = $ reflectedDestination -> getDefaultProperties ( ) ; foreach ( $ reflectedSource -> getProperties ( ) as $ sourceProperty ) { $ destinationObject = $ this -> mergeProperty ( $ destinationObject , $ reflectedDestination -> getProperty ( $ sourceProperty -> getName ( ) ) , $ sourceObject , $ sourceProperty , $ defaultPropertyValues ) ; } return $ destinationObject ; }
Deep-merge the source object over the destination object and return the results.

@param object $destinationObject
@param object $sourceObject

@return object
Deep - merge the source object over the destination object and return the results .