read()) { $tag = strtolower($xml->name); switch ($tag) { case 'methodname': case 'value': if ($xml->nodeType === XMLReader::ELEMENT) { $expect = $tag; } else { $expect = null; } break; case '#text': if ($xml->hasValue) { switch ($expect) { case 'methodname': $method_name = $xml->value; break; case 'value': $params[] = $xml->value; break; } } break; default: // nothing } } $errors = libxml_get_errors(); libxml_use_internal_errors($errorflag); if (! empty($errors)) { throw new \RuntimeException( 'errors while parsing XML', $errors[0]->code ); } if (! empty($method_name)) { return new XmlRpcMethod($method_name, $params); } return null; } /** * Constructs a new XmlRpcMethod object from the method name and params. * * @param string $name The method name * @param array $params An array or params for the method call. */ public function __construct(public string $name, public array $params) { } }