12 namespace fpoirotte\XRL;
74 $server->expose($wrapper,
'system');
94 $doc = trim(substr($doc, 3, -2),
" \t\r\n*");
95 $doc = str_replace(array(
"\r\n",
"\r"),
"\n", $doc);
96 $lines = explode(
"\n", $doc .
"\n");
105 foreach ($lines as $line) {
106 $line = trim($line,
" \r\n\t*");
108 if ($tag !== null && $line ===
'') {
111 $type = (string) substr($buffer, 0, strcspn($buffer,
" \r\n\t"));
112 $buffer = ltrim(substr($buffer, strcspn($buffer,
" \r\n\t")));
113 if (strncmp($buffer,
'$', 1)) {
117 $name = (string) substr($buffer, 1, strcspn($buffer,
" \r\n\t") - 1);
118 $tags[
'params'][$name] = $type;
122 $type = (string) substr($buffer, 0, strcspn($buffer,
" \r\n\t"));
123 $tags[
'retval'] = $type;
134 if (!strncmp($line,
'\\', 1) || !strncmp($line,
'@', 1)) {
135 $tag = (string) substr($line, 1, strcspn($line,
" \r\n\t") - 1);
136 $buffer = ltrim(substr($line, strcspn($line,
" \r\n\t")));
140 $buffer .=
"\n$line";
172 return 'dateTime.iso8601';
200 'specUrl' =>
'http://www.xmlrpc.com/spec',
204 'introspect' => array(
205 'specUrl' =>
'http://xmlrpc-c.sourceforge.net/xmlrpc-c/introspection.html',
209 'faults_interop' => array(
210 'specUrl' =>
'http://xmlrpc-epi.sourceforge.net/specs/rfc.fault_codes.php',
211 'specVersion' => 20010516,
224 $methods = array_keys($this->server->getIterator()->getArrayCopy());
225 if ($this->whitelist !== null) {
226 $methods = array_values(array_intersect($methods, $this->whitelist));
244 if (!is_string($method) || !isset($this->server[$method])) {
245 throw new \InvalidArgumentException(
'Invalid method');
248 $reflector = $this->server[$method]->getReflector();
249 $doc = $reflector->getDocComment();
250 if ($doc ===
false) {
254 $tags = static::extractTypes($doc);
255 $returnType = static::adaptType($tags[
'retval']);
256 if ($returnType === null) {
261 foreach ($reflector->getParameters() as $param) {
262 if (!isset($tags[
'params'][$param->getName()])) {
265 $type = static::adaptType($tags[
'params'][$param->getName()]);
266 if ($type === null) {
272 return array(array_merge(array($returnType), $params));
286 if (!is_string($method) || !isset($this->server[$method])) {
287 throw new \InvalidArgumentException(
'Invalid method');
290 $reflector = $this->server[$method]->getReflector();
291 $doc = $reflector->getDocComment();
292 if ($doc ===
false) {
297 $doc = substr($doc, 2, -2);
300 $doc = str_replace(array(
"\r\n",
"\r"),
"\n", $doc);
305 return trim(trim($l),
'*');
315 return strspn($l,
" \t");
317 array_filter($help,
'strlen')
323 function ($l) use ($cols) {
324 return (
string) substr($l, $cols);
330 return implode(
"\n", $help);
354 $responses = array();
355 foreach ($requests as $request) {
357 if (!is_array($request)) {
358 throw new \BadFunctionCallException(
'Expected struct');
360 if (!isset($request[
'methodName'])) {
361 throw new \BadFunctionCallException(
'Missing methodName');
363 if (!isset($request[
'params'])) {
364 throw new \BadFunctionCallException(
'Missing params');
366 if (!is_array($request[
'params'])) {
367 throw new \BadFunctionCallException(
'Invalid params');
369 if ($request[
'methodName'] ===
'system.multicall') {
370 throw new \BadFunctionCallException(
'Recursive call');
373 $result = $this->server->call($request[
'methodName'], $request[
'params']);
376 $responses[] = array($result);
378 $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.