diff --git a/Extractor/ApiDocExtractor.php b/Extractor/ApiDocExtractor.php index bc96273..b9077e2 100644 --- a/Extractor/ApiDocExtractor.php +++ b/Extractor/ApiDocExtractor.php @@ -323,7 +323,7 @@ class ApiDocExtractor } } - $regexp = '{(\w*) *\$%s *(.*)}i'; + $regexp = '{(\w*) *\$%s\b *(.*)}i'; foreach ($route->compile()->getVariables() as $var) { $found = false; foreach ($paramDocs as $paramDoc) { diff --git a/Tests/Extractor/ApiDocExtratorTest.php b/Tests/Extractor/ApiDocExtratorTest.php index e90bc95..68e8f70 100644 --- a/Tests/Extractor/ApiDocExtratorTest.php +++ b/Tests/Extractor/ApiDocExtratorTest.php @@ -153,6 +153,20 @@ class ApiDocExtractorTest extends WebTestCase "This method is useful to test if the getDocComment works.", $annotation->getDescription() ); + + $data = $annotation->toArray(); + $this->assertEquals( + 4, + count($data['requirements']) + ); + $this->assertEquals( + 'The param type', + $data['requirements']['paramType']['description'] + ); + $this->assertEquals( + 'The param id', + $data['requirements']['param']['description'] + ); } public function testGetWithAuthentication() diff --git a/Tests/Fixtures/Controller/TestController.php b/Tests/Fixtures/Controller/TestController.php index 53d57fb..79c67cb 100644 --- a/Tests/Fixtures/Controller/TestController.php +++ b/Tests/Fixtures/Controller/TestController.php @@ -73,6 +73,8 @@ class TestController * * @param int $id A nice comment * @param int $page + * @param int $paramType The param type + * @param int $param The param id */ public function myCommentedAction() { diff --git a/Tests/Fixtures/app/config/routing.yml b/Tests/Fixtures/app/config/routing.yml index 4dd5ea9..3467e05 100644 --- a/Tests/Fixtures/app/config/routing.yml +++ b/Tests/Fixtures/app/config/routing.yml @@ -20,7 +20,7 @@ test_route_4: defaults: { _controller: NelmioApiDocTestBundle:Test:any, _format: json } test_route_5: - pattern: /my-commented/{id}/{page} + pattern: /my-commented/{id}/{page}/{paramType}/{param} defaults: { _controller: NelmioApiDocTestBundle:Test:myCommented } test_route_6: diff --git a/Tests/Formatter/MarkdownFormatterTest.php b/Tests/Formatter/MarkdownFormatterTest.php index 122207e..bdba360 100644 --- a/Tests/Formatter/MarkdownFormatterTest.php +++ b/Tests/Formatter/MarkdownFormatterTest.php @@ -297,7 +297,7 @@ dependency_type[a]: * description: A nice description -### `ANY` /my-commented/{id}/{page} ### +### `ANY` /my-commented/{id}/{page}/{paramType}/{param} ### ### This method is deprecated ### @@ -312,6 +312,14 @@ _This method is useful to test if the getDocComment works._ **page** - Type: int +**paramType** + + - Type: int + - Description: The param type +**param** + + - Type: int + - Description: The param id ### `ANY` /secure-route ### diff --git a/Tests/Formatter/SimpleFormatterTest.php b/Tests/Formatter/SimpleFormatterTest.php index 8aa2819..3322a81 100644 --- a/Tests/Formatter/SimpleFormatterTest.php +++ b/Tests/Formatter/SimpleFormatterTest.php @@ -400,7 +400,7 @@ With multiple lines.', 6 => array( 'method' => 'ANY', - 'uri' => '/my-commented/{id}/{page}', + 'uri' => '/my-commented/{id}/{page}/{paramType}/{param}', 'description' => 'This method is useful to test if the getDocComment works.', 'documentation' => 'This method is useful to test if the getDocComment works. And, it supports multilines until the first \'@\' char.', @@ -418,6 +418,18 @@ And, it supports multilines until the first \'@\' char.', 'description' => '', 'requirement' => '', ), + 'paramType' => + array ( + 'dataType' => 'int', + 'description' => 'The param type', + 'requirement' => '', + ), + 'param' => + array ( + 'dataType' => 'int', + 'description' => 'The param id', + 'requirement' => '', + ), ), 'https' => false, 'description' => 'This method is useful to test if the getDocComment works.',