12 namespace fpoirotte\XRL;
64 $server->expose($wrapper,
'system');
84 $doc = trim(substr($doc, 3, -2),
" \t\r\n*");
85 $doc = str_replace(array(
"\r\n",
"\r"),
"\n", $doc);
86 $lines = explode(
"\n", $doc .
"\n");
95 foreach ($lines as $line) {
96 $line = trim($line,
" \r\n\t*");
98 if ($tag !== null && $line ===
'') {
101 $type = (string) substr($buffer, 0, strcspn($buffer,
" \r\n\t"));
102 $buffer = ltrim(substr($buffer, strcspn($buffer,
" \r\n\t")));
103 if (strncmp($buffer,
'$', 1)) {
107 $name = (string) substr($buffer, 1, strcspn($buffer,
" \r\n\t") - 1);
108 $tags[
'params'][$name] = $type;
112 $type = (string) substr($buffer, 0, strcspn($buffer,
" \r\n\t"));
113 $tags[
'retval'] = $type;
124 if (!strncmp($line,
'\\', 1) || !strncmp($line,
'@', 1)) {
125 $tag = (string) substr($line, 1, strcspn($line,
" \r\n\t") - 1);
126 $buffer = ltrim(substr($line, strcspn($line,
" \r\n\t")));
130 $buffer .=
"\n$line";
160 return 'dateTime.iso8601';
188 'specUrl' =>
'http://www.xmlrpc.com/spec',
192 'introspect' => array(
193 'specUrl' =>
'http://xmlrpc-c.sourceforge.net/xmlrpc-c/introspection.html',
197 'faults_interop' => array(
198 'specUrl' =>
'http://xmlrpc-epi.sourceforge.net/specs/rfc.fault_codes.php',
199 'specVersion' => 20010516,
212 $methods = array_keys($this->server->getIterator()->getArrayCopy());
213 if ($this->whitelist !== null) {
214 $methods = array_intersect($methods, $this->whitelist);
232 if (!is_string($method) || !isset($this->server[$method])) {
233 throw new \InvalidArgumentException(
'Invalid method');
236 $reflector = $this->server[$method]->getReflector();
237 $doc = $reflector->getDocComment();
238 if ($doc ===
false) {
242 $tags = static::extractTypes($doc);
243 $returnType = static::adaptType($tags[
'retval']);
244 if ($returnType === null) {
249 foreach ($reflector->getParameters() as $param) {
250 if (!isset($tags[
'params'][$param->getName()])) {
253 $type = static::adaptType($tags[
'params'][$param->getName()]);
254 if ($type === null) {
260 return array(array_merge(array($returnType), $params));
274 if (!is_string($method) || !isset($this->server[$method])) {
275 throw new \InvalidArgumentException(
'Invalid method');
278 $reflector = $this->server[$method]->getReflector();
279 $doc = $reflector->getDocComment();
280 if ($doc ===
false) {
285 $doc = substr($doc, 2, -2);
288 $doc = str_replace(array(
"\r\n",
"\r"),
"\n", $doc);
293 return trim(trim($l),
'*');
303 return strspn($l,
" \t");
305 array_filter($help,
'strlen')
311 function ($l) use ($cols) {
312 return (
string) substr($l, $cols);
318 return implode(
"\n", $help);
342 $responses = array();
343 foreach ($requests as $request) {
345 if (!is_array($request)) {
346 throw new \BadFunctionCallException(
'Expected struct');
348 if (!isset($request[
'methodName'])) {
349 throw new \BadFunctionCallException(
'Missing methodName');
351 if (!isset($request[
'params'])) {
352 throw new \BadFunctionCallException(
'Missing params');
354 if ($request[
'methodName'] ===
'system.multicall') {
355 throw new \BadFunctionCallException(
'Recursive call');
358 $result = $this->server->call($request[
'methodName'], $request[
'params']);
361 $responses[] = array($result);
363 $responses[] = $error;
__construct(\fpoirotte\XRL\Server $server, array $whitelist=null)
An exception that is used to represent XML-RPC errors.
$whitelist
Whitelist of XML-RPC methods to announce.
multicall(array $requests)
static extractTypes($doc)
static enable(\fpoirotte\XRL\Server $server, array $whitelist=null)
A class that adds various capabilities to an existing XML-RPC server.
$server
Original XML-RPC server.