build on PRs; nitpicks
[plcapi.git] / demo / server / methodProviders / interop.php
1 <?php
2 /**
3  * Defines functions and signatures which can be registered as methods exposed by an XMLRPC Server.
4  *
5  * To use this, use something akin to:
6  * $signatures = include('interop.php');
7  *
8  * Trivial interop tests
9  * http://www.xmlrpc.com/stories/storyReader$1636
10  */
11
12 use PhpXmlRpc\Response;
13 use PhpXmlRpc\Value;
14
15 $i_echoString_sig = array(array(Value::$xmlrpcString, Value::$xmlrpcString));
16 $i_echoString_doc = "Echoes string.";
17
18 $i_echoStringArray_sig = array(array(Value::$xmlrpcArray, Value::$xmlrpcArray));
19 $i_echoStringArray_doc = "Echoes string array.";
20
21 $i_echoInteger_sig = array(array(Value::$xmlrpcInt, Value::$xmlrpcInt));
22 $i_echoInteger_doc = "Echoes integer.";
23
24 $i_echoIntegerArray_sig = array(array(Value::$xmlrpcArray, Value::$xmlrpcArray));
25 $i_echoIntegerArray_doc = "Echoes integer array.";
26
27 $i_echoFloat_sig = array(array(Value::$xmlrpcDouble, Value::$xmlrpcDouble));
28 $i_echoFloat_doc = "Echoes float.";
29
30 $i_echoFloatArray_sig = array(array(Value::$xmlrpcArray, Value::$xmlrpcArray));
31 $i_echoFloatArray_doc = "Echoes float array.";
32
33 $i_echoStruct_sig = array(array(Value::$xmlrpcStruct, Value::$xmlrpcStruct));
34 $i_echoStruct_doc = "Echoes struct.";
35
36 $i_echoStructArray_sig = array(array(Value::$xmlrpcArray, Value::$xmlrpcArray));
37 $i_echoStructArray_doc = "Echoes struct array.";
38
39 $i_echoValue_doc = "Echoes any value back.";
40 $i_echoValue_sig = array(array(Value::$xmlrpcValue, Value::$xmlrpcValue));
41
42 $i_echoBase64_sig = array(array(Value::$xmlrpcBase64, Value::$xmlrpcBase64));
43 $i_echoBase64_doc = "Echoes base64.";
44
45 $i_echoDate_sig = array(array(Value::$xmlrpcDateTime, Value::$xmlrpcDateTime));
46 $i_echoDate_doc = "Echoes dateTime.";
47
48 function i_echoParam($req)
49 {
50     $s = $req->getParam(0);
51
52     return new Response($s);
53 }
54
55 function i_echoString($req)
56 {
57     return i_echoParam($req);
58 }
59
60 function i_echoInteger($req)
61 {
62     return i_echoParam($req);
63 }
64
65 function i_echoFloat($req)
66 {
67     return i_echoParam($req);
68 }
69
70 function i_echoStruct($req)
71 {
72     return i_echoParam($req);
73 }
74
75 function i_echoStringArray($req)
76 {
77     return i_echoParam($req);
78 }
79
80 function i_echoIntegerArray($req)
81 {
82     return i_echoParam($req);
83 }
84
85 function i_echoFloatArray($req)
86 {
87     return i_echoParam($req);
88 }
89
90 function i_echoStructArray($req)
91 {
92     return i_echoParam($req);
93 }
94
95 function i_echoValue($req)
96 {
97     return i_echoParam($req);
98 }
99
100 function i_echoBase64($req)
101 {
102     return i_echoParam($req);
103 }
104
105 function i_echoDate($req)
106 {
107     return i_echoParam($req);
108 }
109
110 $i_whichToolkit_sig = array(array(Value::$xmlrpcStruct));
111 $i_whichToolkit_doc = "Returns a struct containing the following strings: toolkitDocsUrl, toolkitName, toolkitVersion, toolkitOperatingSystem.";
112
113 function i_whichToolkit($req)
114 {
115     global $SERVER_SOFTWARE;
116     $ret = array(
117         "toolkitDocsUrl" => "http://phpxmlrpc.sourceforge.net/",
118         "toolkitName" => PhpXmlRpc\PhpXmlRpc::$xmlrpcName,
119         "toolkitVersion" => PhpXmlRpc\PhpXmlRpc::$xmlrpcVersion,
120         "toolkitOperatingSystem" => isset($SERVER_SOFTWARE) ? $SERVER_SOFTWARE : $_SERVER['SERVER_SOFTWARE'],
121     );
122
123     $encoder = new PhpXmlRpc\Encoder();
124     return new Response($encoder->encode($ret));
125 }
126
127 return array(
128     "interopEchoTests.echoString" => array(
129         "function" => "i_echoString",
130         "signature" => $i_echoString_sig,
131         "docstring" => $i_echoString_doc,
132     ),
133     "interopEchoTests.echoStringArray" => array(
134         "function" => "i_echoStringArray",
135         "signature" => $i_echoStringArray_sig,
136         "docstring" => $i_echoStringArray_doc,
137     ),
138     "interopEchoTests.echoInteger" => array(
139         "function" => "i_echoInteger",
140         "signature" => $i_echoInteger_sig,
141         "docstring" => $i_echoInteger_doc,
142     ),
143     "interopEchoTests.echoIntegerArray" => array(
144         "function" => "i_echoIntegerArray",
145         "signature" => $i_echoIntegerArray_sig,
146         "docstring" => $i_echoIntegerArray_doc,
147     ),
148     "interopEchoTests.echoFloat" => array(
149         "function" => "i_echoFloat",
150         "signature" => $i_echoFloat_sig,
151         "docstring" => $i_echoFloat_doc,
152     ),
153     "interopEchoTests.echoFloatArray" => array(
154         "function" => "i_echoFloatArray",
155         "signature" => $i_echoFloatArray_sig,
156         "docstring" => $i_echoFloatArray_doc,
157     ),
158     "interopEchoTests.echoStruct" => array(
159         "function" => "i_echoStruct",
160         "signature" => $i_echoStruct_sig,
161         "docstring" => $i_echoStruct_doc,
162     ),
163     "interopEchoTests.echoStructArray" => array(
164         "function" => "i_echoStructArray",
165         "signature" => $i_echoStructArray_sig,
166         "docstring" => $i_echoStructArray_doc,
167     ),
168     "interopEchoTests.echoValue" => array(
169         "function" => "i_echoValue",
170         "signature" => $i_echoValue_sig,
171         "docstring" => $i_echoValue_doc,
172     ),
173     "interopEchoTests.echoBase64" => array(
174         "function" => "i_echoBase64",
175         "signature" => $i_echoBase64_sig,
176         "docstring" => $i_echoBase64_doc,
177     ),
178     "interopEchoTests.echoDate" => array(
179         "function" => "i_echoDate",
180         "signature" => $i_echoDate_sig,
181         "docstring" => $i_echoDate_doc,
182     ),
183     "interopEchoTests.whichToolkit" => array(
184         "function" => "i_whichToolkit",
185         "signature" => $i_whichToolkit_sig,
186         "docstring" => $i_whichToolkit_doc,
187     ),
188 );