/**
  * {@inheritdoc}
  */
 public function serialize($method, array $params = [])
 {
     $toBeVisited = [&$params];
     while (isset($toBeVisited[0]) && ($value =& $toBeVisited[0])) {
         $type = gettype($value);
         if ($type === 'array') {
             // Zend converts non-zero-indexed arrays to structs
             if (array_keys($value) !== range(0, count($value) - 1) && array_keys($value) == range(1, count($value))) {
                 $value = array_values($value);
             }
             foreach ($value as &$child) {
                 $toBeVisited[] =& $child;
             }
         } elseif ($type === 'object') {
             if ($value instanceof \DateTime) {
                 $value = AbstractValue::getXmlRpcValue($value->format('Ymd\\TH:i:s'), AbstractValue::XMLRPC_TYPE_DATETIME);
             } elseif ($value instanceof Base64) {
                 $value = AbstractValue::getXmlRpcValue($value->getDecoded(), AbstractValue::XMLRPC_TYPE_BASE64);
             } else {
                 $value = get_object_vars($value);
             }
         } elseif ($type === 'resource') {
             throw new InvalidTypeException($value);
         }
         array_shift($toBeVisited);
     }
     $request = new Request($method, $params);
     try {
         return $request->saveXml();
     } catch (\Exception $e) {
         throw new SerializerException($e->getMessage(), $e->getCode(), $e);
     }
 }
Example #2
0
 /**
  * testSaveXML() test
  */
 public function testSaveXML()
 {
     $argv = array('string', true);
     $this->_request->setMethod('do.Something');
     $this->_request->setParams($argv);
     $xml = $this->_request->saveXml();
     $this->_testXmlRequest($xml, $argv);
 }