22 public static $objHolder = array();
39 switch (strtolower($phpType)) {
41 return Value::$xmlrpcString;
43 case Value::$xmlrpcInt:
44 case Value::$xmlrpcI4:
45 return Value::$xmlrpcInt;
46 case Value::$xmlrpcDouble:
47 return Value::$xmlrpcDouble;
49 case Value::$xmlrpcBoolean:
52 return Value::$xmlrpcBoolean;
53 case Value::$xmlrpcArray:
54 return Value::$xmlrpcArray;
56 case Value::$xmlrpcStruct:
57 return Value::$xmlrpcStruct;
58 case Value::$xmlrpcBase64:
59 return Value::$xmlrpcBase64;
63 if (class_exists($phpType)) {
64 return Value::$xmlrpcStruct;
67 return Value::$xmlrpcValue;
81 switch (strtolower($xmlrpcType)) {
83 case 'datetime.iso8601':
85 return Value::$xmlrpcString;
100 return strtolower($xmlrpcType);
151 public function wrapPhpFunction($callable, $newFuncName =
'', $extraOptions = array())
153 $buildIt = isset($extraOptions[
'return_source']) ? !($extraOptions[
'return_source']) :
true;
155 if (is_string($callable) && strpos($callable,
'::') !==
false) {
156 $callable = explode(
'::', $callable);
158 if (is_array($callable)) {
159 if (count($callable) < 2 || (!is_string($callable[0]) && !is_object($callable[0]))) {
160 error_log(
'XML-RPC: ' . __METHOD__ .
': syntax for function to be wrapped is wrong');
163 if (is_string($callable[0])) {
164 $plainFuncName = implode(
'::', $callable);
165 } elseif (is_object($callable[0])) {
166 $plainFuncName = get_class($callable[0]) .
'->' . $callable[1];
168 $exists = method_exists($callable[0], $callable[1]);
169 }
else if ($callable instanceof \Closure) {
172 error_log(
'XML-RPC: ' . __METHOD__ .
': a closure can not be wrapped in generated source code');
176 $plainFuncName =
'Closure';
179 $plainFuncName = $callable;
180 $exists = function_exists($callable);
184 error_log(
'XML-RPC: ' . __METHOD__ .
': function to be wrapped is not defined: ' . $plainFuncName);
188 $funcDesc = $this->introspectFunction($callable, $plainFuncName);
193 $funcSigs = $this->buildMethodSignatures($funcDesc);
196 $callable = $this->buildWrapFunctionClosure($callable, $extraOptions, $plainFuncName, $funcDesc);
198 $newFuncName = $this->newFunctionName($callable, $newFuncName, $extraOptions);
199 $code = $this->buildWrapFunctionSource($callable, $newFuncName, $extraOptions, $plainFuncName, $funcDesc);
203 'function' => $callable,
204 'signature' => $funcSigs[
'sigs'],
205 'docstring' => $funcDesc[
'desc'],
206 'signature_docs' => $funcSigs[
'sigsDocs'],
209 $ret[
'function'] = $newFuncName;
210 $ret[
'source'] = $code;
225 if (is_array($callable)) {
226 $func = new \ReflectionMethod($callable[0], $callable[1]);
227 if ($func->isPrivate()) {
228 error_log(
'XML-RPC: ' . __METHOD__ .
': method to be wrapped is private: ' . $plainFuncName);
231 if ($func->isProtected()) {
232 error_log(
'XML-RPC: ' . __METHOD__ .
': method to be wrapped is protected: ' . $plainFuncName);
235 if ($func->isConstructor()) {
236 error_log(
'XML-RPC: ' . __METHOD__ .
': method to be wrapped is the constructor: ' . $plainFuncName);
239 if ($func->isDestructor()) {
240 error_log(
'XML-RPC: ' . __METHOD__ .
': method to be wrapped is the destructor: ' . $plainFuncName);
243 if ($func->isAbstract()) {
244 error_log(
'XML-RPC: ' . __METHOD__ .
': method to be wrapped is abstract: ' . $plainFuncName);
249 $func = new \ReflectionFunction($callable);
251 if ($func->isInternal()) {
254 error_log(
'XML-RPC: ' . __METHOD__ .
': function to be wrapped is internal: ' . $plainFuncName);
263 $returns = Value::$xmlrpcValue;
267 $paramDocs = array();
269 $docs = $func->getDocComment();
271 $docs = explode(
"\n", $docs);
273 foreach ($docs as $doc) {
274 $doc = trim($doc,
" \r\t/*");
275 if (strlen($doc) && strpos($doc,
'@') !== 0 && !$i) {
280 } elseif (strpos($doc,
'@param') === 0) {
282 if (preg_match(
'/@param\s+(\S+)\s+(\$\S+)\s*(.+)?/', $doc, $matches)) {
283 $name = strtolower(trim($matches[2]));
285 $paramDocs[$name][
'doc'] = isset($matches[3]) ? $matches[3] :
'';
286 $paramDocs[$name][
'type'] = $matches[1];
289 } elseif (strpos($doc,
'@return') === 0) {
291 if (preg_match(
'/@return\s+(\S+)(\s+.+)?/', $doc, $matches)) {
292 $returns = $matches[1];
293 if (isset($matches[2])) {
294 $returnsDocs = trim($matches[2]);
304 foreach ($func->getParameters() as $paramObj) {
305 $params[$i] = array();
306 $params[$i][
'name'] =
'$' . $paramObj->getName();
307 $params[$i][
'isoptional'] = $paramObj->isOptional();
315 'paramDocs' => $paramDocs,
316 'returns' => $returns,
317 'returnsDocs' =>$returnsDocs,
334 $parsVariations = array();
336 $pNum = count($funcDesc[
'params']);
337 foreach ($funcDesc[
'params'] as $param) {
347 if ($param[
'isoptional']) {
349 $parsVariations[] = $pars;
356 $parsVariations[] = $pars;
360 if (count($parsVariations) == 0) {
362 $parsVariations[] = array();
367 foreach ($parsVariations as $pars) {
369 $sig = array($this->php2XmlrpcType($funcDesc[
'returns']));
370 $pSig = array($funcDesc[
'returnsDocs']);
371 for ($i = 0; $i < count($pars); $i++) {
372 $name = strtolower($funcDesc[
'params'][$i][
'name']);
373 if (isset($funcDesc[
'paramDocs'][$name][
'type'])) {
374 $sig[] = $this->php2XmlrpcType($funcDesc[
'paramDocs'][$name][
'type']);
376 $sig[] = Value::$xmlrpcValue;
378 $pSig[] = isset($funcDesc[
'paramDocs'][$name][
'doc']) ? $funcDesc[
'paramDocs'][$name][
'doc'] :
'';
386 'sigsDocs' => $sigsDocs
403 $function =
function($req) use($callable, $extraOptions, $funcDesc)
405 $nameSpace =
'\\PhpXmlRpc\\';
406 $encoderClass = $nameSpace.
'Encoder';
407 $responseClass = $nameSpace.
'Response';
408 $valueClass = $nameSpace.
'Value';
412 $minPars = count($funcDesc[
'params']);
414 foreach ($funcDesc[
'params'] as $i => $param) {
415 if ($param[
'isoptional']) {
421 $numPars = $req->getNumParams();
422 if ($numPars < $minPars || $numPars > $maxPars) {
423 return new $responseClass(0, 3,
'Incorrect parameters passed to method');
426 $encoder =
new $encoderClass();
428 if (isset($extraOptions[
'decode_php_objs']) && $extraOptions[
'decode_php_objs']) {
429 $options[] =
'decode_php_objs';
431 $params = $encoder->decode($req, $options);
433 $result = call_user_func_array($callable, $params);
435 if (! is_a($result, $responseClass)) {
436 if ($funcDesc[
'returns'] == Value::$xmlrpcDateTime || $funcDesc[
'returns'] == Value::$xmlrpcBase64) {
437 $result =
new $valueClass($result, $funcDesc[
'returns']);
440 if (isset($extraOptions[
'encode_php_objs']) && $extraOptions[
'encode_php_objs']) {
441 $options[] =
'encode_php_objs';
444 $result = $encoder->encode($result, $options);
446 $result =
new $responseClass($result);
465 $prefix = isset($extraOptions[
'prefix']) ? $extraOptions[
'prefix'] :
'xmlrpc';
467 if ($newFuncName ==
'') {
468 if (is_array($callable)) {
469 if (is_string($callable[0])) {
470 $xmlrpcFuncName =
"{$prefix}_" . implode(
'_', $callable);
472 $xmlrpcFuncName =
"{$prefix}_" . get_class($callable[0]) .
'_' . $callable[1];
475 if ($callable instanceof \Closure) {
476 $xmlrpcFuncName =
"{$prefix}_closure";
478 $callable = preg_replace(array(
'/\./',
'/[^a-zA-Z0-9_\x7f-\xff]/'),
479 array(
'_',
''), $callable);
480 $xmlrpcFuncName =
"{$prefix}_$callable";
484 $xmlrpcFuncName = $newFuncName;
487 while (function_exists($xmlrpcFuncName)) {
488 $xmlrpcFuncName .=
'x';
491 return $xmlrpcFuncName;
506 $namespace =
'\\PhpXmlRpc\\';
508 $encodePhpObjects = isset($extraOptions[
'encode_php_objs']) ? (bool)$extraOptions[
'encode_php_objs'] :
false;
509 $decodePhpObjects = isset($extraOptions[
'decode_php_objs']) ? (bool)$extraOptions[
'decode_php_objs'] :
false;
510 $catchWarnings = isset($extraOptions[
'suppress_warnings']) && $extraOptions[
'suppress_warnings'] ?
'@' :
'';
513 $parsVariations = array();
515 $pNum = count($funcDesc[
'params']);
516 foreach ($funcDesc[
'params'] as $param) {
518 if ($param[
'isoptional']) {
520 $parsVariations[] = $pars;
527 $parsVariations[] = $pars;
531 if (count($parsVariations) == 0) {
533 $parsVariations[] = array();
537 $minPars = count($parsVariations[0]);
538 $maxPars = count($parsVariations[count($parsVariations)-1]);
543 $innerCode =
"\$paramCount = \$req->getNumParams();\n";
544 $innerCode .=
"if (\$paramCount < $minPars || \$paramCount > $maxPars) return new {$namespace}Response(0, " . PhpXmlRpc::$xmlrpcerr[
'incorrect_params'] .
", '" . PhpXmlRpc::$xmlrpcstr[
'incorrect_params'] .
"');\n";
546 $innerCode .=
"\$encoder = new {$namespace}Encoder();\n";
547 if ($decodePhpObjects) {
548 $innerCode .=
"\$p = \$encoder->decode(\$req, array('decode_php_objs'));\n";
550 $innerCode .=
"\$p = \$encoder->decode(\$req);\n";
555 if (is_array($callable) && is_object($callable[0])) {
556 self::$objHolder[$newFuncName] = $callable[0];
557 $innerCode .=
"\$obj = PhpXmlRpc\\Wrapper::\$objHolder['$newFuncName'];\n";
558 $realFuncName =
'$obj->' . $callable[1];
560 $realFuncName = $plainFuncName;
562 foreach ($parsVariations as $i => $pars) {
563 $innerCode .=
"if (\$paramCount == " . count($pars) .
") \$retval = {$catchWarnings}$realFuncName(" . implode(
',', $pars) .
");\n";
564 if ($i < (count($parsVariations) - 1))
565 $innerCode .=
"else\n";
567 $innerCode .=
"if (is_a(\$retval, '{$namespace}Response')) return \$retval; else\n";
568 if ($funcDesc[
'returns'] == Value::$xmlrpcDateTime || $funcDesc[
'returns'] == Value::$xmlrpcBase64) {
569 $innerCode .=
"return new {$namespace}Response(new {$namespace}Value(\$retval, '{$funcDesc['returns']}'));";
571 if ($encodePhpObjects) {
572 $innerCode .=
"return new {$namespace}Response(\$encoder->encode(\$retval, array('encode_php_objs')));\n";
574 $innerCode .=
"return new {$namespace}Response(\$encoder->encode(\$retval));\n";
581 $code =
"function $newFuncName(\$req) {\n" . $innerCode .
"\n}";
601 $methodFilter = isset($extraOptions[
'method_filter']) ? $extraOptions[
'method_filter'] :
'';
602 $methodType = isset($extraOptions[
'method_type']) ? $extraOptions[
'method_type'] :
'auto';
603 $prefix = isset($extraOptions[
'prefix']) ? $extraOptions[
'prefix'] :
'';
606 $mList = get_class_methods($className);
607 foreach ($mList as $mName) {
608 if ($methodFilter ==
'' || preg_match($methodFilter, $mName)) {
609 $func = new \ReflectionMethod($className, $mName);
610 if (!$func->isPrivate() && !$func->isProtected() && !$func->isConstructor() && !$func->isDestructor() && !$func->isAbstract()) {
611 if (($func->isStatic() && ($methodType ==
'all' || $methodType ==
'static' || ($methodType ==
'auto' && is_string($className)))) ||
612 (!$func->isStatic() && ($methodType ==
'all' || $methodType ==
'nonstatic' || ($methodType ==
'auto' && is_object($className))))
614 $methodWrap = $this->wrapPhpFunction(array($className, $mName),
'', $extraOptions);
616 if (is_object($className)) {
617 $realClassName = get_class($className);
619 $realClassName = $className;
621 $results[$prefix.
"$realClassName.$mName"] = $methodWrap;
678 $newFuncName = isset($extraOptions[
'new_function_name']) ? $extraOptions[
'new_function_name'] :
'';
680 $buildIt = isset($extraOptions[
'return_source']) ? !($extraOptions[
'return_source']) :
true;
682 $mSig = $this->retrieveMethodSignature($client, $methodName, $extraOptions);
688 return $this->buildWrapMethodClosure($client, $methodName, $extraOptions, $mSig);
692 $mDesc = $this->retrieveMethodHelp($client, $methodName, $extraOptions);
694 $newFuncName = $this->newFunctionName($methodName, $newFuncName, $extraOptions);
696 $results = $this->buildWrapMethodSource($client, $methodName, $extraOptions, $newFuncName, $mSig, $mDesc);
702 $results[
'function'] = $newFuncName;
718 $namespace =
'\\PhpXmlRpc\\';
719 $reqClass = $namespace .
'Request';
720 $valClass = $namespace .
'Value';
721 $decoderClass = $namespace .
'Encoder';
723 $debug = isset($extraOptions[
'debug']) ? ($extraOptions[
'debug']) : 0;
724 $timeout = isset($extraOptions[
'timeout']) ? (int)$extraOptions[
'timeout'] : 0;
725 $protocol = isset($extraOptions[
'protocol']) ? $extraOptions[
'protocol'] :
'';
726 $sigNum = isset($extraOptions[
'signum']) ? (int)$extraOptions[
'signum'] : 0;
728 $req =
new $reqClass(
'system.methodSignature');
729 $req->addparam(
new $valClass($methodName));
730 $client->setDebug($debug);
731 $response = $client->send($req, $timeout, $protocol);
732 if ($response->faultCode()) {
733 error_log(
'XML-RPC: ' . __METHOD__ .
': could not retrieve method signature from remote server for method ' . $methodName);
737 $mSig = $response->value();
738 if ($client->return_type !=
'phpvals') {
739 $decoder =
new $decoderClass();
740 $mSig = $decoder->decode($mSig);
743 if (!is_array($mSig) || count($mSig) <= $sigNum) {
744 error_log(
'XML-RPC: ' . __METHOD__ .
': could not retrieve method signature nr.' . $sigNum .
' from remote server for method ' . $methodName);
748 return $mSig[$sigNum];
759 $namespace =
'\\PhpXmlRpc\\';
760 $reqClass = $namespace .
'Request';
761 $valClass = $namespace .
'Value';
763 $debug = isset($extraOptions[
'debug']) ? ($extraOptions[
'debug']) : 0;
764 $timeout = isset($extraOptions[
'timeout']) ? (int)$extraOptions[
'timeout'] : 0;
765 $protocol = isset($extraOptions[
'protocol']) ? $extraOptions[
'protocol'] :
'';
769 $req =
new $reqClass(
'system.methodHelp');
770 $req->addparam(
new $valClass($methodName));
771 $client->setDebug($debug);
772 $response = $client->send($req, $timeout, $protocol);
773 if (!$response->faultCode()) {
774 $mDesc = $response->value();
775 if ($client->return_type !=
'phpvals') {
776 $mDesc = $mDesc->scalarval();
795 $clientClone = clone $client;
796 $function =
function() use($clientClone, $methodName, $extraOptions, $mSig)
798 $timeout = isset($extraOptions[
'timeout']) ? (int)$extraOptions[
'timeout'] : 0;
799 $protocol = isset($extraOptions[
'protocol']) ? $extraOptions[
'protocol'] :
'';
800 $encodePhpObjects = isset($extraOptions[
'encode_php_objs']) ? (bool)$extraOptions[
'encode_php_objs'] :
false;
801 $decodePhpObjects = isset($extraOptions[
'decode_php_objs']) ? (bool)$extraOptions[
'decode_php_objs'] :
false;
802 if (isset($extraOptions[
'return_on_fault'])) {
804 $faultResponse = $extraOptions[
'return_on_fault'];
806 $decodeFault =
false;
809 $namespace =
'\\PhpXmlRpc\\';
810 $reqClass = $namespace .
'Request';
811 $encoderClass = $namespace .
'Encoder';
812 $valueClass = $namespace .
'Value';
814 $encoder =
new $encoderClass();
815 $encodeOptions = array();
816 if ($encodePhpObjects) {
817 $encodeOptions[] =
'encode_php_objs';
819 $decodeOptions = array();
820 if ($decodePhpObjects) {
821 $decodeOptions[] =
'decode_php_objs';
827 $maxArgs = count($mSig)-1;
828 $currentArgs = func_get_args();
829 if (func_num_args() == ($maxArgs+1)) {
830 $debug = array_pop($currentArgs);
831 $clientClone->setDebug($debug);
834 $xmlrpcArgs = array();
835 foreach($currentArgs as $i => $arg) {
836 if ($i == $maxArgs) {
839 $pType = $mSig[$i+1];
840 if ($pType ==
'i4' || $pType ==
'int' || $pType ==
'boolean' || $pType ==
'double' ||
841 $pType ==
'string' || $pType ==
'dateTime.iso8601' || $pType ==
'base64' || $pType ==
'null'
845 $xmlrpcArgs[] =
new $valueClass($arg, $pType);
847 $xmlrpcArgs[] = $encoder->encode($arg, $encodeOptions);
851 $req =
new $reqClass($methodName, $xmlrpcArgs);
853 $clientClone->return_type =
'xmlrpcvals';
854 $resp = $clientClone->send($req, $timeout, $protocol);
855 if ($resp->faultcode()) {
857 if (is_string($faultResponse) && ((strpos($faultResponse,
'%faultCode%') !==
false) ||
858 (strpos($faultResponse,
'%faultString%') !==
false))) {
859 $faultResponse = str_replace(array(
'%faultCode%',
'%faultString%'),
860 array($resp->faultCode(), $resp->faultString()), $faultResponse);
862 return $faultResponse;
867 return $encoder->decode($resp->value(), $decodeOptions);
885 $timeout = isset($extraOptions[
'timeout']) ? (int)$extraOptions[
'timeout'] : 0;
886 $protocol = isset($extraOptions[
'protocol']) ? $extraOptions[
'protocol'] :
'';
887 $encodePhpObjects = isset($extraOptions[
'encode_php_objs']) ? (bool)$extraOptions[
'encode_php_objs'] :
false;
888 $decodePhpObjects = isset($extraOptions[
'decode_php_objs']) ? (bool)$extraOptions[
'decode_php_objs'] :
false;
889 $clientCopyMode = isset($extraOptions[
'simple_client_copy']) ? (int)($extraOptions[
'simple_client_copy']) : 0;
890 $prefix = isset($extraOptions[
'prefix']) ? $extraOptions[
'prefix'] :
'xmlrpc';
891 if (isset($extraOptions[
'return_on_fault'])) {
893 $faultResponse = $extraOptions[
'return_on_fault'];
895 $decodeFault =
false;
899 $namespace =
'\\PhpXmlRpc\\';
901 $code =
"function $newFuncName (";
902 if ($clientCopyMode < 2) {
904 $verbatimClientCopy = !$clientCopyMode;
905 $innerCode = $this->buildClientWrapperCode($client, $verbatimClientCopy, $prefix, $namespace);
906 $innerCode .=
"\$client->setDebug(\$debug);\n";
913 $innerCode .=
"\$req = new {$namespace}Request('$methodName');\n";
917 $mDesc =
"/**\n* " . str_replace(
'*/',
'* /', $mDesc) .
"\n";
919 $mDesc =
"/**\nFunction $newFuncName\n";
923 $innerCode .=
"\$encoder = new {$namespace}Encoder();\n";
925 $pCount = count($mSig);
926 for ($i = 1; $i < $pCount; $i++) {
929 if ($pType ==
'i4' || $pType ==
'int' || $pType ==
'boolean' || $pType ==
'double' ||
930 $pType ==
'string' || $pType ==
'dateTime.iso8601' || $pType ==
'base64' || $pType ==
'null'
933 $innerCode .=
"\$p$i = new {$namespace}Value(\$p$i, '$pType');\n";
935 if ($encodePhpObjects) {
936 $innerCode .=
"\$p$i = \$encoder->encode(\$p$i, array('encode_php_objs'));\n";
938 $innerCode .=
"\$p$i = \$encoder->encode(\$p$i);\n";
941 $innerCode .=
"\$req->addparam(\$p$i);\n";
942 $mDesc .=
'* @param ' . $this->xmlrpc2PhpType($pType) .
" \$p$i\n";
944 if ($clientCopyMode < 2) {
945 $plist[] =
'$debug=0';
946 $mDesc .=
"* @param int \$debug when 1 (or 2) will enable debugging of the underlying {$prefix} call (defaults to 0)\n";
948 $plist = implode(
', ', $plist);
949 $mDesc .=
'* @return ' . $this->xmlrpc2PhpType($mSig[0]) .
" (or an {$namespace}Response obj instance if call fails)\n*/\n";
951 $innerCode .=
"\$res = \${$this_}client->send(\$req, $timeout, '$protocol');\n";
953 if (is_string($faultResponse) && ((strpos($faultResponse,
'%faultCode%') !==
false) || (strpos($faultResponse,
'%faultString%') !==
false))) {
954 $respCode =
"str_replace(array('%faultCode%', '%faultString%'), array(\$res->faultCode(), \$res->faultString()), '" . str_replace(
"'",
"''", $faultResponse) .
"')";
956 $respCode = var_export($faultResponse,
true);
961 if ($decodePhpObjects) {
962 $innerCode .=
"if (\$res->faultcode()) return $respCode; else return \$encoder->decode(\$res->value(), array('decode_php_objs'));";
964 $innerCode .=
"if (\$res->faultcode()) return $respCode; else return \$encoder->decode(\$res->value());";
967 $code = $code . $plist .
") {\n" . $innerCode .
"\n}\n";
969 return array(
'source' => $code,
'docstring' => $mDesc);
992 $methodFilter = isset($extraOptions[
'method_filter']) ? $extraOptions[
'method_filter'] :
'';
993 $timeout = isset($extraOptions[
'timeout']) ? (int)$extraOptions[
'timeout'] : 0;
994 $protocol = isset($extraOptions[
'protocol']) ? $extraOptions[
'protocol'] :
'';
995 $newClassName = isset($extraOptions[
'new_class_name']) ? $extraOptions[
'new_class_name'] :
'';
996 $encodePhpObjects = isset($extraOptions[
'encode_php_objs']) ? (bool)$extraOptions[
'encode_php_objs'] :
false;
997 $decodePhpObjects = isset($extraOptions[
'decode_php_objs']) ? (bool)$extraOptions[
'decode_php_objs'] :
false;
998 $verbatimClientCopy = isset($extraOptions[
'simple_client_copy']) ? !($extraOptions[
'simple_client_copy']) :
true;
999 $buildIt = isset($extraOptions[
'return_source']) ? !($extraOptions[
'return_source']) :
true;
1000 $prefix = isset($extraOptions[
'prefix']) ? $extraOptions[
'prefix'] :
'xmlrpc';
1001 $namespace =
'\\PhpXmlRpc\\';
1003 $reqClass = $namespace .
'Request';
1004 $decoderClass = $namespace .
'Encoder';
1006 $req =
new $reqClass(
'system.listMethods');
1007 $response = $client->send($req, $timeout, $protocol);
1008 if ($response->faultCode()) {
1009 error_log(
'XML-RPC: ' . __METHOD__ .
': could not retrieve method list from remote server');
1013 $mList = $response->value();
1014 if ($client->return_type !=
'phpvals') {
1015 $decoder =
new $decoderClass();
1016 $mList = $decoder->decode($mList);
1018 if (!is_array($mList) || !count($mList)) {
1019 error_log(
'XML-RPC: ' . __METHOD__ .
': could not retrieve meaningful method list from remote server');
1024 if ($newClassName !=
'') {
1025 $xmlrpcClassName = $newClassName;
1027 $xmlrpcClassName = $prefix .
'_' . preg_replace(array(
'/\./',
'/[^a-zA-Z0-9_\x7f-\xff]/'),
1028 array(
'_',
''), $client->server) .
'_client';
1030 while ($buildIt && class_exists($xmlrpcClassName)) {
1031 $xmlrpcClassName .=
'x';
1035 $source =
"class $xmlrpcClassName\n{\npublic \$client;\n\n";
1036 $source .=
"function __construct()\n{\n";
1037 $source .= $this->buildClientWrapperCode($client, $verbatimClientCopy, $prefix, $namespace);
1038 $source .=
"\$this->client = \$client;\n}\n\n";
1040 'return_source' =>
true,
1041 'simple_client_copy' => 2,
1042 'timeout' => $timeout,
1043 'protocol' => $protocol,
1044 'encode_php_objs' => $encodePhpObjects,
1045 'decode_php_objs' => $decodePhpObjects,
1046 'prefix' => $prefix,
1049 foreach ($mList as $mName) {
1050 if ($methodFilter ==
'' || preg_match($methodFilter, $mName)) {
1052 $opts[
'new_function_name'] = preg_replace(array(
'/\./',
'/[^a-zA-Z0-9_\x7f-\xff]/'),
1053 array(
'_',
''), $mName);
1054 $methodWrap = $this->wrapXmlrpcMethod($client, $mName, $opts);
1057 $source .= $methodWrap[
'docstring'];
1059 $source .= $methodWrap[
'source'] .
"\n";
1061 error_log(
'XML-RPC: ' . __METHOD__ .
': will not create class method to wrap remote method ' . $mName);
1068 eval($source .
'$allOK=1;');
1070 return $xmlrpcClassName;
1072 error_log(
'XML-RPC: ' . __METHOD__ .
': could not create class ' . $xmlrpcClassName .
' to wrap remote server ' . $client->server);
1076 return array(
'class' => $xmlrpcClassName,
'code' => $source,
'docstring' =>
'');
1095 $code =
"\$client = new {$namespace}Client('" . str_replace(
"'",
"\'", $client->path) .
1096 "', '" . str_replace(
"'",
"\'", $client->server) .
"', $client->port);\n";
1100 if ($verbatimClientCopy) {
1101 foreach ($client as $fld => $val) {
1102 if ($fld !=
'debug' && $fld !=
'return_type') {
1103 $val = var_export($val,
true);
1104 $code .=
"\$client->$fld = $val;\n";
1109 $code .=
"\$client->return_type = '{$prefix}vals';\n";