Skip to content

Commit

Permalink
Merge pull request #4 from thamtech/docblock-parser-fixes
Browse files Browse the repository at this point in the history
Docblock parser fixes
  • Loading branch information
cranetm committed Sep 28, 2015
2 parents 035f782 + c312cff commit 54d9dfd
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
10 changes: 5 additions & 5 deletions JsonRpc2/Controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -316,14 +316,14 @@ private function parseMethodDocComment($method)

$lines = preg_split ('/$\R?^/m', $method->getDocComment());
for ($i=0; $i<count($lines); $i++) {
preg_match("/@param $variableRegex ([\w\\\\\[\]]+)/", $lines[$i], $paramMatches);
preg_match("/@param\s+([\w\\\\\[\]]+)\s+$variableRegex/", $lines[$i], $paramMatches);
if (!empty($paramMatches)) {
$subject = &$this->methodInfo['params'][$paramMatches[1]];
$subject = &$this->methodInfo['params'][$paramMatches[2]];
$subject = $infoTpl;
$subject['name'] = $paramMatches[1];
$subject['type'] = $paramMatches[2];
$subject['name'] = $paramMatches[2];
$subject['type'] = $paramMatches[1];
} else {
preg_match("/@return ([\w\\\\\[\]]+)/", $lines[$i], $paramMatches);
preg_match("/@return\s+([\w\\\\\[\]]+)/", $lines[$i], $paramMatches);
if (!empty($paramMatches)) {
$subject = &$this->methodInfo['return'];
$subject = $infoTpl;
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ But we can receive params as associative object and in this case param's order i
Let's validate **$message** as int value in our **actionUpdate** and increase it:
~~~php
/**
* @param $message int
* @param int $message
* @return array
*/
public function actionUpdate($message)
Expand Down Expand Up @@ -195,7 +195,7 @@ class Test extends Dto {
...and change **actionUpdate** for using Test DTO
~~~php
/**
* @param $test \JsonRpc2\Dto\Test
* @param \JsonRpc2\Dto\Test $test
* @return array
*/
public function actionUpdate($test)
Expand Down Expand Up @@ -223,8 +223,8 @@ You can use this arrays in actions OR in DTOs and all params data will be valida
**'Update'** Action:
~~~php
/**
* @param $tests \JsonRpc2\Dto\Test[]
* @param $messages string[]
* @param \JsonRpc2\Dto\Test[] $tests
* @param string[] $messages
* @return array
*/
public function actionUpdate($tests, $messages)
Expand Down

0 comments on commit 54d9dfd

Please sign in to comment.