Add a test for wrapping closures
[plcapi.git] / demo / server / server.php
index c3eedf4..6f0a430 100644 (file)
@@ -132,11 +132,6 @@ function inner_findstate($stateNo)
     }
 }
 
-$findStateClosure = function ($req)
-{
-    return findState($req);
-};
-
 $wrapper = new PhpXmlRpc\Wrapper();
 
 $findstate2_sig = $wrapper->wrap_php_function('inner_findstate');
@@ -163,11 +158,16 @@ $findstate9_sig = $wrapper->wrap_php_function('xmlrpcServerMethodsContainer::fin
 eval($findstate9_sig['source']);
 
 $findstate10_sig = array(
-    "function" => $findStateClosure,
+    "function" => function ($req) { return findState($req); },
     "signature" => $findstate_sig,
     "docstring" => $findstate_doc,
 );
 
+$findstate11_sig = $wrapper->wrap_php_function(function ($stateNo) { return inner_findstate($stateNo); });
+
+$c = new xmlrpcServerMethodsContainer;
+$moreSignatures = $wrapper->wrap_php_class($c, array('prefix' => 'tests.', 'method_type' => 'all'));
+
 $addtwo_sig = array(array(Value::$xmlrpcInt, Value::$xmlrpcInt, Value::$xmlrpcInt));
 $addtwo_doc = 'Add two integers together and return the result';
 function addTwo($req)
@@ -890,9 +890,11 @@ $signatures = array(
     'tests.getStateName.8' => $findstate8_sig,
     'tests.getStateName.9' => $findstate9_sig,
     'tests.getStateName.10' => $findstate10_sig,
-
+    'tests.getStateName.11' => $findstate11_sig,
 );
 
+$signatures = array_merge($signatures, $moreSignatures);
+
 $s = new PhpXmlRpc\Server($signatures, false);
 $s->setdebug(3);
 $s->compress_response = true;