lib/Doctrine/ODM/CouchDB/Proxy/ProxyFactory.php
private function generateSleep(ClassMetadata $class)
    {
        $sleepImpl = '';

        if ($class->reflClass->hasMethod('__sleep')) {
            $sleepImpl .= "return array_merge(array('__isInitialized__'), parent::__sleep());";
        } else {
            $sleepImpl .= "return array('__isInitialized__', ";

            $properties = array();
            foreach ($class->fieldMappings as $name => $prop) {
                $properties[] = "'$name'";
            }

            $sleepImpl .= implode(',', $properties) . ');';
        }

        return $sleepImpl;
    }
private function generateSleep(ClassMetadata $class)
    {
        $sleepImpl = '';

        if ($class->reflClass->hasMethod('__sleep')) {
            $sleepImpl .= "return array_merge(array('__isInitialized__'), parent::__sleep());";
        } else {
            $sleepImpl .= "return array('__isInitialized__', ";

            $properties = array();
            foreach ($class->fieldMappings as $name => $prop) {
                $properties[] = "'$name'";
            }

            $sleepImpl .= implode(',', $properties) . ');';
        }

        return $sleepImpl;
    }
Generates the code for the __sleep method for a proxy class.

@param $class
@return string