fix type parsing for more complex types
This commit is contained in:
parent
e7323dfb8c
commit
b05603ab33
|
@ -13,12 +13,13 @@ class ApiCallTest extends \DokuWikiTest
|
|||
* in several lines
|
||||
* @param string $foo First variable
|
||||
* @param int $bar
|
||||
* @param string[] $baz
|
||||
* @something else
|
||||
* @something other
|
||||
* @another tag
|
||||
* @return string The return
|
||||
*/
|
||||
public function dummyMethod1($foo, $bar)
|
||||
public function dummyMethod1($foo, $bar, $baz)
|
||||
{
|
||||
return 'dummy';
|
||||
}
|
||||
|
@ -39,7 +40,11 @@ class ApiCallTest extends \DokuWikiTest
|
|||
'bar' => [
|
||||
'type' => 'int',
|
||||
'description' => '',
|
||||
]
|
||||
],
|
||||
'baz' => [
|
||||
'type' => 'array',
|
||||
'description' => '',
|
||||
],
|
||||
],
|
||||
$call->getArgs()
|
||||
);
|
||||
|
|
|
@ -283,25 +283,25 @@ class ApiCall
|
|||
|
||||
if (isset($tags['param'])) {
|
||||
foreach ($tags['param'] as $param) {
|
||||
if (preg_match('/^(\w+)\s+\$(\w+)(\s+(.*))?$/m', $param, $m)) {
|
||||
$result['args'][$m[2]] = [
|
||||
'type' => $this->cleanTypeHint($m[1]),
|
||||
'description' => trim($m[3] ?? ''),
|
||||
];
|
||||
}
|
||||
[$type, $name, $description] = array_map('trim', sexplode(' ', $param, 3, ''));
|
||||
if ($name[0] !== '$') continue;
|
||||
$name = substr($name, 1);
|
||||
|
||||
$result['args'][$name] = [
|
||||
'type' => $this->cleanTypeHint($type),
|
||||
'description' => $description,
|
||||
];
|
||||
}
|
||||
unset($tags['param']);
|
||||
}
|
||||
|
||||
|
||||
if (isset($tags['return'])) {
|
||||
$return = $tags['return'][0];
|
||||
if (preg_match('/^(\w+)(\s+(.*))?$/m', $return, $m)) {
|
||||
$result['return'] = [
|
||||
'type' => $this->cleanTypeHint($m[1]),
|
||||
'description' => trim($m[2] ?? '')
|
||||
];
|
||||
}
|
||||
[$type, $description] = array_map('trim', sexplode(' ', $return, 2, ''));
|
||||
$result['return'] = [
|
||||
'type' => $this->cleanTypeHint($type),
|
||||
'description' => $description
|
||||
];
|
||||
unset($tags['return']);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue