wrapPhpFunction('plain_findstate'); // *** objects/classes *** /** * Used to test usage of object methods in dispatch maps and in wrapper code. */ class xmlrpcServerMethodsContainer { /** * Method used to test logging of php warnings generated by user functions. * @param PhpXmlRpc\Request $req * @return Response */ public function phpWarningGenerator($req) { $a = $undefinedVariable; // this triggers a warning in E_ALL mode, since $undefinedVariable is undefined return new Response(new Value(1, Value::$xmlrpcBoolean)); } /** * Method used to test catching of exceptions in the server. * @param PhpXmlRpc\Request $req * @throws Exception */ public function exceptionGenerator($req) { throw new Exception("it's just a test", 1); } /** * @param string $msg */ public function debugMessageGenerator($msg) { PhpXmlRpc\Server::xmlrpc_debugmsg($msg); } /** * A PHP version of the state-number server. Send me an integer and i'll sell you a state. * Used to test wrapping of PHP methods into xmlrpc methods. * * @param integer $num * @return string * @throws Exception */ public static function findState($num) { // we are lazy ;-) return plain_findstate($num); } /** * Returns an instance of stdClass. * Used to test wrapping of PHP objects with class preservation */ public function returnObject() { $obj = new stdClass(); $obj->hello = 'world'; return $obj; } } $findstate3_sig = $wrapper->wrapPhpFunction(array('xmlrpcServerMethodsContainer', 'findState')); $obj = new xmlrpcServerMethodsContainer(); $findstate4_sig = $wrapper->wrapPhpFunction(array($obj, 'findstate')); $findstate5_sig = $wrapper->wrapPhpFunction('xmlrpcServerMethodsContainer::findState', '', array('return_source' => true)); eval($findstate5_sig['source']); $findstate6_sig = $wrapper->wrapPhpFunction('plain_findstate', '', array('return_source' => true)); eval($findstate6_sig['source']); $findstate7_sig = $wrapper->wrapPhpFunction(array('xmlrpcServerMethodsContainer', 'findState'), '', array('return_source' => true)); eval($findstate7_sig['source']); //$obj = new xmlrpcServerMethodsContainer(); $findstate8_sig = $wrapper->wrapPhpFunction(array($obj, 'findstate'), '', array('return_source' => true)); eval($findstate8_sig['source']); $findstate9_sig = $wrapper->wrapPhpFunction('xmlrpcServerMethodsContainer::findState', '', array('return_source' => true)); eval($findstate9_sig['source']); $findstate10_sig = array( /// @todo add a demo/test with a closure "function" => function ($req) { return findState($req); }, "signature" => array(array(Value::$xmlrpcString, Value::$xmlrpcInt)), "docstring" => 'When passed an integer between 1 and 51 returns the name of a US state, where the integer is the ' . 'index of that state name in an alphabetic order.', ); $findstate11_sig = $wrapper->wrapPhpFunction(function ($stateNo) { return plain_findstate($stateNo); }); /// @todo do we really need a new instance ? $c = new xmlrpcServerMethodsContainer(); $moreSignatures = $wrapper->wrapPhpClass($c, array('prefix' => 'tests.', 'method_type' => 'all')); $namespaceSignatures = $wrapper->wrapPhpClass($c, array('namespace' => 'namespacetest', 'method_type' => 'all')); $returnObj_sig = $wrapper->wrapPhpFunction(array($c, 'returnObject'), '', array('encode_php_objs' => true)); return array_merge( array( 'tests.getStateName.2' => $findstate2_sig, 'tests.getStateName.3' => $findstate3_sig, 'tests.getStateName.4' => $findstate4_sig, 'tests.getStateName.5' => $findstate5_sig, 'tests.getStateName.6' => $findstate6_sig, 'tests.getStateName.7' => $findstate7_sig, 'tests.getStateName.8' => $findstate8_sig, 'tests.getStateName.9' => $findstate9_sig, 'tests.getStateName.10' => $findstate10_sig, 'tests.getStateName.11' => $findstate11_sig, 'tests.returnPhpObject' => $returnObj_sig, ), $namespaceSignatures, $moreSignatures );