- return array('class' => $xmlrpcclassname, 'code' => $source, 'docstring' => '');
- }
- }
- }
- }
-
- /**
- * Given the necessary info, build php code that creates a new function to
- * invoke a remote xmlrpc method.
- * Take care that no full checking of input parameters is done to ensure that
- * valid php code is emitted.
- * Note: real spaghetti code follows...
- */
- public function build_remote_method_wrapper_code($client, $methodname, $xmlrpcfuncname,
- $msig, $mdesc = '', $timeout = 0, $protocol = '', $client_copy_mode = 0, $prefix = 'xmlrpc',
- $decode_php_objects = false, $encode_php_objects = false, $decode_fault = false,
- $fault_response = '', $namespace = '\\PhpXmlRpc\\')
- {
- $code = "function $xmlrpcfuncname (";
- if ($client_copy_mode < 2) {
- // client copy mode 0 or 1 == partial / full client copy in emitted code
- $innercode = $this->build_client_wrapper_code($client, $client_copy_mode, $prefix, $namespace);
- $innercode .= "\$client->setDebug(\$debug);\n";
- $this_ = '';
- } else {
- // client copy mode 2 == no client copy in emitted code
- $innercode = '';
- $this_ = 'this->';
- }
- $innercode .= "\$msg = new {$namespace}Request('$methodname');\n";
-
- if ($mdesc != '') {
- // take care that PHP comment is not terminated unwillingly by method description
- $mdesc = "/**\n* " . str_replace('*/', '* /', $mdesc) . "\n";
- } else {
- $mdesc = "/**\nFunction $xmlrpcfuncname\n";
- }
-
- // param parsing
- $innercode .= "\$encoder = new {$namespace}Encoder();\n";
- $plist = array();
- $pcount = count($msig);
- for ($i = 1; $i < $pcount; $i++) {
- $plist[] = "\$p$i";
- $ptype = $msig[$i];
- if ($ptype == 'i4' || $ptype == 'int' || $ptype == 'boolean' || $ptype == 'double' ||
- $ptype == 'string' || $ptype == 'dateTime.iso8601' || $ptype == 'base64' || $ptype == 'null'
- ) {
- // only build directly xmlrpc values when type is known and scalar
- $innercode .= "\$p$i = new {$namespace}Value(\$p$i, '$ptype');\n";
- } else {
- if ($encode_php_objects) {
- $innercode .= "\$p$i = \$encoder->encode(\$p$i, array('encode_php_objs'));\n";
- } else {
- $innercode .= "\$p$i = \$encoder->encode(\$p$i);\n";