Merge pull request #179 from lightglitch/fix-178

Fix parameter name boundary in regex
This commit is contained in:
William Durand 2013-05-06 01:00:51 -07:00
commit 5567f74692
6 changed files with 40 additions and 4 deletions

View File

@ -323,7 +323,7 @@ class ApiDocExtractor
} }
} }
$regexp = '{(\w*) *\$%s *(.*)}i'; $regexp = '{(\w*) *\$%s\b *(.*)}i';
foreach ($route->compile()->getVariables() as $var) { foreach ($route->compile()->getVariables() as $var) {
$found = false; $found = false;
foreach ($paramDocs as $paramDoc) { foreach ($paramDocs as $paramDoc) {

View File

@ -153,6 +153,20 @@ class ApiDocExtractorTest extends WebTestCase
"This method is useful to test if the getDocComment works.", "This method is useful to test if the getDocComment works.",
$annotation->getDescription() $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() public function testGetWithAuthentication()

View File

@ -73,6 +73,8 @@ class TestController
* *
* @param int $id A nice comment * @param int $id A nice comment
* @param int $page * @param int $page
* @param int $paramType The param type
* @param int $param The param id
*/ */
public function myCommentedAction() public function myCommentedAction()
{ {

View File

@ -20,7 +20,7 @@ test_route_4:
defaults: { _controller: NelmioApiDocTestBundle:Test:any, _format: json } defaults: { _controller: NelmioApiDocTestBundle:Test:any, _format: json }
test_route_5: test_route_5:
pattern: /my-commented/{id}/{page} pattern: /my-commented/{id}/{page}/{paramType}/{param}
defaults: { _controller: NelmioApiDocTestBundle:Test:myCommented } defaults: { _controller: NelmioApiDocTestBundle:Test:myCommented }
test_route_6: test_route_6:

View File

@ -297,7 +297,7 @@ dependency_type[a]:
* description: A nice description * description: A nice description
### `ANY` /my-commented/{id}/{page} ### ### `ANY` /my-commented/{id}/{page}/{paramType}/{param} ###
### This method is deprecated ### ### This method is deprecated ###
@ -312,6 +312,14 @@ _This method is useful to test if the getDocComment works._
**page** **page**
- Type: int - Type: int
**paramType**
- Type: int
- Description: The param type
**param**
- Type: int
- Description: The param id
### `ANY` /secure-route ### ### `ANY` /secure-route ###

View File

@ -400,7 +400,7 @@ With multiple lines.',
6 => 6 =>
array( array(
'method' => 'ANY', '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.', 'description' => 'This method is useful to test if the getDocComment works.',
'documentation' => '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.', And, it supports multilines until the first \'@\' char.',
@ -418,6 +418,18 @@ And, it supports multilines until the first \'@\' char.',
'description' => '', 'description' => '',
'requirement' => '', 'requirement' => '',
), ),
'paramType' =>
array (
'dataType' => 'int',
'description' => 'The param type',
'requirement' => '',
),
'param' =>
array (
'dataType' => 'int',
'description' => 'The param id',
'requirement' => '',
),
), ),
'https' => false, 'https' => false,
'description' => 'This method is useful to test if the getDocComment works.', 'description' => 'This method is useful to test if the getDocComment works.',