|
@@ -176,20 +176,20 @@ discard block |
|
|
block discarded – undo |
|
176
|
176
|
$callable = explode('::', $callable); |
|
177
|
177
|
} |
|
178
|
178
|
if (is_array($callable)) { |
|
179
|
|
- if (count($callable) < 2 || (!is_string($callable[0]) && !is_object($callable[0]))) { |
|
180
|
|
- $this->getLogger()->error('XML-RPC: ' . __METHOD__ . ': syntax for function to be wrapped is wrong'); |
|
|
179
|
+ if (count($callable)<2 || (!is_string($callable[0]) && !is_object($callable[0]))) { |
|
|
180
|
+ $this->getLogger()->error('XML-RPC: '.__METHOD__.': syntax for function to be wrapped is wrong'); |
|
181
|
181
|
return false; |
|
182
|
182
|
} |
|
183
|
183
|
if (is_string($callable[0])) { |
|
184
|
184
|
$plainFuncName = implode('::', $callable); |
|
185
|
185
|
} elseif (is_object($callable[0])) { |
|
186
|
|
- $plainFuncName = get_class($callable[0]) . '->' . $callable[1]; |
|
|
186
|
+ $plainFuncName = get_class($callable[0]).'->'.$callable[1]; |
|
187
|
187
|
} |
|
188
|
188
|
$exists = method_exists($callable[0], $callable[1]); |
|
189
|
189
|
} else if ($callable instanceof \Closure) { |
|
190
|
190
|
// we do not support creating code which wraps closures, as php does not allow to serialize them |
|
191
|
191
|
if (!$buildIt) { |
|
192
|
|
- $this->getLogger()->error('XML-RPC: ' . __METHOD__ . ': a closure can not be wrapped in generated source code'); |
|
|
192
|
+ $this->getLogger()->error('XML-RPC: '.__METHOD__.': a closure can not be wrapped in generated source code'); |
|
193
|
193
|
return false; |
|
194
|
194
|
} |
|
195
|
195
|
|
|
@@ -201,7 +201,7 @@ discard block |
|
|
block discarded – undo |
|
201
|
201
|
} |
|
202
|
202
|
|
|
203
|
203
|
if (!$exists) { |
|
204
|
|
- $this->getLogger()->error('XML-RPC: ' . __METHOD__ . ': function to be wrapped is not defined: ' . $plainFuncName); |
|
|
204
|
+ $this->getLogger()->error('XML-RPC: '.__METHOD__.': function to be wrapped is not defined: '.$plainFuncName); |
|
205
|
205
|
return false; |
|
206
|
206
|
} |
|
207
|
207
|
|
|
@@ -245,23 +245,23 @@ discard block |
|
|
block discarded – undo |
|
245
|
245
|
if (is_array($callable)) { |
|
246
|
246
|
$func = new \ReflectionMethod($callable[0], $callable[1]); |
|
247
|
247
|
if ($func->isPrivate()) { |
|
248
|
|
- $this->getLogger()->error('XML-RPC: ' . __METHOD__ . ': method to be wrapped is private: ' . $plainFuncName); |
|
|
248
|
+ $this->getLogger()->error('XML-RPC: '.__METHOD__.': method to be wrapped is private: '.$plainFuncName); |
|
249
|
249
|
return false; |
|
250
|
250
|
} |
|
251
|
251
|
if ($func->isProtected()) { |
|
252
|
|
- $this->getLogger()->error('XML-RPC: ' . __METHOD__ . ': method to be wrapped is protected: ' . $plainFuncName); |
|
|
252
|
+ $this->getLogger()->error('XML-RPC: '.__METHOD__.': method to be wrapped is protected: '.$plainFuncName); |
|
253
|
253
|
return false; |
|
254
|
254
|
} |
|
255
|
255
|
if ($func->isConstructor()) { |
|
256
|
|
- $this->getLogger()->error('XML-RPC: ' . __METHOD__ . ': method to be wrapped is the constructor: ' . $plainFuncName); |
|
|
256
|
+ $this->getLogger()->error('XML-RPC: '.__METHOD__.': method to be wrapped is the constructor: '.$plainFuncName); |
|
257
|
257
|
return false; |
|
258
|
258
|
} |
|
259
|
259
|
if ($func->isDestructor()) { |
|
260
|
|
- $this->getLogger()->error('XML-RPC: ' . __METHOD__ . ': method to be wrapped is the destructor: ' . $plainFuncName); |
|
|
260
|
+ $this->getLogger()->error('XML-RPC: '.__METHOD__.': method to be wrapped is the destructor: '.$plainFuncName); |
|
261
|
261
|
return false; |
|
262
|
262
|
} |
|
263
|
263
|
if ($func->isAbstract()) { |
|
264
|
|
- $this->getLogger()->error('XML-RPC: ' . __METHOD__ . ': method to be wrapped is abstract: ' . $plainFuncName); |
|
|
264
|
+ $this->getLogger()->error('XML-RPC: '.__METHOD__.': method to be wrapped is abstract: '.$plainFuncName); |
|
265
|
265
|
return false; |
|
266
|
266
|
} |
|
267
|
267
|
/// @todo add more checks for static vs. nonstatic? |
|
@@ -271,7 +271,7 @@ discard block |
|
|
block discarded – undo |
|
271
|
271
|
if ($func->isInternal()) { |
|
272
|
272
|
/// @todo from PHP 5.1.0 onward, we should be able to use invokeargs instead of getparameters to fully |
|
273
|
273
|
/// reflect internal php functions |
|
274
|
|
- $this->getLogger()->error('XML-RPC: ' . __METHOD__ . ': function to be wrapped is internal: ' . $plainFuncName); |
|
|
274
|
+ $this->getLogger()->error('XML-RPC: '.__METHOD__.': function to be wrapped is internal: '.$plainFuncName); |
|
275
|
275
|
return false; |
|
276
|
276
|
} |
|
277
|
277
|
|
|
@@ -331,7 +331,7 @@ discard block |
|
|
block discarded – undo |
|
331
|
331
|
$i = 0; |
|
332
|
332
|
foreach ($func->getParameters() as $paramObj) { |
|
333
|
333
|
$params[$i] = array(); |
|
334
|
|
- $params[$i]['name'] = '$' . $paramObj->getName(); |
|
|
334
|
+ $params[$i]['name'] = '$'.$paramObj->getName(); |
|
335
|
335
|
$params[$i]['isoptional'] = $paramObj->isOptional(); |
|
336
|
336
|
if (method_exists($paramObj, 'getType')) { |
|
337
|
337
|
$paramType = $paramObj->getType(); |
|
@@ -402,7 +402,7 @@ discard block |
|
|
block discarded – undo |
|
402
|
402
|
// build a signature |
|
403
|
403
|
$sig = array($this->php2XmlrpcType($funcDesc['returns'])); |
|
404
|
404
|
$pSig = array($funcDesc['returnsDocs']); |
|
405
|
|
- for ($i = 0; $i < count($pars); $i++) { |
|
|
405
|
+ for ($i = 0; $i<count($pars); $i++) { |
|
406
|
406
|
$name = strtolower($funcDesc['params'][$i]['name']); |
|
407
|
407
|
if (isset($funcDesc['paramDocs'][$name]['type'])) { |
|
408
|
408
|
$sig[] = $this->php2XmlrpcType($funcDesc['paramDocs'][$name]['type']); |
|
@@ -458,7 +458,7 @@ discard block |
|
|
block discarded – undo |
|
458
|
458
|
} |
|
459
|
459
|
} |
|
460
|
460
|
$numPars = $req->getNumParams(); |
|
461
|
|
- if ($numPars < $minPars || $numPars > $maxPars) { |
|
|
461
|
+ if ($numPars<$minPars || $numPars>$maxPars) { |
|
462
|
462
|
return new $responseClass(0, 3, 'Incorrect parameters passed to method'); |
|
463
|
463
|
} |
|
464
|
464
|
|
|
@@ -472,7 +472,7 @@ discard block |
|
|
block discarded – undo |
|
472
|
472
|
$result = call_user_func_array($callable, $params); |
|
473
|
473
|
|
|
474
|
474
|
/// @todo when namespaces is under PhpXmlRpc, use root-class checking |
|
475
|
|
- if (! is_a($result, $responseClass)) { |
|
|
475
|
+ if (!is_a($result, $responseClass)) { |
|
476
|
476
|
// q: why not do the same for int, float, bool, string? |
|
477
|
477
|
if ($funcDesc['returns'] == Value::$xmlrpcDateTime || $funcDesc['returns'] == Value::$xmlrpcBase64) { |
|
478
|
478
|
$result = new $valueClass($result, $funcDesc['returns']); |
|
@@ -511,9 +511,9 @@ discard block |
|
|
block discarded – undo |
|
511
|
511
|
if ($newFuncName == '') { |
|
512
|
512
|
if (is_array($callable)) { |
|
513
|
513
|
if (is_string($callable[0])) { |
|
514
|
|
- $xmlrpcFuncName = "{$prefix}_" . implode('_', $callable); |
|
|
514
|
+ $xmlrpcFuncName = "{$prefix}_".implode('_', $callable); |
|
515
|
515
|
} else { |
|
516
|
|
- $xmlrpcFuncName = "{$prefix}_" . get_class($callable[0]) . '_' . $callable[1]; |
|
|
516
|
+ $xmlrpcFuncName = "{$prefix}_".get_class($callable[0]).'_'.$callable[1]; |
|
517
|
517
|
} |
|
518
|
518
|
} else { |
|
519
|
519
|
if ($callable instanceof \Closure) { |
|
@@ -545,9 +545,9 @@ discard block |
|
|
block discarded – undo |
|
545
|
545
|
*/ |
|
546
|
546
|
protected function buildWrapFunctionSource($callable, $newFuncName, $extraOptions, $plainFuncName, $funcDesc) |
|
547
|
547
|
{ |
|
548
|
|
- $encodeNulls = isset($extraOptions['encode_nulls']) ? (bool)$extraOptions['encode_nulls'] : false; |
|
549
|
|
- $encodePhpObjects = isset($extraOptions['encode_php_objs']) ? (bool)$extraOptions['encode_php_objs'] : false; |
|
550
|
|
- $decodePhpObjects = isset($extraOptions['decode_php_objs']) ? (bool)$extraOptions['decode_php_objs'] : false; |
|
|
548
|
+ $encodeNulls = isset($extraOptions['encode_nulls']) ? (bool) $extraOptions['encode_nulls'] : false; |
|
|
549
|
+ $encodePhpObjects = isset($extraOptions['encode_php_objs']) ? (bool) $extraOptions['encode_php_objs'] : false; |
|
|
550
|
+ $decodePhpObjects = isset($extraOptions['decode_php_objs']) ? (bool) $extraOptions['decode_php_objs'] : false; |
|
551
|
551
|
$catchWarnings = isset($extraOptions['suppress_warnings']) && $extraOptions['suppress_warnings'] ? '@' : ''; |
|
552
|
552
|
|
|
553
|
553
|
$i = 0; |
|
@@ -582,9 +582,9 @@ discard block |
|
|
block discarded – undo |
|
582
|
582
|
// build body of new function |
|
583
|
583
|
|
|
584
|
584
|
$innerCode = " \$paramCount = \$req->getNumParams();\n"; |
|
585
|
|
- $innerCode .= " if (\$paramCount < $minPars || \$paramCount > $maxPars) return new " . static::$namespace . "Response(0, " . PhpXmlRpc::$xmlrpcerr['incorrect_params'] . ", '" . PhpXmlRpc::$xmlrpcstr['incorrect_params'] . "');\n"; |
|
|
585
|
+ $innerCode .= " if (\$paramCount < $minPars || \$paramCount > $maxPars) return new ".static::$namespace."Response(0, ".PhpXmlRpc::$xmlrpcerr['incorrect_params'].", '".PhpXmlRpc::$xmlrpcstr['incorrect_params']."');\n"; |
|
586
|
586
|
|
|
587
|
|
- $innerCode .= " \$encoder = new " . static::$namespace . "Encoder();\n"; |
|
|
587
|
+ $innerCode .= " \$encoder = new ".static::$namespace."Encoder();\n"; |
|
588
|
588
|
if ($decodePhpObjects) { |
|
589
|
589
|
$innerCode .= " \$params = \$encoder->decode(\$req, array('decode_php_objs'));\n"; |
|
590
|
590
|
} else { |
|
@@ -598,24 +598,24 @@ discard block |
|
|
block discarded – undo |
|
598
|
598
|
static::holdObject($newFuncName, $callable[0]); |
|
599
|
599
|
$class = get_class($callable[0]); |
|
600
|
600
|
if ($class[0] !== '\\') { |
|
601
|
|
- $class = '\\' . $class; |
|
|
601
|
+ $class = '\\'.$class; |
|
602
|
602
|
} |
|
603
|
603
|
$innerCode .= " /// @var $class \$obj\n"; |
|
604
|
604
|
$innerCode .= " \$obj = PhpXmlRpc\\Wrapper::getHeldObject('$newFuncName');\n"; |
|
605
|
|
- $realFuncName = '$obj->' . $callable[1]; |
|
|
605
|
+ $realFuncName = '$obj->'.$callable[1]; |
|
606
|
606
|
} else { |
|
607
|
607
|
$realFuncName = $plainFuncName; |
|
608
|
608
|
} |
|
609
|
609
|
foreach ($parsVariations as $i => $pars) { |
|
610
|
|
- $innerCode .= " if (\$paramCount == " . count($pars) . ") \$retVal = {$catchWarnings}$realFuncName(" . implode(',', $pars) . ");\n"; |
|
611
|
|
- if ($i < (count($parsVariations) - 1)) |
|
|
610
|
+ $innerCode .= " if (\$paramCount == ".count($pars).") \$retVal = {$catchWarnings}$realFuncName(".implode(',', $pars).");\n"; |
|
|
611
|
+ if ($i<(count($parsVariations)-1)) |
|
612
|
612
|
$innerCode .= " else\n"; |
|
613
|
613
|
} |
|
614
|
614
|
/// @todo here we should (could?) check for PhpXmlRpc/Response when dealing with a subclass namespace |
|
615
|
|
- $innerCode .= " if (is_a(\$retVal, '" . static::$namespace . "Response'))\n return \$retVal;\n else\n"; |
|
|
615
|
+ $innerCode .= " if (is_a(\$retVal, '".static::$namespace."Response'))\n return \$retVal;\n else\n"; |
|
616
|
616
|
/// q: why not do the same for int, float, bool, string? |
|
617
|
617
|
if ($funcDesc['returns'] == Value::$xmlrpcDateTime || $funcDesc['returns'] == Value::$xmlrpcBase64) { |
|
618
|
|
- $innerCode .= " return new " . static::$namespace . "Response(new " . static::$namespace . "Value(\$retVal, '{$funcDesc['returns']}'));"; |
|
|
618
|
+ $innerCode .= " return new ".static::$namespace."Response(new ".static::$namespace."Value(\$retVal, '{$funcDesc['returns']}'));"; |
|
619
|
619
|
} else { |
|
620
|
620
|
$encodeOptions = array(); |
|
621
|
621
|
if ($encodeNulls) { |
|
@@ -626,18 +626,18 @@ discard block |
|
|
block discarded – undo |
|
626
|
626
|
} |
|
627
|
627
|
|
|
628
|
628
|
if ($encodeOptions) { |
|
629
|
|
- $innerCode .= " return new " . static::$namespace . "Response(\$encoder->encode(\$retVal, array('" . |
|
630
|
|
- implode("', '", $encodeOptions) . "')));"; |
|
|
629
|
+ $innerCode .= " return new ".static::$namespace."Response(\$encoder->encode(\$retVal, array('". |
|
|
630
|
+ implode("', '", $encodeOptions)."')));"; |
|
631
|
631
|
} else { |
|
632
|
|
- $innerCode .= " return new " . static::$namespace . "Response(\$encoder->encode(\$retVal));"; |
|
|
632
|
+ $innerCode .= " return new ".static::$namespace."Response(\$encoder->encode(\$retVal));"; |
|
633
|
633
|
} |
|
634
|
634
|
} |
|
635
|
635
|
// shall we exclude functions returning by ref? |
|
636
|
636
|
// if ($func->returnsReference()) |
|
637
|
637
|
// return false; |
|
638
|
638
|
|
|
639
|
|
- $code = "/**\n * @param \PhpXmlRpc\Request \$req\n * @return \PhpXmlRpc\Response\n * @throws \\Exception\n */\n" . |
|
640
|
|
- "function $newFuncName(\$req)\n{\n" . $innerCode . "\n}"; |
|
|
639
|
+ $code = "/**\n * @param \PhpXmlRpc\Request \$req\n * @return \PhpXmlRpc\Response\n * @throws \\Exception\n */\n". |
|
|
640
|
+ "function $newFuncName(\$req)\n{\n".$innerCode."\n}"; |
|
641
|
641
|
|
|
642
|
642
|
return $code; |
|
643
|
643
|
} |
|
@@ -697,7 +697,7 @@ discard block |
|
|
block discarded – undo |
|
697
|
697
|
protected function generateMethodNameForClassMethod($className, $classMethod, $extraOptions = array()) |
|
698
|
698
|
{ |
|
699
|
699
|
if (isset($extraOptions['replace_class_name']) && $extraOptions['replace_class_name']) { |
|
700
|
|
- return (isset($extraOptions['prefix']) ? $extraOptions['prefix'] : '') . $classMethod; |
|
|
700
|
+ return (isset($extraOptions['prefix']) ? $extraOptions['prefix'] : '').$classMethod; |
|
701
|
701
|
} |
|
702
|
702
|
|
|
703
|
703
|
if (is_object($className)) { |
|
@@ -705,7 +705,7 @@ discard block |
|
|
block discarded – undo |
|
705
|
705
|
} else { |
|
706
|
706
|
$realClassName = $className; |
|
707
|
707
|
} |
|
708
|
|
- return (isset($extraOptions['prefix']) ? $extraOptions['prefix'] : '') . "$realClassName.$classMethod"; |
|
|
708
|
+ return (isset($extraOptions['prefix']) ? $extraOptions['prefix'] : '')."$realClassName.$classMethod"; |
|
709
|
709
|
} |
|
710
|
710
|
|
|
711
|
711
|
/** |
|
@@ -801,14 +801,14 @@ discard block |
|
|
block discarded – undo |
|
801
|
801
|
*/ |
|
802
|
802
|
protected function retrieveMethodSignature($client, $methodName, array $extraOptions = array()) |
|
803
|
803
|
{ |
|
804
|
|
- $reqClass = static::$namespace . 'Request'; |
|
805
|
|
- $valClass = static::$namespace . 'Value'; |
|
806
|
|
- $decoderClass = static::$namespace . 'Encoder'; |
|
|
804
|
+ $reqClass = static::$namespace.'Request'; |
|
|
805
|
+ $valClass = static::$namespace.'Value'; |
|
|
806
|
+ $decoderClass = static::$namespace.'Encoder'; |
|
807
|
807
|
|
|
808
|
808
|
$debug = isset($extraOptions['debug']) ? ($extraOptions['debug']) : 0; |
|
809
|
|
- $timeout = isset($extraOptions['timeout']) ? (int)$extraOptions['timeout'] : 0; |
|
|
809
|
+ $timeout = isset($extraOptions['timeout']) ? (int) $extraOptions['timeout'] : 0; |
|
810
|
810
|
$protocol = isset($extraOptions['protocol']) ? $extraOptions['protocol'] : ''; |
|
811
|
|
- $sigNum = isset($extraOptions['signum']) ? (int)$extraOptions['signum'] : 0; |
|
|
811
|
+ $sigNum = isset($extraOptions['signum']) ? (int) $extraOptions['signum'] : 0; |
|
812
|
812
|
|
|
813
|
813
|
$req = new $reqClass('system.methodSignature'); |
|
814
|
814
|
$req->addParam(new $valClass($methodName)); |
|
@@ -818,7 +818,7 @@ discard block |
|
|
block discarded – undo |
|
818
|
818
|
$response = $client->send($req, $timeout, $protocol); |
|
819
|
819
|
$client->setDebug($origDebug); |
|
820
|
820
|
if ($response->faultCode()) { |
|
821
|
|
- $this->getLogger()->error('XML-RPC: ' . __METHOD__ . ': could not retrieve method signature from remote server for method ' . $methodName); |
|
|
821
|
+ $this->getLogger()->error('XML-RPC: '.__METHOD__.': could not retrieve method signature from remote server for method '.$methodName); |
|
822
|
822
|
return false; |
|
823
|
823
|
} |
|
824
|
824
|
|
|
@@ -829,8 +829,8 @@ discard block |
|
|
block discarded – undo |
|
829
|
829
|
$mSig = $decoder->decode($mSig); |
|
830
|
830
|
} |
|
831
|
831
|
|
|
832
|
|
- if (!is_array($mSig) || count($mSig) <= $sigNum) { |
|
833
|
|
- $this->getLogger()->error('XML-RPC: ' . __METHOD__ . ': could not retrieve method signature nr.' . $sigNum . ' from remote server for method ' . $methodName); |
|
|
832
|
+ if (!is_array($mSig) || count($mSig)<=$sigNum) { |
|
|
833
|
+ $this->getLogger()->error('XML-RPC: '.__METHOD__.': could not retrieve method signature nr.'.$sigNum.' from remote server for method '.$methodName); |
|
834
|
834
|
return false; |
|
835
|
835
|
} |
|
836
|
836
|
|
|
@@ -845,11 +845,11 @@ discard block |
|
|
block discarded – undo |
|
845
|
845
|
*/ |
|
846
|
846
|
protected function retrieveMethodHelp($client, $methodName, array $extraOptions = array()) |
|
847
|
847
|
{ |
|
848
|
|
- $reqClass = static::$namespace . 'Request'; |
|
849
|
|
- $valClass = static::$namespace . 'Value'; |
|
|
848
|
+ $reqClass = static::$namespace.'Request'; |
|
|
849
|
+ $valClass = static::$namespace.'Value'; |
|
850
|
850
|
|
|
851
|
851
|
$debug = isset($extraOptions['debug']) ? ($extraOptions['debug']) : 0; |
|
852
|
|
- $timeout = isset($extraOptions['timeout']) ? (int)$extraOptions['timeout'] : 0; |
|
|
852
|
+ $timeout = isset($extraOptions['timeout']) ? (int) $extraOptions['timeout'] : 0; |
|
853
|
853
|
$protocol = isset($extraOptions['protocol']) ? $extraOptions['protocol'] : ''; |
|
854
|
854
|
|
|
855
|
855
|
$mDesc = ''; |
|
@@ -886,11 +886,11 @@ discard block |
|
|
block discarded – undo |
|
886
|
886
|
$clientClone = $this->cloneClientForClosure($client); |
|
887
|
887
|
$function = function() use($clientClone, $methodName, $extraOptions, $mSig) |
|
888
|
888
|
{ |
|
889
|
|
- $timeout = isset($extraOptions['timeout']) ? (int)$extraOptions['timeout'] : 0; |
|
|
889
|
+ $timeout = isset($extraOptions['timeout']) ? (int) $extraOptions['timeout'] : 0; |
|
890
|
890
|
$protocol = isset($extraOptions['protocol']) ? $extraOptions['protocol'] : ''; |
|
891
|
|
- $encodePhpObjects = isset($extraOptions['encode_php_objs']) ? (bool)$extraOptions['encode_php_objs'] : false; |
|
892
|
|
- $decodePhpObjects = isset($extraOptions['decode_php_objs']) ? (bool)$extraOptions['decode_php_objs'] : false; |
|
893
|
|
- $encodeNulls = isset($extraOptions['encode_nulls']) ? (bool)$extraOptions['encode_nulls'] : false; |
|
|
891
|
+ $encodePhpObjects = isset($extraOptions['encode_php_objs']) ? (bool) $extraOptions['encode_php_objs'] : false; |
|
|
892
|
+ $decodePhpObjects = isset($extraOptions['decode_php_objs']) ? (bool) $extraOptions['decode_php_objs'] : false; |
|
|
893
|
+ $encodeNulls = isset($extraOptions['encode_nulls']) ? (bool) $extraOptions['encode_nulls'] : false; |
|
894
|
894
|
$throwFault = false; |
|
895
|
895
|
$decodeFault = false; |
|
896
|
896
|
$faultResponse = null; |
|
@@ -901,9 +901,9 @@ discard block |
|
|
block discarded – undo |
|
901
|
901
|
$faultResponse = $extraOptions['return_on_fault']; |
|
902
|
902
|
} |
|
903
|
903
|
|
|
904
|
|
- $reqClass = static::$namespace . 'Request'; |
|
905
|
|
- $encoderClass = static::$namespace . 'Encoder'; |
|
906
|
|
- $valueClass = static::$namespace . 'Value'; |
|
|
904
|
+ $reqClass = static::$namespace.'Request'; |
|
|
905
|
+ $encoderClass = static::$namespace.'Encoder'; |
|
|
906
|
+ $valueClass = static::$namespace.'Value'; |
|
907
|
907
|
|
|
908
|
908
|
$encoder = new $encoderClass(); |
|
909
|
909
|
$encodeOptions = array(); |
|
@@ -985,14 +985,14 @@ discard block |
|
|
block discarded – undo |
|
985
|
985
|
* @param string $mDesc |
|
986
|
986
|
* @return string[] keys: source, docstring |
|
987
|
987
|
*/ |
|
988
|
|
- public function buildWrapMethodSource($client, $methodName, array $extraOptions, $newFuncName, $mSig, $mDesc='') |
|
|
988
|
+ public function buildWrapMethodSource($client, $methodName, array $extraOptions, $newFuncName, $mSig, $mDesc = '') |
|
989
|
989
|
{ |
|
990
|
|
- $timeout = isset($extraOptions['timeout']) ? (int)$extraOptions['timeout'] : 0; |
|
|
990
|
+ $timeout = isset($extraOptions['timeout']) ? (int) $extraOptions['timeout'] : 0; |
|
991
|
991
|
$protocol = isset($extraOptions['protocol']) ? $extraOptions['protocol'] : ''; |
|
992
|
|
- $encodePhpObjects = isset($extraOptions['encode_php_objs']) ? (bool)$extraOptions['encode_php_objs'] : false; |
|
993
|
|
- $decodePhpObjects = isset($extraOptions['decode_php_objs']) ? (bool)$extraOptions['decode_php_objs'] : false; |
|
994
|
|
- $encodeNulls = isset($extraOptions['encode_nulls']) ? (bool)$extraOptions['encode_nulls'] : false; |
|
995
|
|
- $clientCopyMode = isset($extraOptions['simple_client_copy']) ? (int)($extraOptions['simple_client_copy']) : 0; |
|
|
992
|
+ $encodePhpObjects = isset($extraOptions['encode_php_objs']) ? (bool) $extraOptions['encode_php_objs'] : false; |
|
|
993
|
+ $decodePhpObjects = isset($extraOptions['decode_php_objs']) ? (bool) $extraOptions['decode_php_objs'] : false; |
|
|
994
|
+ $encodeNulls = isset($extraOptions['encode_nulls']) ? (bool) $extraOptions['encode_nulls'] : false; |
|
|
995
|
+ $clientCopyMode = isset($extraOptions['simple_client_copy']) ? (int) ($extraOptions['simple_client_copy']) : 0; |
|
996
|
996
|
$prefix = isset($extraOptions['prefix']) ? $extraOptions['prefix'] : static::$prefix; |
|
997
|
997
|
$clientReturnType = isset($extraOptions['client_return_type']) ? $extraOptions['client_return_type'] : $prefix; |
|
998
|
998
|
$throwFault = false; |
|
@@ -1006,10 +1006,10 @@ discard block |
|
|
block discarded – undo |
|
1006
|
1006
|
} |
|
1007
|
1007
|
|
|
1008
|
1008
|
$code = "function $newFuncName("; |
|
1009
|
|
- if ($clientCopyMode < 2) { |
|
|
1009
|
+ if ($clientCopyMode<2) { |
|
1010
|
1010
|
// client copy mode 0 or 1 == full / partial client copy in emitted code |
|
1011
|
1011
|
$verbatimClientCopy = !$clientCopyMode; |
|
1012
|
|
- $innerCode = ' ' . str_replace("\n", "\n ", $this->buildClientWrapperCode($client, $verbatimClientCopy, $clientReturnType, static::$namespace)); |
|
|
1012
|
+ $innerCode = ' '.str_replace("\n", "\n ", $this->buildClientWrapperCode($client, $verbatimClientCopy, $clientReturnType, static::$namespace)); |
|
1013
|
1013
|
$innerCode .= "\$client->setDebug(\$debug);\n"; |
|
1014
|
1014
|
$this_ = ''; |
|
1015
|
1015
|
} else { |
|
@@ -1017,28 +1017,28 @@ discard block |
|
|
block discarded – undo |
|
1017
|
1017
|
$innerCode = ''; |
|
1018
|
1018
|
$this_ = 'this->'; |
|
1019
|
1019
|
} |
|
1020
|
|
- $innerCode .= " \$req = new " . static::$namespace . "Request('$methodName');\n"; |
|
|
1020
|
+ $innerCode .= " \$req = new ".static::$namespace."Request('$methodName');\n"; |
|
1021
|
1021
|
|
|
1022
|
1022
|
if ($mDesc != '') { |
|
1023
|
1023
|
// take care that PHP comment is not terminated unwillingly by method description |
|
1024
|
1024
|
/// @todo according to the spec, method desc can have html in it. We should run it through strip_tags... |
|
1025
|
|
- $mDesc = "/**\n * " . str_replace(array("\n", '*/'), array("\n * ", '* /'), $mDesc) . "\n"; |
|
|
1025
|
+ $mDesc = "/**\n * ".str_replace(array("\n", '*/'), array("\n * ", '* /'), $mDesc)."\n"; |
|
1026
|
1026
|
} else { |
|
1027
|
1027
|
$mDesc = "/**\n * Function $newFuncName.\n"; |
|
1028
|
1028
|
} |
|
1029
|
1029
|
|
|
1030
|
1030
|
// param parsing |
|
1031
|
|
- $innerCode .= " \$encoder = new " . static::$namespace . "Encoder();\n"; |
|
|
1031
|
+ $innerCode .= " \$encoder = new ".static::$namespace."Encoder();\n"; |
|
1032
|
1032
|
$plist = array(); |
|
1033
|
1033
|
$pCount = count($mSig); |
|
1034
|
|
- for ($i = 1; $i < $pCount; $i++) { |
|
|
1034
|
+ for ($i = 1; $i<$pCount; $i++) { |
|
1035
|
1035
|
$plist[] = "\$p$i"; |
|
1036
|
1036
|
$pType = $mSig[$i]; |
|
1037
|
1037
|
if ($pType == 'i4' || $pType == 'i8' || $pType == 'int' || $pType == 'boolean' || $pType == 'double' || |
|
1038
|
1038
|
$pType == 'string' || $pType == 'dateTime.iso8601' || $pType == 'base64' || $pType == 'null' |
|
1039
|
1039
|
) { |
|
1040
|
1040
|
// only build directly xml-rpc values when type is known and scalar |
|
1041
|
|
- $innerCode .= " \$p$i = new " . static::$namespace . "Value(\$p$i, '$pType');\n"; |
|
|
1041
|
+ $innerCode .= " \$p$i = new ".static::$namespace."Value(\$p$i, '$pType');\n"; |
|
1042
|
1042
|
} else { |
|
1043
|
1043
|
if ($encodePhpObjects || $encodeNulls) { |
|
1044
|
1044
|
$encOpts = array(); |
|
@@ -1049,26 +1049,26 @@ discard block |
|
|
block discarded – undo |
|
1049
|
1049
|
$encOpts[] = 'null_extension'; |
|
1050
|
1050
|
} |
|
1051
|
1051
|
|
|
1052
|
|
- $innerCode .= " \$p$i = \$encoder->encode(\$p$i, array( '" . implode("', '", $encOpts) . "'));\n"; |
|
|
1052
|
+ $innerCode .= " \$p$i = \$encoder->encode(\$p$i, array( '".implode("', '", $encOpts)."'));\n"; |
|
1053
|
1053
|
} else { |
|
1054
|
1054
|
$innerCode .= " \$p$i = \$encoder->encode(\$p$i);\n"; |
|
1055
|
1055
|
} |
|
1056
|
1056
|
} |
|
1057
|
1057
|
$innerCode .= " \$req->addParam(\$p$i);\n"; |
|
1058
|
|
- $mDesc .= " * @param " . $this->xmlrpc2PhpType($pType) . " \$p$i\n"; |
|
|
1058
|
+ $mDesc .= " * @param ".$this->xmlrpc2PhpType($pType)." \$p$i\n"; |
|
1059
|
1059
|
} |
|
1060
|
|
- if ($clientCopyMode < 2) { |
|
|
1060
|
+ if ($clientCopyMode<2) { |
|
1061
|
1061
|
$plist[] = '$debug = 0'; |
|
1062
|
1062
|
$mDesc .= " * @param int \$debug when 1 (or 2) will enable debugging of the underlying {$prefix} call (defaults to 0)\n"; |
|
1063
|
1063
|
} |
|
1064
|
1064
|
$plist = implode(', ', $plist); |
|
1065
|
|
- $mDesc .= ' * @return ' . $this->xmlrpc2PhpType($mSig[0]); |
|
|
1065
|
+ $mDesc .= ' * @return '.$this->xmlrpc2PhpType($mSig[0]); |
|
1066
|
1066
|
if ($throwFault) { |
|
1067
|
|
- $mDesc .= "\n * @throws " . (is_string($throwFault) ? $throwFault : '\\PhpXmlRpc\\Exception'); |
|
|
1067
|
+ $mDesc .= "\n * @throws ".(is_string($throwFault) ? $throwFault : '\\PhpXmlRpc\\Exception'); |
|
1068
|
1068
|
} else if ($decodeFault) { |
|
1069
|
|
- $mDesc .= '|' . gettype($faultResponse) . " (a " . gettype($faultResponse) . " if call fails)"; |
|
|
1069
|
+ $mDesc .= '|'.gettype($faultResponse)." (a ".gettype($faultResponse)." if call fails)"; |
|
1070
|
1070
|
} else { |
|
1071
|
|
- $mDesc .= '|' . static::$namespace . "Response (a " . static::$namespace . "Response obj instance if call fails)"; |
|
|
1071
|
+ $mDesc .= '|'.static::$namespace."Response (a ".static::$namespace."Response obj instance if call fails)"; |
|
1072
|
1072
|
} |
|
1073
|
1073
|
$mDesc .= "\n */\n"; |
|
1074
|
1074
|
|
|
@@ -1081,9 +1081,9 @@ discard block |
|
|
block discarded – undo |
|
1081
|
1081
|
$respCode = "throw new $throwFault(\$res->faultString(), \$res->faultCode())"; |
|
1082
|
1082
|
} else if ($decodeFault) { |
|
1083
|
1083
|
if (is_string($faultResponse) && ((strpos($faultResponse, '%faultCode%') !== false) || (strpos($faultResponse, '%faultString%') !== false))) { |
|
1084
|
|
- $respCode = "return str_replace(array('%faultCode%', '%faultString%'), array(\$res->faultCode(), \$res->faultString()), '" . str_replace("'", "''", $faultResponse) . "')"; |
|
|
1084
|
+ $respCode = "return str_replace(array('%faultCode%', '%faultString%'), array(\$res->faultCode(), \$res->faultString()), '".str_replace("'", "''", $faultResponse)."')"; |
|
1085
|
1085
|
} else { |
|
1086
|
|
- $respCode = 'return ' . var_export($faultResponse, true); |
|
|
1086
|
+ $respCode = 'return '.var_export($faultResponse, true); |
|
1087
|
1087
|
} |
|
1088
|
1088
|
} else { |
|
1089
|
1089
|
$respCode = 'return $res'; |
|
@@ -1094,7 +1094,7 @@ discard block |
|
|
block discarded – undo |
|
1094
|
1094
|
$innerCode .= " if (\$res->faultCode()) $respCode; else return \$encoder->decode(\$res->value());"; |
|
1095
|
1095
|
} |
|
1096
|
1096
|
|
|
1097
|
|
- $code = $code . $plist . ")\n{\n" . $innerCode . "\n}\n"; |
|
|
1097
|
+ $code = $code.$plist.")\n{\n".$innerCode."\n}\n"; |
|
1098
|
1098
|
|
|
1099
|
1099
|
return array('source' => $code, 'docstring' => $mDesc); |
|
1100
|
1100
|
} |
|
@@ -1124,27 +1124,27 @@ discard block |
|
|
block discarded – undo |
|
1124
|
1124
|
public function wrapXmlrpcServer($client, $extraOptions = array()) |
|
1125
|
1125
|
{ |
|
1126
|
1126
|
$methodFilter = isset($extraOptions['method_filter']) ? $extraOptions['method_filter'] : ''; |
|
1127
|
|
- $timeout = isset($extraOptions['timeout']) ? (int)$extraOptions['timeout'] : 0; |
|
|
1127
|
+ $timeout = isset($extraOptions['timeout']) ? (int) $extraOptions['timeout'] : 0; |
|
1128
|
1128
|
$protocol = isset($extraOptions['protocol']) ? $extraOptions['protocol'] : ''; |
|
1129
|
1129
|
$newClassName = isset($extraOptions['new_class_name']) ? $extraOptions['new_class_name'] : ''; |
|
1130
|
|
- $encodeNulls = isset($extraOptions['encode_nulls']) ? (bool)$extraOptions['encode_nulls'] : false; |
|
1131
|
|
- $encodePhpObjects = isset($extraOptions['encode_php_objs']) ? (bool)$extraOptions['encode_php_objs'] : false; |
|
1132
|
|
- $decodePhpObjects = isset($extraOptions['decode_php_objs']) ? (bool)$extraOptions['decode_php_objs'] : false; |
|
|
1130
|
+ $encodeNulls = isset($extraOptions['encode_nulls']) ? (bool) $extraOptions['encode_nulls'] : false; |
|
|
1131
|
+ $encodePhpObjects = isset($extraOptions['encode_php_objs']) ? (bool) $extraOptions['encode_php_objs'] : false; |
|
|
1132
|
+ $decodePhpObjects = isset($extraOptions['decode_php_objs']) ? (bool) $extraOptions['decode_php_objs'] : false; |
|
1133
|
1133
|
$verbatimClientCopy = isset($extraOptions['simple_client_copy']) ? !($extraOptions['simple_client_copy']) : true; |
|
1134
|
|
- $throwOnFault = isset($extraOptions['throw_on_fault']) ? (bool)$extraOptions['throw_on_fault'] : false; |
|
|
1134
|
+ $throwOnFault = isset($extraOptions['throw_on_fault']) ? (bool) $extraOptions['throw_on_fault'] : false; |
|
1135
|
1135
|
$buildIt = isset($extraOptions['return_source']) ? !($extraOptions['return_source']) : true; |
|
1136
|
1136
|
$prefix = isset($extraOptions['prefix']) ? $extraOptions['prefix'] : static::$prefix; |
|
1137
|
1137
|
$clientReturnType = isset($extraOptions['client_return_type']) ? $extraOptions['client_return_type'] : $prefix; |
|
1138
|
1138
|
|
|
1139
|
|
- $reqClass = static::$namespace . 'Request'; |
|
1140
|
|
- $decoderClass = static::$namespace . 'Encoder'; |
|
|
1139
|
+ $reqClass = static::$namespace.'Request'; |
|
|
1140
|
+ $decoderClass = static::$namespace.'Encoder'; |
|
1141
|
1141
|
|
|
1142
|
1142
|
// retrieve the list of methods |
|
1143
|
1143
|
$req = new $reqClass('system.listMethods'); |
|
1144
|
1144
|
/// @todo move setting of timeout, protocol to outside the send() call |
|
1145
|
1145
|
$response = $client->send($req, $timeout, $protocol); |
|
1146
|
1146
|
if ($response->faultCode()) { |
|
1147
|
|
- $this->getLogger()->error('XML-RPC: ' . __METHOD__ . ': could not retrieve method list from remote server'); |
|
|
1147
|
+ $this->getLogger()->error('XML-RPC: '.__METHOD__.': could not retrieve method list from remote server'); |
|
1148
|
1148
|
|
|
1149
|
1149
|
return false; |
|
1150
|
1150
|
} |
|
@@ -1155,7 +1155,7 @@ discard block |
|
|
block discarded – undo |
|
1155
|
1155
|
$mList = $decoder->decode($mList); |
|
1156
|
1156
|
} |
|
1157
|
1157
|
if (!is_array($mList) || !count($mList)) { |
|
1158
|
|
- $this->getLogger()->error('XML-RPC: ' . __METHOD__ . ': could not retrieve meaningful method list from remote server'); |
|
|
1158
|
+ $this->getLogger()->error('XML-RPC: '.__METHOD__.': could not retrieve meaningful method list from remote server'); |
|
1159
|
1159
|
|
|
1160
|
1160
|
return false; |
|
1161
|
1161
|
} |
|
@@ -1165,8 +1165,8 @@ discard block |
|
|
block discarded – undo |
|
1165
|
1165
|
$xmlrpcClassName = $newClassName; |
|
1166
|
1166
|
} else { |
|
1167
|
1167
|
/// @todo direct access to $client->server is now deprecated |
|
1168
|
|
- $xmlrpcClassName = $prefix . '_' . preg_replace(array('/\./', '/[^a-zA-Z0-9_\x7f-\xff]/'), array('_', ''), |
|
1169
|
|
- $client->server) . '_client'; |
|
|
1168
|
+ $xmlrpcClassName = $prefix.'_'.preg_replace(array('/\./', '/[^a-zA-Z0-9_\x7f-\xff]/'), array('_', ''), |
|
|
1169
|
+ $client->server).'_client'; |
|
1170
|
1170
|
} |
|
1171
|
1171
|
while ($buildIt && class_exists($xmlrpcClassName)) { |
|
1172
|
1172
|
$xmlrpcClassName .= 'x'; |
|
@@ -1174,7 +1174,7 @@ discard block |
|
|
block discarded – undo |
|
1174
|
1174
|
|
|
1175
|
1175
|
$source = "class $xmlrpcClassName\n{\n public \$client;\n\n"; |
|
1176
|
1176
|
$source .= " function __construct()\n {\n"; |
|
1177
|
|
- $source .= ' ' . str_replace("\n", "\n ", $this->buildClientWrapperCode($client, $verbatimClientCopy, $clientReturnType, static::$namespace)); |
|
|
1177
|
+ $source .= ' '.str_replace("\n", "\n ", $this->buildClientWrapperCode($client, $verbatimClientCopy, $clientReturnType, static::$namespace)); |
|
1178
|
1178
|
$source .= "\$this->client = \$client;\n }\n\n"; |
|
1179
|
1179
|
$opts = array( |
|
1180
|
1180
|
'return_source' => true, |
|
@@ -1197,28 +1197,28 @@ discard block |
|
|
block discarded – undo |
|
1197
|
1197
|
$methodWrap = $this->wrapXmlrpcMethod($client, $mName, $opts); |
|
1198
|
1198
|
if ($methodWrap) { |
|
1199
|
1199
|
if ($buildIt) { |
|
1200
|
|
- $source .= $methodWrap['source'] . "\n"; |
|
|
1200
|
+ $source .= $methodWrap['source']."\n"; |
|
1201
|
1201
|
|
|
1202
|
1202
|
} else { |
|
1203
|
|
- $source .= ' ' . str_replace("\n", "\n ", $methodWrap['docstring']); |
|
1204
|
|
- $source .= str_replace("\n", "\n ", $methodWrap['source']). "\n"; |
|
|
1203
|
+ $source .= ' '.str_replace("\n", "\n ", $methodWrap['docstring']); |
|
|
1204
|
+ $source .= str_replace("\n", "\n ", $methodWrap['source'])."\n"; |
|
1205
|
1205
|
} |
|
1206
|
1206
|
|
|
1207
|
1207
|
} else { |
|
1208
|
|
- $this->getLogger()->error('XML-RPC: ' . __METHOD__ . ': will not create class method to wrap remote method ' . $mName); |
|
|
1208
|
+ $this->getLogger()->error('XML-RPC: '.__METHOD__.': will not create class method to wrap remote method '.$mName); |
|
1209
|
1209
|
} |
|
1210
|
1210
|
} |
|
1211
|
1211
|
} |
|
1212
|
1212
|
$source .= "}\n"; |
|
1213
|
1213
|
if ($buildIt) { |
|
1214
|
1214
|
$allOK = 0; |
|
1215
|
|
- eval($source . '$allOK=1;'); |
|
|
1215
|
+ eval($source.'$allOK=1;'); |
|
1216
|
1216
|
if ($allOK) { |
|
1217
|
1217
|
return $xmlrpcClassName; |
|
1218
|
1218
|
} else { |
|
1219
|
1219
|
/// @todo direct access to $client->server is now deprecated |
|
1220
|
|
- $this->getLogger()->error('XML-RPC: ' . __METHOD__ . ': could not create class ' . $xmlrpcClassName . |
|
1221
|
|
- ' to wrap remote server ' . $client->server); |
|
|
1220
|
+ $this->getLogger()->error('XML-RPC: '.__METHOD__.': could not create class '.$xmlrpcClassName. |
|
|
1221
|
+ ' to wrap remote server '.$client->server); |
|
1222
|
1222
|
return false; |
|
1223
|
1223
|
} |
|
1224
|
1224
|
} else { |
|
@@ -1237,7 +1237,7 @@ discard block |
|
|
block discarded – undo |
|
1237
|
1237
|
*/ |
|
1238
|
1238
|
protected function buildClientWrapperCode($client, $verbatimClientCopy, $prefix = 'xmlrpc', $namespace = '\\PhpXmlRpc\\') |
|
1239
|
1239
|
{ |
|
1240
|
|
- $code = "\$client = new {$namespace}Client('" . str_replace(array("\\", "'"), array("\\\\", "\'"), $client->getUrl()) . |
|
|
1240
|
+ $code = "\$client = new {$namespace}Client('".str_replace(array("\\", "'"), array("\\\\", "\'"), $client->getUrl()). |
|
1241
|
1241
|
"');\n"; |
|
1242
|
1242
|
|
|
1243
|
1243
|
// copy all client fields to the client that will be generated runtime |