/** * {@inheritdoc} */ public function parse($xmlString) { if ($this->validateResponse) { XmlChecker::isValid($xmlString); } $result = xmlrpc_decode($xmlString, 'UTF-8'); if ($result === null && self::isBiggerThanParseLimit($xmlString)) { throw ParserException::xmlrpcExtensionLibxmlParsehugeNotSupported(); } $toBeVisited = [&$result]; while (isset($toBeVisited[0]) && ($value =& $toBeVisited[0])) { $type = gettype($value); if ($type === 'object') { $xmlRpcType = $value->{'xmlrpc_type'}; if ($xmlRpcType === 'datetime') { $value = \DateTime::createFromFormat('Ymd\\TH:i:s', $value->scalar, isset($timezone) ? $timezone : ($timezone = new \DateTimeZone('UTC'))); } elseif ($xmlRpcType === 'base64') { if ($value->scalar !== '') { $value = Base64Value::serialize($value->scalar); } else { $value = null; } } } elseif ($type === 'array') { foreach ($value as &$element) { $toBeVisited[] =& $element; } } array_shift($toBeVisited); } if (is_array($result)) { reset($result); if (xmlrpc_is_fault($result)) { throw FaultException::createFromResponse($result); } } return $result; }
public function paramProvider() { return [['test_string' => [4 => str_repeat('aä', 1000000)], 'test_integer' => (int) rand(), 'test_float' => (double) rand(), 'test_datetime' => new \DateTime(), 'test_base64' => Base64Value::serialize(str_repeat('a', 100000))]]; }