43 require_once
'XML/RPC2/Exception.php';
160 public function __construct(ReflectionMethod $method, $defaultPrefix)
163 $docs = $method->getDocComment();
167 $docs = explode(
"\n", $docs);
169 $parameters = array();
174 $prefix = $defaultPrefix;
177 $paramDocs = array();
178 foreach ($docs as $i => $doc) {
179 $doc = trim($doc,
" \r\t/*");
180 if (strlen($doc) && strpos($doc,
'@') !== 0) {
187 if (strpos($doc,
'@xmlrpc.hidden') === 0) {
190 if ((strpos($doc,
'@xmlrpc.prefix') === 0) && preg_match(
'/@xmlrpc.prefix( )*(.*)/', $doc, $matches)) {
191 $prefix = $matches[2];
193 if ((strpos($doc,
'@xmlrpc.methodname') === 0) && preg_match(
'/@xmlrpc.methodname( )*(.*)/', $doc, $matches)) {
194 $methodname = $matches[2];
196 if (strpos($doc,
'@param') === 0) {
200 if (strpos($doc,
'@return') === 0) {
201 $param = preg_split(
"/\s+/", $doc);
202 if (isset($param[1])) {
208 $this->_numberOfRequiredParameters = $method->getNumberOfRequiredParameters();
210 foreach ($method->getParameters() as $parameterIndex => $parameter) {
212 $newParameter = array(
'type' =>
'mixed');
215 if (array_key_exists($parameterIndex, $paramDocs) &&
216 preg_match(
'/@param\s+(\S+)(\s+(.+))/', $paramDocs[$parameterIndex], $matches)) {
217 if (strpos($matches[1],
'|')) {
222 $tmp =
'$' . $parameter->getName() .
' ';
223 if (strpos($matches[2],
'$' . $tmp) === 0) {
224 $newParameter[
'doc'] = $matches[2];
228 $newParameter[
'doc'] = substr($matches[2], strlen($tmp));
232 $parameters[$parameter->getName()] = $newParameter;
235 if (is_null($methodname)) {
236 $methodname = $prefix . $method->getName();
239 $this->_internalMethod = $method->getName();
240 $this->_parameters = $parameters;
241 $this->_returns = $returns;
242 $this->_help = $shortdesc;
243 $this->_name = $methodname;
244 $this->_hidden = $hidden;
262 if ($methodName != $this->_name)
return false;
263 if (count($callParams) < $this->_numberOfRequiredParameters)
return false;
264 if (count($callParams) > $this->_parameters)
return false;
266 foreach($this->_parameters as $param) {
268 if ($paramIndex <= $this->_numberOfRequiredParameters) {
271 if ((!($param[
'type'] ==
'mixed')) and ($param[
'type'] != $callParamType)) {
291 $result =
"<span class=\"type\">($returnType)</span> ";
292 $result .=
"<span class=\"name\">$name</span>";
293 $result .=
"<span class=\"other\">(</span>";
296 while (list(
$name, $parameter) = each($this->_parameters)) {
298 if ($nbr == $this->_numberOfRequiredParameters + 1) {
299 $result .=
"<span class=\"other\"> [ </span>";
306 $type = $parameter[
'type'];
307 $result .=
"<span class=\"paratype\">($type) </span>";
308 $result .=
"<span class=\"paraname\">$name</span>";
310 reset($this->_parameters);
311 if ($nbr > $this->_numberOfRequiredParameters) {
312 $result .=
"<span class=\"other\"> ] </span>";
314 $result .=
"<span class=\"other\">)</span>";
328 $help = nl2br(htmlentities($this->_help));
329 print
" <h3><a name=\"$id\">$signature</a></h3>\n";
330 print
" <p><b>Description :</b></p>\n";
331 print
" <div class=\"description\">\n";
334 if (count($this->_parameters)>0) {
335 print
" <p><b>Parameters : </b></p>\n";
336 if (count($this->_parameters)>0) {
338 print
" <tr><td><b>Type</b></td><td><b>Name</b></td><td><b>Documentation</b></td></tr>\n";
339 while (list(
$name, $parameter) = each($this->_parameters)) {
340 $type = $parameter[
'type'];
341 $doc = htmlentities($parameter[
'doc']);
342 print
" <tr><td>$type</td><td>$name</td><td>$doc</td></tr>\n";
344 reset($this->_parameters);
360 $tmp = strtolower(
$type);
361 $convertArray = array(
364 'integer' =>
'integer',
365 'string' =>
'string',
369 'boolean' =>
'boolean',
372 'double' =>
'double',
376 'structure' =>
'array',
377 'datetime' =>
'mixed',
378 'datetime.iso8601' =>
'mixed',
379 'iso8601' =>
'mixed',
382 if (isset($convertArray[$tmp])) {
383 return $convertArray[$tmp];