|
@@ -179,20 +179,20 @@ discard block |
|
|
block discarded – undo |
|
179
|
179
|
$callable = explode('::', $callable); |
|
180
|
180
|
} |
|
181
|
181
|
if (is_array($callable)) { |
|
182
|
|
- if (count($callable) < 2 || (!is_string($callable[0]) && !is_object($callable[0]))) { |
|
183
|
|
- $this->getLogger()->error('XML-RPC: ' . __METHOD__ . ': syntax for function to be wrapped is wrong'); |
|
|
182
|
+ if (count($callable)<2 || (!is_string($callable[0]) && !is_object($callable[0]))) { |
|
|
183
|
+ $this->getLogger()->error('XML-RPC: '.__METHOD__.': syntax for function to be wrapped is wrong'); |
|
184
|
184
|
return false; |
|
185
|
185
|
} |
|
186
|
186
|
if (is_string($callable[0])) { |
|
187
|
187
|
$plainFuncName = implode('::', $callable); |
|
188
|
188
|
} elseif (is_object($callable[0])) { |
|
189
|
|
- $plainFuncName = get_class($callable[0]) . '->' . $callable[1]; |
|
|
189
|
+ $plainFuncName = get_class($callable[0]).'->'.$callable[1]; |
|
190
|
190
|
} |
|
191
|
191
|
$exists = method_exists($callable[0], $callable[1]); |
|
192
|
192
|
} else if ($callable instanceof \Closure) { |
|
193
|
193
|
// we do not support creating code which wraps closures, as php does not allow to serialize them |
|
194
|
194
|
if (!$buildIt) { |
|
195
|
|
- $this->getLogger()->error('XML-RPC: ' . __METHOD__ . ': a closure can not be wrapped in generated source code'); |
|
|
195
|
+ $this->getLogger()->error('XML-RPC: '.__METHOD__.': a closure can not be wrapped in generated source code'); |
|
196
|
196
|
return false; |
|
197
|
197
|
} |
|
198
|
198
|
|
|
@@ -204,7 +204,7 @@ discard block |
|
|
block discarded – undo |
|
204
|
204
|
} |
|
205
|
205
|
|
|
206
|
206
|
if (!$exists) { |
|
207
|
|
- $this->getLogger()->error('XML-RPC: ' . __METHOD__ . ': function to be wrapped is not defined: ' . $plainFuncName); |
|
|
207
|
+ $this->getLogger()->error('XML-RPC: '.__METHOD__.': function to be wrapped is not defined: '.$plainFuncName); |
|
208
|
208
|
return false; |
|
209
|
209
|
} |
|
210
|
210
|
|
|
@@ -248,23 +248,23 @@ discard block |
|
|
block discarded – undo |
|
248
|
248
|
if (is_array($callable)) { |
|
249
|
249
|
$func = new \ReflectionMethod($callable[0], $callable[1]); |
|
250
|
250
|
if ($func->isPrivate()) { |
|
251
|
|
- $this->getLogger()->error('XML-RPC: ' . __METHOD__ . ': method to be wrapped is private: ' . $plainFuncName); |
|
|
251
|
+ $this->getLogger()->error('XML-RPC: '.__METHOD__.': method to be wrapped is private: '.$plainFuncName); |
|
252
|
252
|
return false; |
|
253
|
253
|
} |
|
254
|
254
|
if ($func->isProtected()) { |
|
255
|
|
- $this->getLogger()->error('XML-RPC: ' . __METHOD__ . ': method to be wrapped is protected: ' . $plainFuncName); |
|
|
255
|
+ $this->getLogger()->error('XML-RPC: '.__METHOD__.': method to be wrapped is protected: '.$plainFuncName); |
|
256
|
256
|
return false; |
|
257
|
257
|
} |
|
258
|
258
|
if ($func->isConstructor()) { |
|
259
|
|
- $this->getLogger()->error('XML-RPC: ' . __METHOD__ . ': method to be wrapped is the constructor: ' . $plainFuncName); |
|
|
259
|
+ $this->getLogger()->error('XML-RPC: '.__METHOD__.': method to be wrapped is the constructor: '.$plainFuncName); |
|
260
|
260
|
return false; |
|
261
|
261
|
} |
|
262
|
262
|
if ($func->isDestructor()) { |
|
263
|
|
- $this->getLogger()->error('XML-RPC: ' . __METHOD__ . ': method to be wrapped is the destructor: ' . $plainFuncName); |
|
|
263
|
+ $this->getLogger()->error('XML-RPC: '.__METHOD__.': method to be wrapped is the destructor: '.$plainFuncName); |
|
264
|
264
|
return false; |
|
265
|
265
|
} |
|
266
|
266
|
if ($func->isAbstract()) { |
|
267
|
|
- $this->getLogger()->error('XML-RPC: ' . __METHOD__ . ': method to be wrapped is abstract: ' . $plainFuncName); |
|
|
267
|
+ $this->getLogger()->error('XML-RPC: '.__METHOD__.': method to be wrapped is abstract: '.$plainFuncName); |
|
268
|
268
|
return false; |
|
269
|
269
|
} |
|
270
|
270
|
/// @todo add more checks for static vs. nonstatic? |
|
@@ -274,7 +274,7 @@ discard block |
|
|
block discarded – undo |
|
274
|
274
|
if ($func->isInternal()) { |
|
275
|
275
|
/// @todo from PHP 5.1.0 onward, we should be able to use invokeargs instead of getparameters to fully |
|
276
|
276
|
/// reflect internal php functions |
|
277
|
|
- $this->getLogger()->error('XML-RPC: ' . __METHOD__ . ': function to be wrapped is internal: ' . $plainFuncName); |
|
|
277
|
+ $this->getLogger()->error('XML-RPC: '.__METHOD__.': function to be wrapped is internal: '.$plainFuncName); |
|
278
|
278
|
return false; |
|
279
|
279
|
} |
|
280
|
280
|
|
|
@@ -334,7 +334,7 @@ discard block |
|
|
block discarded – undo |
|
334
|
334
|
$i = 0; |
|
335
|
335
|
foreach ($func->getParameters() as $paramObj) { |
|
336
|
336
|
$params[$i] = array(); |
|
337
|
|
- $params[$i]['name'] = '$' . $paramObj->getName(); |
|
|
337
|
+ $params[$i]['name'] = '$'.$paramObj->getName(); |
|
338
|
338
|
$params[$i]['isoptional'] = $paramObj->isOptional(); |
|
339
|
339
|
if (method_exists($paramObj, 'getType')) { |
|
340
|
340
|
$paramType = $paramObj->getType(); |
|
@@ -405,7 +405,7 @@ discard block |
|
|
block discarded – undo |
|
405
|
405
|
// build a signature |
|
406
|
406
|
$sig = array($this->php2XmlrpcType($funcDesc['returns'])); |
|
407
|
407
|
$pSig = array($funcDesc['returnsDocs']); |
|
408
|
|
- for ($i = 0; $i < count($pars); $i++) { |
|
|
408
|
+ for ($i = 0; $i<count($pars); $i++) { |
|
409
|
409
|
$name = strtolower($funcDesc['params'][$i]['name']); |
|
410
|
410
|
if (isset($funcDesc['paramDocs'][$name]['type'])) { |
|
411
|
411
|
$sig[] = $this->php2XmlrpcType($funcDesc['paramDocs'][$name]['type']); |
|
@@ -462,7 +462,7 @@ discard block |
|
|
block discarded – undo |
|
462
|
462
|
} |
|
463
|
463
|
} |
|
464
|
464
|
$numPars = $req->getNumParams(); |
|
465
|
|
- if ($numPars < $minPars || $numPars > $maxPars) { |
|
|
465
|
+ if ($numPars<$minPars || $numPars>$maxPars) { |
|
466
|
466
|
return new $responseClass(0, 3, 'Incorrect parameters passed to method'); |
|
467
|
467
|
} |
|
468
|
468
|
|
|
@@ -475,7 +475,7 @@ discard block |
|
|
block discarded – undo |
|
475
|
475
|
|
|
476
|
476
|
$result = call_user_func_array($callable, $params); |
|
477
|
477
|
|
|
478
|
|
- if (! is_a($result, $allowedResponseClass)) { |
|
|
478
|
+ if (!is_a($result, $allowedResponseClass)) { |
|
479
|
479
|
// q: why not do the same for int, float, bool, string? |
|
480
|
480
|
if ($funcDesc['returns'] == Value::$xmlrpcDateTime || $funcDesc['returns'] == Value::$xmlrpcBase64) { |
|
481
|
481
|
$result = new $valueClass($result, $funcDesc['returns']); |
|
@@ -514,9 +514,9 @@ discard block |
|
|
block discarded – undo |
|
514
|
514
|
if ($newFuncName == '') { |
|
515
|
515
|
if (is_array($callable)) { |
|
516
|
516
|
if (is_string($callable[0])) { |
|
517
|
|
- $xmlrpcFuncName = "{$prefix}_" . implode('_', $callable); |
|
|
517
|
+ $xmlrpcFuncName = "{$prefix}_".implode('_', $callable); |
|
518
|
518
|
} else { |
|
519
|
|
- $xmlrpcFuncName = "{$prefix}_" . get_class($callable[0]) . '_' . $callable[1]; |
|
|
519
|
+ $xmlrpcFuncName = "{$prefix}_".get_class($callable[0]).'_'.$callable[1]; |
|
520
|
520
|
} |
|
521
|
521
|
} else { |
|
522
|
522
|
if ($callable instanceof \Closure) { |
|
@@ -548,9 +548,9 @@ discard block |
|
|
block discarded – undo |
|
548
|
548
|
*/ |
|
549
|
549
|
protected function buildWrapFunctionSource($callable, $newFuncName, $extraOptions, $plainFuncName, $funcDesc) |
|
550
|
550
|
{ |
|
551
|
|
- $encodeNulls = isset($extraOptions['encode_nulls']) ? (bool)$extraOptions['encode_nulls'] : false; |
|
552
|
|
- $encodePhpObjects = isset($extraOptions['encode_php_objs']) ? (bool)$extraOptions['encode_php_objs'] : false; |
|
553
|
|
- $decodePhpObjects = isset($extraOptions['decode_php_objs']) ? (bool)$extraOptions['decode_php_objs'] : false; |
|
|
551
|
+ $encodeNulls = isset($extraOptions['encode_nulls']) ? (bool) $extraOptions['encode_nulls'] : false; |
|
|
552
|
+ $encodePhpObjects = isset($extraOptions['encode_php_objs']) ? (bool) $extraOptions['encode_php_objs'] : false; |
|
|
553
|
+ $decodePhpObjects = isset($extraOptions['decode_php_objs']) ? (bool) $extraOptions['decode_php_objs'] : false; |
|
554
|
554
|
$catchWarnings = isset($extraOptions['suppress_warnings']) && $extraOptions['suppress_warnings'] ? '@' : ''; |
|
555
|
555
|
|
|
556
|
556
|
$i = 0; |
|
@@ -585,9 +585,9 @@ discard block |
|
|
block discarded – undo |
|
585
|
585
|
// build body of new function |
|
586
|
586
|
|
|
587
|
587
|
$innerCode = " \$paramCount = \$req->getNumParams();\n"; |
|
588
|
|
- $innerCode .= " if (\$paramCount < $minPars || \$paramCount > $maxPars) return new " . static::$namespace . "Response(0, " . PhpXmlRpc::$xmlrpcerr['incorrect_params'] . ", '" . PhpXmlRpc::$xmlrpcstr['incorrect_params'] . "');\n"; |
|
|
588
|
+ $innerCode .= " if (\$paramCount < $minPars || \$paramCount > $maxPars) return new ".static::$namespace."Response(0, ".PhpXmlRpc::$xmlrpcerr['incorrect_params'].", '".PhpXmlRpc::$xmlrpcstr['incorrect_params']."');\n"; |
|
589
|
589
|
|
|
590
|
|
- $innerCode .= " \$encoder = new " . static::$namespace . "Encoder();\n"; |
|
|
590
|
+ $innerCode .= " \$encoder = new ".static::$namespace."Encoder();\n"; |
|
591
|
591
|
if ($decodePhpObjects) { |
|
592
|
592
|
$innerCode .= " \$params = \$encoder->decode(\$req, array('decode_php_objs'));\n"; |
|
593
|
593
|
} else { |
|
@@ -601,24 +601,24 @@ discard block |
|
|
block discarded – undo |
|
601
|
601
|
static::holdObject($newFuncName, $callable[0]); |
|
602
|
602
|
$class = get_class($callable[0]); |
|
603
|
603
|
if ($class[0] !== '\\') { |
|
604
|
|
- $class = '\\' . $class; |
|
|
604
|
+ $class = '\\'.$class; |
|
605
|
605
|
} |
|
606
|
606
|
$innerCode .= " /// @var $class \$obj\n"; |
|
607
|
|
- $innerCode .= " \$obj = " . static::$namespace . "Wrapper::getHeldObject('$newFuncName');\n"; |
|
608
|
|
- $realFuncName = '$obj->' . $callable[1]; |
|
|
607
|
+ $innerCode .= " \$obj = ".static::$namespace."Wrapper::getHeldObject('$newFuncName');\n"; |
|
|
608
|
+ $realFuncName = '$obj->'.$callable[1]; |
|
609
|
609
|
} else { |
|
610
|
610
|
$realFuncName = $plainFuncName; |
|
611
|
611
|
} |
|
612
|
612
|
foreach ($parsVariations as $i => $pars) { |
|
613
|
|
- $innerCode .= " if (\$paramCount == " . count($pars) . ") \$retVal = {$catchWarnings}$realFuncName(" . implode(',', $pars) . ");\n"; |
|
614
|
|
- if ($i < (count($parsVariations) - 1)) |
|
|
613
|
+ $innerCode .= " if (\$paramCount == ".count($pars).") \$retVal = {$catchWarnings}$realFuncName(".implode(',', $pars).");\n"; |
|
|
614
|
+ if ($i<(count($parsVariations)-1)) |
|
615
|
615
|
$innerCode .= " else\n"; |
|
616
|
616
|
} |
|
617
|
|
- $allowedResponseClass = static::$allowedResponseClass != '' ? static::$allowedResponseClass : static::$namespace . 'Response'; |
|
618
|
|
- $innerCode .= " if (is_a(\$retVal, '" . $allowedResponseClass . "'))\n return \$retVal;\n else\n"; |
|
|
617
|
+ $allowedResponseClass = static::$allowedResponseClass != '' ? static::$allowedResponseClass : static::$namespace.'Response'; |
|
|
618
|
+ $innerCode .= " if (is_a(\$retVal, '".$allowedResponseClass."'))\n return \$retVal;\n else\n"; |
|
619
|
619
|
/// q: why not do the same for int, float, bool, string? |
|
620
|
620
|
if ($funcDesc['returns'] == Value::$xmlrpcDateTime || $funcDesc['returns'] == Value::$xmlrpcBase64) { |
|
621
|
|
- $innerCode .= " return new " . static::$namespace . "Response(new " . static::$namespace . "Value(\$retVal, '{$funcDesc['returns']}'));"; |
|
|
621
|
+ $innerCode .= " return new ".static::$namespace."Response(new ".static::$namespace."Value(\$retVal, '{$funcDesc['returns']}'));"; |
|
622
|
622
|
} else { |
|
623
|
623
|
$encodeOptions = array(); |
|
624
|
624
|
if ($encodeNulls) { |
|
@@ -629,18 +629,18 @@ discard block |
|
|
block discarded – undo |
|
629
|
629
|
} |
|
630
|
630
|
|
|
631
|
631
|
if ($encodeOptions) { |
|
632
|
|
- $innerCode .= " return new " . static::$namespace . "Response(\$encoder->encode(\$retVal, array('" . |
|
633
|
|
- implode("', '", $encodeOptions) . "')));"; |
|
|
632
|
+ $innerCode .= " return new ".static::$namespace."Response(\$encoder->encode(\$retVal, array('". |
|
|
633
|
+ implode("', '", $encodeOptions)."')));"; |
|
634
|
634
|
} else { |
|
635
|
|
- $innerCode .= " return new " . static::$namespace . "Response(\$encoder->encode(\$retVal));"; |
|
|
635
|
+ $innerCode .= " return new ".static::$namespace."Response(\$encoder->encode(\$retVal));"; |
|
636
|
636
|
} |
|
637
|
637
|
} |
|
638
|
638
|
// shall we exclude functions returning by ref? |
|
639
|
639
|
// if ($func->returnsReference()) |
|
640
|
640
|
// return false; |
|
641
|
641
|
|
|
642
|
|
- $code = "/**\n * @param \PhpXmlRpc\Request \$req\n * @return \PhpXmlRpc\Response\n * @throws \\Exception\n */\n" . |
|
643
|
|
- "function $newFuncName(\$req)\n{\n" . $innerCode . "\n}"; |
|
|
642
|
+ $code = "/**\n * @param \PhpXmlRpc\Request \$req\n * @return \PhpXmlRpc\Response\n * @throws \\Exception\n */\n". |
|
|
643
|
+ "function $newFuncName(\$req)\n{\n".$innerCode."\n}"; |
|
644
|
644
|
|
|
645
|
645
|
return $code; |
|
646
|
646
|
} |
|
@@ -700,7 +700,7 @@ discard block |
|
|
block discarded – undo |
|
700
|
700
|
protected function generateMethodNameForClassMethod($className, $classMethod, $extraOptions = array()) |
|
701
|
701
|
{ |
|
702
|
702
|
if (isset($extraOptions['replace_class_name']) && $extraOptions['replace_class_name']) { |
|
703
|
|
- return (isset($extraOptions['prefix']) ? $extraOptions['prefix'] : '') . $classMethod; |
|
|
703
|
+ return (isset($extraOptions['prefix']) ? $extraOptions['prefix'] : '').$classMethod; |
|
704
|
704
|
} |
|
705
|
705
|
|
|
706
|
706
|
if (is_object($className)) { |
|
@@ -708,7 +708,7 @@ discard block |
|
|
block discarded – undo |
|
708
|
708
|
} else { |
|
709
|
709
|
$realClassName = $className; |
|
710
|
710
|
} |
|
711
|
|
- return (isset($extraOptions['prefix']) ? $extraOptions['prefix'] : '') . "$realClassName.$classMethod"; |
|
|
711
|
+ return (isset($extraOptions['prefix']) ? $extraOptions['prefix'] : '')."$realClassName.$classMethod"; |
|
712
|
712
|
} |
|
713
|
713
|
|
|
714
|
714
|
/** |
|
@@ -804,14 +804,14 @@ discard block |
|
|
block discarded – undo |
|
804
|
804
|
*/ |
|
805
|
805
|
protected function retrieveMethodSignature($client, $methodName, array $extraOptions = array()) |
|
806
|
806
|
{ |
|
807
|
|
- $reqClass = static::$namespace . 'Request'; |
|
808
|
|
- $valClass = static::$namespace . 'Value'; |
|
809
|
|
- $decoderClass = static::$namespace . 'Encoder'; |
|
|
807
|
+ $reqClass = static::$namespace.'Request'; |
|
|
808
|
+ $valClass = static::$namespace.'Value'; |
|
|
809
|
+ $decoderClass = static::$namespace.'Encoder'; |
|
810
|
810
|
|
|
811
|
811
|
$debug = isset($extraOptions['debug']) ? ($extraOptions['debug']) : 0; |
|
812
|
|
- $timeout = isset($extraOptions['timeout']) ? (int)$extraOptions['timeout'] : 0; |
|
|
812
|
+ $timeout = isset($extraOptions['timeout']) ? (int) $extraOptions['timeout'] : 0; |
|
813
|
813
|
$protocol = isset($extraOptions['protocol']) ? $extraOptions['protocol'] : ''; |
|
814
|
|
- $sigNum = isset($extraOptions['signum']) ? (int)$extraOptions['signum'] : 0; |
|
|
814
|
+ $sigNum = isset($extraOptions['signum']) ? (int) $extraOptions['signum'] : 0; |
|
815
|
815
|
|
|
816
|
816
|
$req = new $reqClass('system.methodSignature'); |
|
817
|
817
|
$req->addParam(new $valClass($methodName)); |
|
@@ -821,7 +821,7 @@ discard block |
|
|
block discarded – undo |
|
821
|
821
|
$response = $client->send($req, $timeout, $protocol); |
|
822
|
822
|
$client->setDebug($origDebug); |
|
823
|
823
|
if ($response->faultCode()) { |
|
824
|
|
- $this->getLogger()->error('XML-RPC: ' . __METHOD__ . ': could not retrieve method signature from remote server for method ' . $methodName); |
|
|
824
|
+ $this->getLogger()->error('XML-RPC: '.__METHOD__.': could not retrieve method signature from remote server for method '.$methodName); |
|
825
|
825
|
return false; |
|
826
|
826
|
} |
|
827
|
827
|
|
|
@@ -832,8 +832,8 @@ discard block |
|
|
block discarded – undo |
|
832
|
832
|
$mSig = $decoder->decode($mSig); |
|
833
|
833
|
} |
|
834
|
834
|
|
|
835
|
|
- if (!is_array($mSig) || count($mSig) <= $sigNum) { |
|
836
|
|
- $this->getLogger()->error('XML-RPC: ' . __METHOD__ . ': could not retrieve method signature nr.' . $sigNum . ' from remote server for method ' . $methodName); |
|
|
835
|
+ if (!is_array($mSig) || count($mSig)<=$sigNum) { |
|
|
836
|
+ $this->getLogger()->error('XML-RPC: '.__METHOD__.': could not retrieve method signature nr.'.$sigNum.' from remote server for method '.$methodName); |
|
837
|
837
|
return false; |
|
838
|
838
|
} |
|
839
|
839
|
|
|
@@ -848,11 +848,11 @@ discard block |
|
|
block discarded – undo |
|
848
|
848
|
*/ |
|
849
|
849
|
protected function retrieveMethodHelp($client, $methodName, array $extraOptions = array()) |
|
850
|
850
|
{ |
|
851
|
|
- $reqClass = static::$namespace . 'Request'; |
|
852
|
|
- $valClass = static::$namespace . 'Value'; |
|
|
851
|
+ $reqClass = static::$namespace.'Request'; |
|
|
852
|
+ $valClass = static::$namespace.'Value'; |
|
853
|
853
|
|
|
854
|
854
|
$debug = isset($extraOptions['debug']) ? ($extraOptions['debug']) : 0; |
|
855
|
|
- $timeout = isset($extraOptions['timeout']) ? (int)$extraOptions['timeout'] : 0; |
|
|
855
|
+ $timeout = isset($extraOptions['timeout']) ? (int) $extraOptions['timeout'] : 0; |
|
856
|
856
|
$protocol = isset($extraOptions['protocol']) ? $extraOptions['protocol'] : ''; |
|
857
|
857
|
|
|
858
|
858
|
$mDesc = ''; |
|
@@ -889,11 +889,11 @@ discard block |
|
|
block discarded – undo |
|
889
|
889
|
$clientClone = $this->cloneClientForClosure($client); |
|
890
|
890
|
$function = function() use($clientClone, $methodName, $extraOptions, $mSig) |
|
891
|
891
|
{ |
|
892
|
|
- $timeout = isset($extraOptions['timeout']) ? (int)$extraOptions['timeout'] : 0; |
|
|
892
|
+ $timeout = isset($extraOptions['timeout']) ? (int) $extraOptions['timeout'] : 0; |
|
893
|
893
|
$protocol = isset($extraOptions['protocol']) ? $extraOptions['protocol'] : ''; |
|
894
|
|
- $encodePhpObjects = isset($extraOptions['encode_php_objs']) ? (bool)$extraOptions['encode_php_objs'] : false; |
|
895
|
|
- $decodePhpObjects = isset($extraOptions['decode_php_objs']) ? (bool)$extraOptions['decode_php_objs'] : false; |
|
896
|
|
- $encodeNulls = isset($extraOptions['encode_nulls']) ? (bool)$extraOptions['encode_nulls'] : false; |
|
|
894
|
+ $encodePhpObjects = isset($extraOptions['encode_php_objs']) ? (bool) $extraOptions['encode_php_objs'] : false; |
|
|
895
|
+ $decodePhpObjects = isset($extraOptions['decode_php_objs']) ? (bool) $extraOptions['decode_php_objs'] : false; |
|
|
896
|
+ $encodeNulls = isset($extraOptions['encode_nulls']) ? (bool) $extraOptions['encode_nulls'] : false; |
|
897
|
897
|
$throwFault = false; |
|
898
|
898
|
$decodeFault = false; |
|
899
|
899
|
$faultResponse = null; |
|
@@ -904,9 +904,9 @@ discard block |
|
|
block discarded – undo |
|
904
|
904
|
$faultResponse = $extraOptions['return_on_fault']; |
|
905
|
905
|
} |
|
906
|
906
|
|
|
907
|
|
- $reqClass = static::$namespace . 'Request'; |
|
908
|
|
- $encoderClass = static::$namespace . 'Encoder'; |
|
909
|
|
- $valueClass = static::$namespace . 'Value'; |
|
|
907
|
+ $reqClass = static::$namespace.'Request'; |
|
|
908
|
+ $encoderClass = static::$namespace.'Encoder'; |
|
|
909
|
+ $valueClass = static::$namespace.'Value'; |
|
910
|
910
|
|
|
911
|
911
|
$encoder = new $encoderClass(); |
|
912
|
912
|
$encodeOptions = array(); |
|
@@ -988,14 +988,14 @@ discard block |
|
|
block discarded – undo |
|
988
|
988
|
* @param string $mDesc |
|
989
|
989
|
* @return string[] keys: source, docstring |
|
990
|
990
|
*/ |
|
991
|
|
- public function buildWrapMethodSource($client, $methodName, array $extraOptions, $newFuncName, $mSig, $mDesc='') |
|
|
991
|
+ public function buildWrapMethodSource($client, $methodName, array $extraOptions, $newFuncName, $mSig, $mDesc = '') |
|
992
|
992
|
{ |
|
993
|
|
- $timeout = isset($extraOptions['timeout']) ? (int)$extraOptions['timeout'] : 0; |
|
|
993
|
+ $timeout = isset($extraOptions['timeout']) ? (int) $extraOptions['timeout'] : 0; |
|
994
|
994
|
$protocol = isset($extraOptions['protocol']) ? $extraOptions['protocol'] : ''; |
|
995
|
|
- $encodePhpObjects = isset($extraOptions['encode_php_objs']) ? (bool)$extraOptions['encode_php_objs'] : false; |
|
996
|
|
- $decodePhpObjects = isset($extraOptions['decode_php_objs']) ? (bool)$extraOptions['decode_php_objs'] : false; |
|
997
|
|
- $encodeNulls = isset($extraOptions['encode_nulls']) ? (bool)$extraOptions['encode_nulls'] : false; |
|
998
|
|
- $clientCopyMode = isset($extraOptions['simple_client_copy']) ? (int)($extraOptions['simple_client_copy']) : 0; |
|
|
995
|
+ $encodePhpObjects = isset($extraOptions['encode_php_objs']) ? (bool) $extraOptions['encode_php_objs'] : false; |
|
|
996
|
+ $decodePhpObjects = isset($extraOptions['decode_php_objs']) ? (bool) $extraOptions['decode_php_objs'] : false; |
|
|
997
|
+ $encodeNulls = isset($extraOptions['encode_nulls']) ? (bool) $extraOptions['encode_nulls'] : false; |
|
|
998
|
+ $clientCopyMode = isset($extraOptions['simple_client_copy']) ? (int) ($extraOptions['simple_client_copy']) : 0; |
|
999
|
999
|
$prefix = isset($extraOptions['prefix']) ? $extraOptions['prefix'] : static::$prefix; |
|
1000
|
1000
|
$clientReturnType = isset($extraOptions['client_return_type']) ? $extraOptions['client_return_type'] : $prefix; |
|
1001
|
1001
|
$throwFault = false; |
|
@@ -1009,10 +1009,10 @@ discard block |
|
|
block discarded – undo |
|
1009
|
1009
|
} |
|
1010
|
1010
|
|
|
1011
|
1011
|
$code = "function $newFuncName("; |
|
1012
|
|
- if ($clientCopyMode < 2) { |
|
|
1012
|
+ if ($clientCopyMode<2) { |
|
1013
|
1013
|
// client copy mode 0 or 1 == full / partial client copy in emitted code |
|
1014
|
1014
|
$verbatimClientCopy = !$clientCopyMode; |
|
1015
|
|
- $innerCode = ' ' . str_replace("\n", "\n ", $this->buildClientWrapperCode($client, $verbatimClientCopy, $clientReturnType, static::$namespace)); |
|
|
1015
|
+ $innerCode = ' '.str_replace("\n", "\n ", $this->buildClientWrapperCode($client, $verbatimClientCopy, $clientReturnType, static::$namespace)); |
|
1016
|
1016
|
$innerCode .= "\$client->setDebug(\$debug);\n"; |
|
1017
|
1017
|
$this_ = ''; |
|
1018
|
1018
|
} else { |
|
@@ -1020,28 +1020,28 @@ discard block |
|
|
block discarded – undo |
|
1020
|
1020
|
$innerCode = ''; |
|
1021
|
1021
|
$this_ = 'this->'; |
|
1022
|
1022
|
} |
|
1023
|
|
- $innerCode .= " \$req = new " . static::$namespace . "Request('$methodName');\n"; |
|
|
1023
|
+ $innerCode .= " \$req = new ".static::$namespace."Request('$methodName');\n"; |
|
1024
|
1024
|
|
|
1025
|
1025
|
if ($mDesc != '') { |
|
1026
|
1026
|
// take care that PHP comment is not terminated unwillingly by method description |
|
1027
|
1027
|
/// @todo according to the spec, method desc can have html in it. We should run it through strip_tags... |
|
1028
|
|
- $mDesc = "/**\n * " . str_replace(array("\n", '*/'), array("\n * ", '* /'), $mDesc) . "\n"; |
|
|
1028
|
+ $mDesc = "/**\n * ".str_replace(array("\n", '*/'), array("\n * ", '* /'), $mDesc)."\n"; |
|
1029
|
1029
|
} else { |
|
1030
|
1030
|
$mDesc = "/**\n * Function $newFuncName.\n"; |
|
1031
|
1031
|
} |
|
1032
|
1032
|
|
|
1033
|
1033
|
// param parsing |
|
1034
|
|
- $innerCode .= " \$encoder = new " . static::$namespace . "Encoder();\n"; |
|
|
1034
|
+ $innerCode .= " \$encoder = new ".static::$namespace."Encoder();\n"; |
|
1035
|
1035
|
$plist = array(); |
|
1036
|
1036
|
$pCount = count($mSig); |
|
1037
|
|
- for ($i = 1; $i < $pCount; $i++) { |
|
|
1037
|
+ for ($i = 1; $i<$pCount; $i++) { |
|
1038
|
1038
|
$plist[] = "\$p$i"; |
|
1039
|
1039
|
$pType = $mSig[$i]; |
|
1040
|
1040
|
if ($pType == 'i4' || $pType == 'i8' || $pType == 'int' || $pType == 'boolean' || $pType == 'double' || |
|
1041
|
1041
|
$pType == 'string' || $pType == 'dateTime.iso8601' || $pType == 'base64' || $pType == 'null' |
|
1042
|
1042
|
) { |
|
1043
|
1043
|
// only build directly xml-rpc values when type is known and scalar |
|
1044
|
|
- $innerCode .= " \$p$i = new " . static::$namespace . "Value(\$p$i, '$pType');\n"; |
|
|
1044
|
+ $innerCode .= " \$p$i = new ".static::$namespace."Value(\$p$i, '$pType');\n"; |
|
1045
|
1045
|
} else { |
|
1046
|
1046
|
if ($encodePhpObjects || $encodeNulls) { |
|
1047
|
1047
|
$encOpts = array(); |
|
@@ -1052,26 +1052,26 @@ discard block |
|
|
block discarded – undo |
|
1052
|
1052
|
$encOpts[] = 'null_extension'; |
|
1053
|
1053
|
} |
|
1054
|
1054
|
|
|
1055
|
|
- $innerCode .= " \$p$i = \$encoder->encode(\$p$i, array( '" . implode("', '", $encOpts) . "'));\n"; |
|
|
1055
|
+ $innerCode .= " \$p$i = \$encoder->encode(\$p$i, array( '".implode("', '", $encOpts)."'));\n"; |
|
1056
|
1056
|
} else { |
|
1057
|
1057
|
$innerCode .= " \$p$i = \$encoder->encode(\$p$i);\n"; |
|
1058
|
1058
|
} |
|
1059
|
1059
|
} |
|
1060
|
1060
|
$innerCode .= " \$req->addParam(\$p$i);\n"; |
|
1061
|
|
- $mDesc .= " * @param " . $this->xmlrpc2PhpType($pType) . " \$p$i\n"; |
|
|
1061
|
+ $mDesc .= " * @param ".$this->xmlrpc2PhpType($pType)." \$p$i\n"; |
|
1062
|
1062
|
} |
|
1063
|
|
- if ($clientCopyMode < 2) { |
|
|
1063
|
+ if ($clientCopyMode<2) { |
|
1064
|
1064
|
$plist[] = '$debug = 0'; |
|
1065
|
1065
|
$mDesc .= " * @param int \$debug when 1 (or 2) will enable debugging of the underlying {$prefix} call (defaults to 0)\n"; |
|
1066
|
1066
|
} |
|
1067
|
1067
|
$plist = implode(', ', $plist); |
|
1068
|
|
- $mDesc .= ' * @return ' . $this->xmlrpc2PhpType($mSig[0]); |
|
|
1068
|
+ $mDesc .= ' * @return '.$this->xmlrpc2PhpType($mSig[0]); |
|
1069
|
1069
|
if ($throwFault) { |
|
1070
|
|
- $mDesc .= "\n * @throws " . (is_string($throwFault) ? $throwFault : '\\PhpXmlRpc\\Exception'); |
|
|
1070
|
+ $mDesc .= "\n * @throws ".(is_string($throwFault) ? $throwFault : '\\PhpXmlRpc\\Exception'); |
|
1071
|
1071
|
} else if ($decodeFault) { |
|
1072
|
|
- $mDesc .= '|' . gettype($faultResponse) . " (a " . gettype($faultResponse) . " if call fails)"; |
|
|
1072
|
+ $mDesc .= '|'.gettype($faultResponse)." (a ".gettype($faultResponse)." if call fails)"; |
|
1073
|
1073
|
} else { |
|
1074
|
|
- $mDesc .= '|' . static::$namespace . "Response (a " . static::$namespace . "Response obj instance if call fails)"; |
|
|
1074
|
+ $mDesc .= '|'.static::$namespace."Response (a ".static::$namespace."Response obj instance if call fails)"; |
|
1075
|
1075
|
} |
|
1076
|
1076
|
$mDesc .= "\n */\n"; |
|
1077
|
1077
|
|
|
@@ -1084,9 +1084,9 @@ discard block |
|
|
block discarded – undo |
|
1084
|
1084
|
$respCode = "throw new $throwFault(\$res->faultString(), \$res->faultCode())"; |
|
1085
|
1085
|
} else if ($decodeFault) { |
|
1086
|
1086
|
if (is_string($faultResponse) && ((strpos($faultResponse, '%faultCode%') !== false) || (strpos($faultResponse, '%faultString%') !== false))) { |
|
1087
|
|
- $respCode = "return str_replace(array('%faultCode%', '%faultString%'), array(\$res->faultCode(), \$res->faultString()), '" . str_replace("'", "''", $faultResponse) . "')"; |
|
|
1087
|
+ $respCode = "return str_replace(array('%faultCode%', '%faultString%'), array(\$res->faultCode(), \$res->faultString()), '".str_replace("'", "''", $faultResponse)."')"; |
|
1088
|
1088
|
} else { |
|
1089
|
|
- $respCode = 'return ' . var_export($faultResponse, true); |
|
|
1089
|
+ $respCode = 'return '.var_export($faultResponse, true); |
|
1090
|
1090
|
} |
|
1091
|
1091
|
} else { |
|
1092
|
1092
|
$respCode = 'return $res'; |
|
@@ -1097,7 +1097,7 @@ discard block |
|
|
block discarded – undo |
|
1097
|
1097
|
$innerCode .= " if (\$res->faultCode()) $respCode; else return \$encoder->decode(\$res->value());"; |
|
1098
|
1098
|
} |
|
1099
|
1099
|
|
|
1100
|
|
- $code = $code . $plist . ")\n{\n" . $innerCode . "\n}\n"; |
|
|
1100
|
+ $code = $code.$plist.")\n{\n".$innerCode."\n}\n"; |
|
1101
|
1101
|
|
|
1102
|
1102
|
return array('source' => $code, 'docstring' => $mDesc); |
|
1103
|
1103
|
} |
|
@@ -1127,27 +1127,27 @@ discard block |
|
|
block discarded – undo |
|
1127
|
1127
|
public function wrapXmlrpcServer($client, $extraOptions = array()) |
|
1128
|
1128
|
{ |
|
1129
|
1129
|
$methodFilter = isset($extraOptions['method_filter']) ? $extraOptions['method_filter'] : ''; |
|
1130
|
|
- $timeout = isset($extraOptions['timeout']) ? (int)$extraOptions['timeout'] : 0; |
|
|
1130
|
+ $timeout = isset($extraOptions['timeout']) ? (int) $extraOptions['timeout'] : 0; |
|
1131
|
1131
|
$protocol = isset($extraOptions['protocol']) ? $extraOptions['protocol'] : ''; |
|
1132
|
1132
|
$newClassName = isset($extraOptions['new_class_name']) ? $extraOptions['new_class_name'] : ''; |
|
1133
|
|
- $encodeNulls = isset($extraOptions['encode_nulls']) ? (bool)$extraOptions['encode_nulls'] : false; |
|
1134
|
|
- $encodePhpObjects = isset($extraOptions['encode_php_objs']) ? (bool)$extraOptions['encode_php_objs'] : false; |
|
1135
|
|
- $decodePhpObjects = isset($extraOptions['decode_php_objs']) ? (bool)$extraOptions['decode_php_objs'] : false; |
|
|
1133
|
+ $encodeNulls = isset($extraOptions['encode_nulls']) ? (bool) $extraOptions['encode_nulls'] : false; |
|
|
1134
|
+ $encodePhpObjects = isset($extraOptions['encode_php_objs']) ? (bool) $extraOptions['encode_php_objs'] : false; |
|
|
1135
|
+ $decodePhpObjects = isset($extraOptions['decode_php_objs']) ? (bool) $extraOptions['decode_php_objs'] : false; |
|
1136
|
1136
|
$verbatimClientCopy = isset($extraOptions['simple_client_copy']) ? !($extraOptions['simple_client_copy']) : true; |
|
1137
|
|
- $throwOnFault = isset($extraOptions['throw_on_fault']) ? (bool)$extraOptions['throw_on_fault'] : false; |
|
|
1137
|
+ $throwOnFault = isset($extraOptions['throw_on_fault']) ? (bool) $extraOptions['throw_on_fault'] : false; |
|
1138
|
1138
|
$buildIt = isset($extraOptions['return_source']) ? !($extraOptions['return_source']) : true; |
|
1139
|
1139
|
$prefix = isset($extraOptions['prefix']) ? $extraOptions['prefix'] : static::$prefix; |
|
1140
|
1140
|
$clientReturnType = isset($extraOptions['client_return_type']) ? $extraOptions['client_return_type'] : $prefix; |
|
1141
|
1141
|
|
|
1142
|
|
- $reqClass = static::$namespace . 'Request'; |
|
1143
|
|
- $decoderClass = static::$namespace . 'Encoder'; |
|
|
1142
|
+ $reqClass = static::$namespace.'Request'; |
|
|
1143
|
+ $decoderClass = static::$namespace.'Encoder'; |
|
1144
|
1144
|
|
|
1145
|
1145
|
// retrieve the list of methods |
|
1146
|
1146
|
$req = new $reqClass('system.listMethods'); |
|
1147
|
1147
|
/// @todo move setting of timeout, protocol to outside the send() call |
|
1148
|
1148
|
$response = $client->send($req, $timeout, $protocol); |
|
1149
|
1149
|
if ($response->faultCode()) { |
|
1150
|
|
- $this->getLogger()->error('XML-RPC: ' . __METHOD__ . ': could not retrieve method list from remote server'); |
|
|
1150
|
+ $this->getLogger()->error('XML-RPC: '.__METHOD__.': could not retrieve method list from remote server'); |
|
1151
|
1151
|
|
|
1152
|
1152
|
return false; |
|
1153
|
1153
|
} |
|
@@ -1158,7 +1158,7 @@ discard block |
|
|
block discarded – undo |
|
1158
|
1158
|
$mList = $decoder->decode($mList); |
|
1159
|
1159
|
} |
|
1160
|
1160
|
if (!is_array($mList) || !count($mList)) { |
|
1161
|
|
- $this->getLogger()->error('XML-RPC: ' . __METHOD__ . ': could not retrieve meaningful method list from remote server'); |
|
|
1161
|
+ $this->getLogger()->error('XML-RPC: '.__METHOD__.': could not retrieve meaningful method list from remote server'); |
|
1162
|
1162
|
|
|
1163
|
1163
|
return false; |
|
1164
|
1164
|
} |
|
@@ -1168,8 +1168,8 @@ discard block |
|
|
block discarded – undo |
|
1168
|
1168
|
$xmlrpcClassName = $newClassName; |
|
1169
|
1169
|
} else { |
|
1170
|
1170
|
/// @todo direct access to $client->server is now deprecated |
|
1171
|
|
- $xmlrpcClassName = $prefix . '_' . preg_replace(array('/\./', '/[^a-zA-Z0-9_\x7f-\xff]/'), array('_', ''), |
|
1172
|
|
- $client->server) . '_client'; |
|
|
1171
|
+ $xmlrpcClassName = $prefix.'_'.preg_replace(array('/\./', '/[^a-zA-Z0-9_\x7f-\xff]/'), array('_', ''), |
|
|
1172
|
+ $client->server).'_client'; |
|
1173
|
1173
|
} |
|
1174
|
1174
|
while ($buildIt && class_exists($xmlrpcClassName)) { |
|
1175
|
1175
|
$xmlrpcClassName .= 'x'; |
|
@@ -1177,7 +1177,7 @@ discard block |
|
|
block discarded – undo |
|
1177
|
1177
|
|
|
1178
|
1178
|
$source = "class $xmlrpcClassName\n{\n public \$client;\n\n"; |
|
1179
|
1179
|
$source .= " function __construct()\n {\n"; |
|
1180
|
|
- $source .= ' ' . str_replace("\n", "\n ", $this->buildClientWrapperCode($client, $verbatimClientCopy, $clientReturnType, static::$namespace)); |
|
|
1180
|
+ $source .= ' '.str_replace("\n", "\n ", $this->buildClientWrapperCode($client, $verbatimClientCopy, $clientReturnType, static::$namespace)); |
|
1181
|
1181
|
$source .= "\$this->client = \$client;\n }\n\n"; |
|
1182
|
1182
|
$opts = array( |
|
1183
|
1183
|
'return_source' => true, |
|
@@ -1200,28 +1200,28 @@ discard block |
|
|
block discarded – undo |
|
1200
|
1200
|
$methodWrap = $this->wrapXmlrpcMethod($client, $mName, $opts); |
|
1201
|
1201
|
if ($methodWrap) { |
|
1202
|
1202
|
if ($buildIt) { |
|
1203
|
|
- $source .= $methodWrap['source'] . "\n"; |
|
|
1203
|
+ $source .= $methodWrap['source']."\n"; |
|
1204
|
1204
|
|
|
1205
|
1205
|
} else { |
|
1206
|
|
- $source .= ' ' . str_replace("\n", "\n ", $methodWrap['docstring']); |
|
1207
|
|
- $source .= str_replace("\n", "\n ", $methodWrap['source']). "\n"; |
|
|
1206
|
+ $source .= ' '.str_replace("\n", "\n ", $methodWrap['docstring']); |
|
|
1207
|
+ $source .= str_replace("\n", "\n ", $methodWrap['source'])."\n"; |
|
1208
|
1208
|
} |
|
1209
|
1209
|
|
|
1210
|
1210
|
} else { |
|
1211
|
|
- $this->getLogger()->error('XML-RPC: ' . __METHOD__ . ': will not create class method to wrap remote method ' . $mName); |
|
|
1211
|
+ $this->getLogger()->error('XML-RPC: '.__METHOD__.': will not create class method to wrap remote method '.$mName); |
|
1212
|
1212
|
} |
|
1213
|
1213
|
} |
|
1214
|
1214
|
} |
|
1215
|
1215
|
$source .= "}\n"; |
|
1216
|
1216
|
if ($buildIt) { |
|
1217
|
1217
|
$allOK = 0; |
|
1218
|
|
- eval($source . '$allOK=1;'); |
|
|
1218
|
+ eval($source.'$allOK=1;'); |
|
1219
|
1219
|
if ($allOK) { |
|
1220
|
1220
|
return $xmlrpcClassName; |
|
1221
|
1221
|
} else { |
|
1222
|
1222
|
/// @todo direct access to $client->server is now deprecated |
|
1223
|
|
- $this->getLogger()->error('XML-RPC: ' . __METHOD__ . ': could not create class ' . $xmlrpcClassName . |
|
1224
|
|
- ' to wrap remote server ' . $client->server); |
|
|
1223
|
+ $this->getLogger()->error('XML-RPC: '.__METHOD__.': could not create class '.$xmlrpcClassName. |
|
|
1224
|
+ ' to wrap remote server '.$client->server); |
|
1225
|
1225
|
return false; |
|
1226
|
1226
|
} |
|
1227
|
1227
|
} else { |
|
@@ -1240,7 +1240,7 @@ discard block |
|
|
block discarded – undo |
|
1240
|
1240
|
*/ |
|
1241
|
1241
|
protected function buildClientWrapperCode($client, $verbatimClientCopy, $prefix = 'xmlrpc', $namespace = '\\PhpXmlRpc\\') |
|
1242
|
1242
|
{ |
|
1243
|
|
- $code = "\$client = new {$namespace}Client('" . str_replace(array("\\", "'"), array("\\\\", "\'"), $client->getUrl()) . |
|
|
1243
|
+ $code = "\$client = new {$namespace}Client('".str_replace(array("\\", "'"), array("\\\\", "\'"), $client->getUrl()). |
|
1244
|
1244
|
"');\n"; |
|
1245
|
1245
|
|
|
1246
|
1246
|
// copy all client fields to the client that will be generated runtime |