code: 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;
      }
docs: Generates the code for the __sleep method for a proxy class.
  
  @param $class
  @return string