|
@@ -181,20 +181,20 @@ discard block |
|
|
block discarded – undo |
|
181
|
181
|
$callable = explode('::', $callable); |
|
182
|
182
|
} |
|
183
|
183
|
if (is_array($callable)) { |
|
184
|
|
- if (count($callable) < 2 || (!is_string($callable[0]) && !is_object($callable[0]))) { |
|
185
|
|
- $this->getLogger()->errorLog('XML-RPC: ' . __METHOD__ . ': syntax for function to be wrapped is wrong'); |
|
|
184
|
+ if (count($callable)<2 || (!is_string($callable[0]) && !is_object($callable[0]))) { |
|
|
185
|
+ $this->getLogger()->errorLog('XML-RPC: '.__METHOD__.': syntax for function to be wrapped is wrong'); |
|
186
|
186
|
return false; |
|
187
|
187
|
} |
|
188
|
188
|
if (is_string($callable[0])) { |
|
189
|
189
|
$plainFuncName = implode('::', $callable); |
|
190
|
190
|
} elseif (is_object($callable[0])) { |
|
191
|
|
- $plainFuncName = get_class($callable[0]) . '->' . $callable[1]; |
|
|
191
|
+ $plainFuncName = get_class($callable[0]).'->'.$callable[1]; |
|
192
|
192
|
} |
|
193
|
193
|
$exists = method_exists($callable[0], $callable[1]); |
|
194
|
194
|
} else if ($callable instanceof \Closure) { |
|
195
|
195
|
// we do not support creating code which wraps closures, as php does not allow to serialize them |
|
196
|
196
|
if (!$buildIt) { |
|
197
|
|
- $this->getLogger()->errorLog('XML-RPC: ' . __METHOD__ . ': a closure can not be wrapped in generated source code'); |
|
|
197
|
+ $this->getLogger()->errorLog('XML-RPC: '.__METHOD__.': a closure can not be wrapped in generated source code'); |
|
198
|
198
|
return false; |
|
199
|
199
|
} |
|
200
|
200
|
|
|
@@ -206,7 +206,7 @@ discard block |
|
|
block discarded – undo |
|
206
|
206
|
} |
|
207
|
207
|
|
|
208
|
208
|
if (!$exists) { |
|
209
|
|
- $this->getLogger()->errorLog('XML-RPC: ' . __METHOD__ . ': function to be wrapped is not defined: ' . $plainFuncName); |
|
|
209
|
+ $this->getLogger()->errorLog('XML-RPC: '.__METHOD__.': function to be wrapped is not defined: '.$plainFuncName); |
|
210
|
210
|
return false; |
|
211
|
211
|
} |
|
212
|
212
|
|
|
@@ -251,23 +251,23 @@ discard block |
|
|
block discarded – undo |
|
251
|
251
|
if (is_array($callable)) { |
|
252
|
252
|
$func = new \ReflectionMethod($callable[0], $callable[1]); |
|
253
|
253
|
if ($func->isPrivate()) { |
|
254
|
|
- $this->getLogger()->errorLog('XML-RPC: ' . __METHOD__ . ': method to be wrapped is private: ' . $plainFuncName); |
|
|
254
|
+ $this->getLogger()->errorLog('XML-RPC: '.__METHOD__.': method to be wrapped is private: '.$plainFuncName); |
|
255
|
255
|
return false; |
|
256
|
256
|
} |
|
257
|
257
|
if ($func->isProtected()) { |
|
258
|
|
- $this->getLogger()->errorLog('XML-RPC: ' . __METHOD__ . ': method to be wrapped is protected: ' . $plainFuncName); |
|
|
258
|
+ $this->getLogger()->errorLog('XML-RPC: '.__METHOD__.': method to be wrapped is protected: '.$plainFuncName); |
|
259
|
259
|
return false; |
|
260
|
260
|
} |
|
261
|
261
|
if ($func->isConstructor()) { |
|
262
|
|
- $this->getLogger()->errorLog('XML-RPC: ' . __METHOD__ . ': method to be wrapped is the constructor: ' . $plainFuncName); |
|
|
262
|
+ $this->getLogger()->errorLog('XML-RPC: '.__METHOD__.': method to be wrapped is the constructor: '.$plainFuncName); |
|
263
|
263
|
return false; |
|
264
|
264
|
} |
|
265
|
265
|
if ($func->isDestructor()) { |
|
266
|
|
- $this->getLogger()->errorLog('XML-RPC: ' . __METHOD__ . ': method to be wrapped is the destructor: ' . $plainFuncName); |
|
|
266
|
+ $this->getLogger()->errorLog('XML-RPC: '.__METHOD__.': method to be wrapped is the destructor: '.$plainFuncName); |
|
267
|
267
|
return false; |
|
268
|
268
|
} |
|
269
|
269
|
if ($func->isAbstract()) { |
|
270
|
|
- $this->getLogger()->errorLog('XML-RPC: ' . __METHOD__ . ': method to be wrapped is abstract: ' . $plainFuncName); |
|
|
270
|
+ $this->getLogger()->errorLog('XML-RPC: '.__METHOD__.': method to be wrapped is abstract: '.$plainFuncName); |
|
271
|
271
|
return false; |
|
272
|
272
|
} |
|
273
|
273
|
/// @todo add more checks for static vs. nonstatic? |
|
@@ -277,7 +277,7 @@ discard block |
|
|
block discarded – undo |
|
277
|
277
|
if ($func->isInternal()) { |
|
278
|
278
|
/// @todo from PHP 5.1.0 onward, we should be able to use invokeargs instead of getparameters to fully |
|
279
|
279
|
/// reflect internal php functions |
|
280
|
|
- $this->getLogger()->errorLog('XML-RPC: ' . __METHOD__ . ': function to be wrapped is internal: ' . $plainFuncName); |
|
|
280
|
+ $this->getLogger()->errorLog('XML-RPC: '.__METHOD__.': function to be wrapped is internal: '.$plainFuncName); |
|
281
|
281
|
return false; |
|
282
|
282
|
} |
|
283
|
283
|
|
|
@@ -329,7 +329,7 @@ discard block |
|
|
block discarded – undo |
|
329
|
329
|
$i = 0; |
|
330
|
330
|
foreach ($func->getParameters() as $paramObj) { |
|
331
|
331
|
$params[$i] = array(); |
|
332
|
|
- $params[$i]['name'] = '$' . $paramObj->getName(); |
|
|
332
|
+ $params[$i]['name'] = '$'.$paramObj->getName(); |
|
333
|
333
|
$params[$i]['isoptional'] = $paramObj->isOptional(); |
|
334
|
334
|
$i++; |
|
335
|
335
|
} |
|
@@ -394,7 +394,7 @@ discard block |
|
|
block discarded – undo |
|
394
|
394
|
// build a signature |
|
395
|
395
|
$sig = array($this->php2XmlrpcType($funcDesc['returns'])); |
|
396
|
396
|
$pSig = array($funcDesc['returnsDocs']); |
|
397
|
|
- for ($i = 0; $i < count($pars); $i++) { |
|
|
397
|
+ for ($i = 0; $i<count($pars); $i++) { |
|
398
|
398
|
$name = strtolower($funcDesc['params'][$i]['name']); |
|
399
|
399
|
if (isset($funcDesc['paramDocs'][$name]['type'])) { |
|
400
|
400
|
$sig[] = $this->php2XmlrpcType($funcDesc['paramDocs'][$name]['type']); |
|
@@ -452,7 +452,7 @@ discard block |
|
|
block discarded – undo |
|
452
|
452
|
} |
|
453
|
453
|
} |
|
454
|
454
|
$numPars = $req->getNumParams(); |
|
455
|
|
- if ($numPars < $minPars || $numPars > $maxPars) { |
|
|
455
|
+ if ($numPars<$minPars || $numPars>$maxPars) { |
|
456
|
456
|
return new $responseClass(0, 3, 'Incorrect parameters passed to method'); |
|
457
|
457
|
} |
|
458
|
458
|
|
|
@@ -465,7 +465,7 @@ discard block |
|
|
block discarded – undo |
|
465
|
465
|
|
|
466
|
466
|
$result = call_user_func_array($callable, $params); |
|
467
|
467
|
|
|
468
|
|
- if (! is_a($result, $responseClass)) { |
|
|
468
|
+ if (!is_a($result, $responseClass)) { |
|
469
|
469
|
if ($funcDesc['returns'] == Value::$xmlrpcDateTime || $funcDesc['returns'] == Value::$xmlrpcBase64) { |
|
470
|
470
|
$result = new $valueClass($result, $funcDesc['returns']); |
|
471
|
471
|
} else { |
|
@@ -501,9 +501,9 @@ discard block |
|
|
block discarded – undo |
|
501
|
501
|
if ($newFuncName == '') { |
|
502
|
502
|
if (is_array($callable)) { |
|
503
|
503
|
if (is_string($callable[0])) { |
|
504
|
|
- $xmlrpcFuncName = "{$prefix}_" . implode('_', $callable); |
|
|
504
|
+ $xmlrpcFuncName = "{$prefix}_".implode('_', $callable); |
|
505
|
505
|
} else { |
|
506
|
|
- $xmlrpcFuncName = "{$prefix}_" . get_class($callable[0]) . '_' . $callable[1]; |
|
|
506
|
+ $xmlrpcFuncName = "{$prefix}_".get_class($callable[0]).'_'.$callable[1]; |
|
507
|
507
|
} |
|
508
|
508
|
} else { |
|
509
|
509
|
if ($callable instanceof \Closure) { |
|
@@ -540,8 +540,8 @@ discard block |
|
|
block discarded – undo |
|
540
|
540
|
{ |
|
541
|
541
|
$namespace = '\\PhpXmlRpc\\'; |
|
542
|
542
|
|
|
543
|
|
- $encodePhpObjects = isset($extraOptions['encode_php_objs']) ? (bool)$extraOptions['encode_php_objs'] : false; |
|
544
|
|
- $decodePhpObjects = isset($extraOptions['decode_php_objs']) ? (bool)$extraOptions['decode_php_objs'] : false; |
|
|
543
|
+ $encodePhpObjects = isset($extraOptions['encode_php_objs']) ? (bool) $extraOptions['encode_php_objs'] : false; |
|
|
544
|
+ $decodePhpObjects = isset($extraOptions['decode_php_objs']) ? (bool) $extraOptions['decode_php_objs'] : false; |
|
545
|
545
|
$catchWarnings = isset($extraOptions['suppress_warnings']) && $extraOptions['suppress_warnings'] ? '@' : ''; |
|
546
|
546
|
|
|
547
|
547
|
$i = 0; |
|
@@ -576,7 +576,7 @@ discard block |
|
|
block discarded – undo |
|
576
|
576
|
// build body of new function |
|
577
|
577
|
|
|
578
|
578
|
$innerCode = "\$paramCount = \$req->getNumParams();\n"; |
|
579
|
|
- $innerCode .= "if (\$paramCount < $minPars || \$paramCount > $maxPars) return new {$namespace}Response(0, " . PhpXmlRpc::$xmlrpcerr['incorrect_params'] . ", '" . PhpXmlRpc::$xmlrpcstr['incorrect_params'] . "');\n"; |
|
|
579
|
+ $innerCode .= "if (\$paramCount < $minPars || \$paramCount > $maxPars) return new {$namespace}Response(0, ".PhpXmlRpc::$xmlrpcerr['incorrect_params'].", '".PhpXmlRpc::$xmlrpcstr['incorrect_params']."');\n"; |
|
580
|
580
|
|
|
581
|
581
|
$innerCode .= "\$encoder = new {$namespace}Encoder();\n"; |
|
582
|
582
|
if ($decodePhpObjects) { |
|
@@ -590,13 +590,13 @@ discard block |
|
|
block discarded – undo |
|
590
|
590
|
if (is_array($callable) && is_object($callable[0])) { |
|
591
|
591
|
self::$objHolder[$newFuncName] = $callable[0]; |
|
592
|
592
|
$innerCode .= "\$obj = PhpXmlRpc\\Wrapper::\$objHolder['$newFuncName'];\n"; |
|
593
|
|
- $realFuncName = '$obj->' . $callable[1]; |
|
|
593
|
+ $realFuncName = '$obj->'.$callable[1]; |
|
594
|
594
|
} else { |
|
595
|
595
|
$realFuncName = $plainFuncName; |
|
596
|
596
|
} |
|
597
|
597
|
foreach ($parsVariations as $i => $pars) { |
|
598
|
|
- $innerCode .= "if (\$paramCount == " . count($pars) . ") \$retval = {$catchWarnings}$realFuncName(" . implode(',', $pars) . ");\n"; |
|
599
|
|
- if ($i < (count($parsVariations) - 1)) |
|
|
598
|
+ $innerCode .= "if (\$paramCount == ".count($pars).") \$retval = {$catchWarnings}$realFuncName(".implode(',', $pars).");\n"; |
|
|
599
|
+ if ($i<(count($parsVariations)-1)) |
|
600
|
600
|
$innerCode .= "else\n"; |
|
601
|
601
|
} |
|
602
|
602
|
$innerCode .= "if (is_a(\$retval, '{$namespace}Response')) return \$retval; else\n"; |
|
@@ -613,7 +613,7 @@ discard block |
|
|
block discarded – undo |
|
613
|
613
|
// if ($func->returnsReference()) |
|
614
|
614
|
// return false; |
|
615
|
615
|
|
|
616
|
|
- $code = "function $newFuncName(\$req) {\n" . $innerCode . "\n}"; |
|
|
616
|
+ $code = "function $newFuncName(\$req) {\n".$innerCode."\n}"; |
|
617
|
617
|
|
|
618
|
618
|
return $code; |
|
619
|
619
|
} |
|
@@ -669,7 +669,7 @@ discard block |
|
|
block discarded – undo |
|
669
|
669
|
protected function generateMethodNameForClassMethod($className, $classMethod, $extraOptions = array()) |
|
670
|
670
|
{ |
|
671
|
671
|
if (isset($extraOptions['replace_class_name']) && $extraOptions['replace_class_name']) { |
|
672
|
|
- return (isset($extraOptions['prefix']) ? $extraOptions['prefix'] : '') . $classMethod; |
|
|
672
|
+ return (isset($extraOptions['prefix']) ? $extraOptions['prefix'] : '').$classMethod; |
|
673
|
673
|
} |
|
674
|
674
|
|
|
675
|
675
|
if (is_object($className)) { |
|
@@ -677,7 +677,7 @@ discard block |
|
|
block discarded – undo |
|
677
|
677
|
} else { |
|
678
|
678
|
$realClassName = $className; |
|
679
|
679
|
} |
|
680
|
|
- return (isset($extraOptions['prefix']) ? $extraOptions['prefix'] : '') . "$realClassName.$classMethod"; |
|
|
680
|
+ return (isset($extraOptions['prefix']) ? $extraOptions['prefix'] : '')."$realClassName.$classMethod"; |
|
681
|
681
|
} |
|
682
|
682
|
|
|
683
|
683
|
/** |
|
@@ -760,21 +760,21 @@ discard block |
|
|
block discarded – undo |
|
760
|
760
|
protected function retrieveMethodSignature($client, $methodName, array $extraOptions = array()) |
|
761
|
761
|
{ |
|
762
|
762
|
$namespace = '\\PhpXmlRpc\\'; |
|
763
|
|
- $reqClass = $namespace . 'Request'; |
|
764
|
|
- $valClass = $namespace . 'Value'; |
|
765
|
|
- $decoderClass = $namespace . 'Encoder'; |
|
|
763
|
+ $reqClass = $namespace.'Request'; |
|
|
764
|
+ $valClass = $namespace.'Value'; |
|
|
765
|
+ $decoderClass = $namespace.'Encoder'; |
|
766
|
766
|
|
|
767
|
767
|
$debug = isset($extraOptions['debug']) ? ($extraOptions['debug']) : 0; |
|
768
|
|
- $timeout = isset($extraOptions['timeout']) ? (int)$extraOptions['timeout'] : 0; |
|
|
768
|
+ $timeout = isset($extraOptions['timeout']) ? (int) $extraOptions['timeout'] : 0; |
|
769
|
769
|
$protocol = isset($extraOptions['protocol']) ? $extraOptions['protocol'] : ''; |
|
770
|
|
- $sigNum = isset($extraOptions['signum']) ? (int)$extraOptions['signum'] : 0; |
|
|
770
|
+ $sigNum = isset($extraOptions['signum']) ? (int) $extraOptions['signum'] : 0; |
|
771
|
771
|
|
|
772
|
772
|
$req = new $reqClass('system.methodSignature'); |
|
773
|
773
|
$req->addparam(new $valClass($methodName)); |
|
774
|
774
|
$client->setDebug($debug); |
|
775
|
775
|
$response = $client->send($req, $timeout, $protocol); |
|
776
|
776
|
if ($response->faultCode()) { |
|
777
|
|
- $this->getLogger()->errorLog('XML-RPC: ' . __METHOD__ . ': could not retrieve method signature from remote server for method ' . $methodName); |
|
|
777
|
+ $this->getLogger()->errorLog('XML-RPC: '.__METHOD__.': could not retrieve method signature from remote server for method '.$methodName); |
|
778
|
778
|
return false; |
|
779
|
779
|
} |
|
780
|
780
|
|
|
@@ -785,8 +785,8 @@ discard block |
|
|
block discarded – undo |
|
785
|
785
|
$mSig = $decoder->decode($mSig); |
|
786
|
786
|
} |
|
787
|
787
|
|
|
788
|
|
- if (!is_array($mSig) || count($mSig) <= $sigNum) { |
|
789
|
|
- $this->getLogger()->errorLog('XML-RPC: ' . __METHOD__ . ': could not retrieve method signature nr.' . $sigNum . ' from remote server for method ' . $methodName); |
|
|
788
|
+ if (!is_array($mSig) || count($mSig)<=$sigNum) { |
|
|
789
|
+ $this->getLogger()->errorLog('XML-RPC: '.__METHOD__.': could not retrieve method signature nr.'.$sigNum.' from remote server for method '.$methodName); |
|
790
|
790
|
return false; |
|
791
|
791
|
} |
|
792
|
792
|
|
|
@@ -803,11 +803,11 @@ discard block |
|
|
block discarded – undo |
|
803
|
803
|
protected function retrieveMethodHelp($client, $methodName, array $extraOptions = array()) |
|
804
|
804
|
{ |
|
805
|
805
|
$namespace = '\\PhpXmlRpc\\'; |
|
806
|
|
- $reqClass = $namespace . 'Request'; |
|
807
|
|
- $valClass = $namespace . 'Value'; |
|
|
806
|
+ $reqClass = $namespace.'Request'; |
|
|
807
|
+ $valClass = $namespace.'Value'; |
|
808
|
808
|
|
|
809
|
809
|
$debug = isset($extraOptions['debug']) ? ($extraOptions['debug']) : 0; |
|
810
|
|
- $timeout = isset($extraOptions['timeout']) ? (int)$extraOptions['timeout'] : 0; |
|
|
810
|
+ $timeout = isset($extraOptions['timeout']) ? (int) $extraOptions['timeout'] : 0; |
|
811
|
811
|
$protocol = isset($extraOptions['protocol']) ? $extraOptions['protocol'] : ''; |
|
812
|
812
|
|
|
813
|
813
|
$mDesc = ''; |
|
@@ -842,10 +842,10 @@ discard block |
|
|
block discarded – undo |
|
842
|
842
|
$clientClone = clone $client; |
|
843
|
843
|
$function = function() use($clientClone, $methodName, $extraOptions, $mSig) |
|
844
|
844
|
{ |
|
845
|
|
- $timeout = isset($extraOptions['timeout']) ? (int)$extraOptions['timeout'] : 0; |
|
|
845
|
+ $timeout = isset($extraOptions['timeout']) ? (int) $extraOptions['timeout'] : 0; |
|
846
|
846
|
$protocol = isset($extraOptions['protocol']) ? $extraOptions['protocol'] : ''; |
|
847
|
|
- $encodePhpObjects = isset($extraOptions['encode_php_objs']) ? (bool)$extraOptions['encode_php_objs'] : false; |
|
848
|
|
- $decodePhpObjects = isset($extraOptions['decode_php_objs']) ? (bool)$extraOptions['decode_php_objs'] : false; |
|
|
847
|
+ $encodePhpObjects = isset($extraOptions['encode_php_objs']) ? (bool) $extraOptions['encode_php_objs'] : false; |
|
|
848
|
+ $decodePhpObjects = isset($extraOptions['decode_php_objs']) ? (bool) $extraOptions['decode_php_objs'] : false; |
|
849
|
849
|
if (isset($extraOptions['return_on_fault'])) { |
|
850
|
850
|
$decodeFault = true; |
|
851
|
851
|
$faultResponse = $extraOptions['return_on_fault']; |
|
@@ -854,9 +854,9 @@ discard block |
|
|
block discarded – undo |
|
854
|
854
|
} |
|
855
|
855
|
|
|
856
|
856
|
$namespace = '\\PhpXmlRpc\\'; |
|
857
|
|
- $reqClass = $namespace . 'Request'; |
|
858
|
|
- $encoderClass = $namespace . 'Encoder'; |
|
859
|
|
- $valueClass = $namespace . 'Value'; |
|
|
857
|
+ $reqClass = $namespace.'Request'; |
|
|
858
|
+ $encoderClass = $namespace.'Encoder'; |
|
|
859
|
+ $valueClass = $namespace.'Value'; |
|
860
|
860
|
|
|
861
|
861
|
$encoder = new $encoderClass(); |
|
862
|
862
|
$encodeOptions = array(); |
|
@@ -930,13 +930,13 @@ discard block |
|
|
block discarded – undo |
|
930
|
930
|
* |
|
931
|
931
|
* @return string[] keys: source, docstring |
|
932
|
932
|
*/ |
|
933
|
|
- public function buildWrapMethodSource($client, $methodName, array $extraOptions, $newFuncName, $mSig, $mDesc='') |
|
|
933
|
+ public function buildWrapMethodSource($client, $methodName, array $extraOptions, $newFuncName, $mSig, $mDesc = '') |
|
934
|
934
|
{ |
|
935
|
|
- $timeout = isset($extraOptions['timeout']) ? (int)$extraOptions['timeout'] : 0; |
|
|
935
|
+ $timeout = isset($extraOptions['timeout']) ? (int) $extraOptions['timeout'] : 0; |
|
936
|
936
|
$protocol = isset($extraOptions['protocol']) ? $extraOptions['protocol'] : ''; |
|
937
|
|
- $encodePhpObjects = isset($extraOptions['encode_php_objs']) ? (bool)$extraOptions['encode_php_objs'] : false; |
|
938
|
|
- $decodePhpObjects = isset($extraOptions['decode_php_objs']) ? (bool)$extraOptions['decode_php_objs'] : false; |
|
939
|
|
- $clientCopyMode = isset($extraOptions['simple_client_copy']) ? (int)($extraOptions['simple_client_copy']) : 0; |
|
|
937
|
+ $encodePhpObjects = isset($extraOptions['encode_php_objs']) ? (bool) $extraOptions['encode_php_objs'] : false; |
|
|
938
|
+ $decodePhpObjects = isset($extraOptions['decode_php_objs']) ? (bool) $extraOptions['decode_php_objs'] : false; |
|
|
939
|
+ $clientCopyMode = isset($extraOptions['simple_client_copy']) ? (int) ($extraOptions['simple_client_copy']) : 0; |
|
940
|
940
|
$prefix = isset($extraOptions['prefix']) ? $extraOptions['prefix'] : 'xmlrpc'; |
|
941
|
941
|
if (isset($extraOptions['return_on_fault'])) { |
|
942
|
942
|
$decodeFault = true; |
|
@@ -949,7 +949,7 @@ discard block |
|
|
block discarded – undo |
|
949
|
949
|
$namespace = '\\PhpXmlRpc\\'; |
|
950
|
950
|
|
|
951
|
951
|
$code = "function $newFuncName ("; |
|
952
|
|
- if ($clientCopyMode < 2) { |
|
|
952
|
+ if ($clientCopyMode<2) { |
|
953
|
953
|
// client copy mode 0 or 1 == full / partial client copy in emitted code |
|
954
|
954
|
$verbatimClientCopy = !$clientCopyMode; |
|
955
|
955
|
$innerCode = $this->buildClientWrapperCode($client, $verbatimClientCopy, $prefix, $namespace); |
|
@@ -964,7 +964,7 @@ discard block |
|
|
block discarded – undo |
|
964
|
964
|
|
|
965
|
965
|
if ($mDesc != '') { |
|
966
|
966
|
// take care that PHP comment is not terminated unwillingly by method description |
|
967
|
|
- $mDesc = "/**\n* " . str_replace('*/', '* /', $mDesc) . "\n"; |
|
|
967
|
+ $mDesc = "/**\n* ".str_replace('*/', '* /', $mDesc)."\n"; |
|
968
|
968
|
} else { |
|
969
|
969
|
$mDesc = "/**\nFunction $newFuncName\n"; |
|
970
|
970
|
} |
|
@@ -973,7 +973,7 @@ discard block |
|
|
block discarded – undo |
|
973
|
973
|
$innerCode .= "\$encoder = new {$namespace}Encoder();\n"; |
|
974
|
974
|
$plist = array(); |
|
975
|
975
|
$pCount = count($mSig); |
|
976
|
|
- for ($i = 1; $i < $pCount; $i++) { |
|
|
976
|
+ for ($i = 1; $i<$pCount; $i++) { |
|
977
|
977
|
$plist[] = "\$p$i"; |
|
978
|
978
|
$pType = $mSig[$i]; |
|
979
|
979
|
if ($pType == 'i4' || $pType == 'i8' || $pType == 'int' || $pType == 'boolean' || $pType == 'double' || |
|
@@ -989,19 +989,19 @@ discard block |
|
|
block discarded – undo |
|
989
|
989
|
} |
|
990
|
990
|
} |
|
991
|
991
|
$innerCode .= "\$req->addparam(\$p$i);\n"; |
|
992
|
|
- $mDesc .= '* @param ' . $this->xmlrpc2PhpType($pType) . " \$p$i\n"; |
|
|
992
|
+ $mDesc .= '* @param '.$this->xmlrpc2PhpType($pType)." \$p$i\n"; |
|
993
|
993
|
} |
|
994
|
|
- if ($clientCopyMode < 2) { |
|
|
994
|
+ if ($clientCopyMode<2) { |
|
995
|
995
|
$plist[] = '$debug=0'; |
|
996
|
996
|
$mDesc .= "* @param int \$debug when 1 (or 2) will enable debugging of the underlying {$prefix} call (defaults to 0)\n"; |
|
997
|
997
|
} |
|
998
|
998
|
$plist = implode(', ', $plist); |
|
999
|
|
- $mDesc .= "* @return {$namespace}Response|" . $this->xmlrpc2PhpType($mSig[0]) . " (an {$namespace}Response obj instance if call fails)\n*/\n"; |
|
|
999
|
+ $mDesc .= "* @return {$namespace}Response|".$this->xmlrpc2PhpType($mSig[0])." (an {$namespace}Response obj instance if call fails)\n*/\n"; |
|
1000
|
1000
|
|
|
1001
|
1001
|
$innerCode .= "\$res = \${$this_}client->send(\$req, $timeout, '$protocol');\n"; |
|
1002
|
1002
|
if ($decodeFault) { |
|
1003
|
1003
|
if (is_string($faultResponse) && ((strpos($faultResponse, '%faultCode%') !== false) || (strpos($faultResponse, '%faultString%') !== false))) { |
|
1004
|
|
- $respCode = "str_replace(array('%faultCode%', '%faultString%'), array(\$res->faultCode(), \$res->faultString()), '" . str_replace("'", "''", $faultResponse) . "')"; |
|
|
1004
|
+ $respCode = "str_replace(array('%faultCode%', '%faultString%'), array(\$res->faultCode(), \$res->faultString()), '".str_replace("'", "''", $faultResponse)."')"; |
|
1005
|
1005
|
} else { |
|
1006
|
1006
|
$respCode = var_export($faultResponse, true); |
|
1007
|
1007
|
} |
|
@@ -1014,7 +1014,7 @@ discard block |
|
|
block discarded – undo |
|
1014
|
1014
|
$innerCode .= "if (\$res->faultcode()) return $respCode; else return \$encoder->decode(\$res->value());"; |
|
1015
|
1015
|
} |
|
1016
|
1016
|
|
|
1017
|
|
- $code = $code . $plist . ") {\n" . $innerCode . "\n}\n"; |
|
|
1017
|
+ $code = $code.$plist.") {\n".$innerCode."\n}\n"; |
|
1018
|
1018
|
|
|
1019
|
1019
|
return array('source' => $code, 'docstring' => $mDesc); |
|
1020
|
1020
|
} |
|
@@ -1042,24 +1042,24 @@ discard block |
|
|
block discarded – undo |
|
1042
|
1042
|
public function wrapXmlrpcServer($client, $extraOptions = array()) |
|
1043
|
1043
|
{ |
|
1044
|
1044
|
$methodFilter = isset($extraOptions['method_filter']) ? $extraOptions['method_filter'] : ''; |
|
1045
|
|
- $timeout = isset($extraOptions['timeout']) ? (int)$extraOptions['timeout'] : 0; |
|
|
1045
|
+ $timeout = isset($extraOptions['timeout']) ? (int) $extraOptions['timeout'] : 0; |
|
1046
|
1046
|
$protocol = isset($extraOptions['protocol']) ? $extraOptions['protocol'] : ''; |
|
1047
|
1047
|
$newClassName = isset($extraOptions['new_class_name']) ? $extraOptions['new_class_name'] : ''; |
|
1048
|
|
- $encodePhpObjects = isset($extraOptions['encode_php_objs']) ? (bool)$extraOptions['encode_php_objs'] : false; |
|
1049
|
|
- $decodePhpObjects = isset($extraOptions['decode_php_objs']) ? (bool)$extraOptions['decode_php_objs'] : false; |
|
|
1048
|
+ $encodePhpObjects = isset($extraOptions['encode_php_objs']) ? (bool) $extraOptions['encode_php_objs'] : false; |
|
|
1049
|
+ $decodePhpObjects = isset($extraOptions['decode_php_objs']) ? (bool) $extraOptions['decode_php_objs'] : false; |
|
1050
|
1050
|
$verbatimClientCopy = isset($extraOptions['simple_client_copy']) ? !($extraOptions['simple_client_copy']) : true; |
|
1051
|
1051
|
$buildIt = isset($extraOptions['return_source']) ? !($extraOptions['return_source']) : true; |
|
1052
|
1052
|
$prefix = isset($extraOptions['prefix']) ? $extraOptions['prefix'] : 'xmlrpc'; |
|
1053
|
1053
|
$namespace = '\\PhpXmlRpc\\'; |
|
1054
|
1054
|
|
|
1055
|
|
- $reqClass = $namespace . 'Request'; |
|
1056
|
|
- $decoderClass = $namespace . 'Encoder'; |
|
|
1055
|
+ $reqClass = $namespace.'Request'; |
|
|
1056
|
+ $decoderClass = $namespace.'Encoder'; |
|
1057
|
1057
|
|
|
1058
|
1058
|
// retrieve the list of methods |
|
1059
|
1059
|
$req = new $reqClass('system.listMethods'); |
|
1060
|
1060
|
$response = $client->send($req, $timeout, $protocol); |
|
1061
|
1061
|
if ($response->faultCode()) { |
|
1062
|
|
- $this->getLogger()->errorLog('XML-RPC: ' . __METHOD__ . ': could not retrieve method list from remote server'); |
|
|
1062
|
+ $this->getLogger()->errorLog('XML-RPC: '.__METHOD__.': could not retrieve method list from remote server'); |
|
1063
|
1063
|
|
|
1064
|
1064
|
return false; |
|
1065
|
1065
|
} |
|
@@ -1070,7 +1070,7 @@ discard block |
|
|
block discarded – undo |
|
1070
|
1070
|
$mList = $decoder->decode($mList); |
|
1071
|
1071
|
} |
|
1072
|
1072
|
if (!is_array($mList) || !count($mList)) { |
|
1073
|
|
- $this->getLogger()->errorLog('XML-RPC: ' . __METHOD__ . ': could not retrieve meaningful method list from remote server'); |
|
|
1073
|
+ $this->getLogger()->errorLog('XML-RPC: '.__METHOD__.': could not retrieve meaningful method list from remote server'); |
|
1074
|
1074
|
|
|
1075
|
1075
|
return false; |
|
1076
|
1076
|
} |
|
@@ -1079,8 +1079,8 @@ discard block |
|
|
block discarded – undo |
|
1079
|
1079
|
if ($newClassName != '') { |
|
1080
|
1080
|
$xmlrpcClassName = $newClassName; |
|
1081
|
1081
|
} else { |
|
1082
|
|
- $xmlrpcClassName = $prefix . '_' . preg_replace(array('/\./', '/[^a-zA-Z0-9_\x7f-\xff]/'), |
|
1083
|
|
- array('_', ''), $client->server) . '_client'; |
|
|
1082
|
+ $xmlrpcClassName = $prefix.'_'.preg_replace(array('/\./', '/[^a-zA-Z0-9_\x7f-\xff]/'), |
|
|
1083
|
+ array('_', ''), $client->server).'_client'; |
|
1084
|
1084
|
} |
|
1085
|
1085
|
while ($buildIt && class_exists($xmlrpcClassName)) { |
|
1086
|
1086
|
$xmlrpcClassName .= 'x'; |
|
@@ -1111,20 +1111,20 @@ discard block |
|
|
block discarded – undo |
|
1111
|
1111
|
if (!$buildIt) { |
|
1112
|
1112
|
$source .= $methodWrap['docstring']; |
|
1113
|
1113
|
} |
|
1114
|
|
- $source .= $methodWrap['source'] . "\n"; |
|
|
1114
|
+ $source .= $methodWrap['source']."\n"; |
|
1115
|
1115
|
} else { |
|
1116
|
|
- $this->getLogger()->errorLog('XML-RPC: ' . __METHOD__ . ': will not create class method to wrap remote method ' . $mName); |
|
|
1116
|
+ $this->getLogger()->errorLog('XML-RPC: '.__METHOD__.': will not create class method to wrap remote method '.$mName); |
|
1117
|
1117
|
} |
|
1118
|
1118
|
} |
|
1119
|
1119
|
} |
|
1120
|
1120
|
$source .= "}\n"; |
|
1121
|
1121
|
if ($buildIt) { |
|
1122
|
1122
|
$allOK = 0; |
|
1123
|
|
- eval($source . '$allOK=1;'); |
|
|
1123
|
+ eval($source.'$allOK=1;'); |
|
1124
|
1124
|
if ($allOK) { |
|
1125
|
1125
|
return $xmlrpcClassName; |
|
1126
|
1126
|
} else { |
|
1127
|
|
- $this->getLogger()->errorLog('XML-RPC: ' . __METHOD__ . ': could not create class ' . $xmlrpcClassName . ' to wrap remote server ' . $client->server); |
|
|
1127
|
+ $this->getLogger()->errorLog('XML-RPC: '.__METHOD__.': could not create class '.$xmlrpcClassName.' to wrap remote server '.$client->server); |
|
1128
|
1128
|
return false; |
|
1129
|
1129
|
} |
|
1130
|
1130
|
} else { |
|
@@ -1144,8 +1144,8 @@ discard block |
|
|
block discarded – undo |
|
1144
|
1144
|
*/ |
|
1145
|
1145
|
protected function buildClientWrapperCode($client, $verbatimClientCopy, $prefix = 'xmlrpc', $namespace = '\\PhpXmlRpc\\') |
|
1146
|
1146
|
{ |
|
1147
|
|
- $code = "\$client = new {$namespace}Client('" . str_replace(array("\\", "'"), array("\\\\", "\'"), $client->path) . |
|
1148
|
|
- "', '" . str_replace(array("\\", "'"), array("\\\\", "\'"), $client->server) . "', $client->port);\n"; |
|
|
1147
|
+ $code = "\$client = new {$namespace}Client('".str_replace(array("\\", "'"), array("\\\\", "\'"), $client->path). |
|
|
1148
|
+ "', '".str_replace(array("\\", "'"), array("\\\\", "\'"), $client->server)."', $client->port);\n"; |
|
1149
|
1149
|
|
|
1150
|
1150
|
// copy all client fields to the client that will be generated runtime |
|
1151
|
1151
|
// (this provides for future expansion or subclassing of client obj) |