ZF-8566: Zend_Server_Reflection_Function_Abstract parsing parameter description regex only matches every second description

Issue Type: Bug Created: 2009-12-17T05:35:52.000+0000 Last Updated: 2010-11-10T23:48:07.000+0000 Status: Resolved Fix version(s): - 1.11.1 (30/Nov/10)

Reporter: Michael Weinrich (micxer) Assignee: Marco Kaiser (bate) Tags: - Zend_Server_Reflection

Related issues: Attachments: - Zend_Server_Reflection_Function_Abstract.patch


Consider a doc block like this:

<pre class="highlight">
  * Short description
  * @param array $param1 Description 1
  * @param array $param2 Description 2
  * @param int $param3 Description 3
  * @param string $param4 Description 4
  * @return array return description

The regex used for parsing the descriptions of the parameters in the _reflect() function will only match "Description 1" and "Description 3", because with each match it already matches the @ of the next @param. Therefore it skips the following parameter description and continues with the one after that.

The fix is pretty simple: Just use a lookahead so that the @ isn't already part of the match and the regex machine will consider it for further matching (see patch attached).


Posted by Tim Smith (abznak) on 2010-04-05T21:18:30.000+0000

This fix works.

Posted by Jeremy Lounder ( on 2010-11-10T16:12:28.000+0000

For ZendFramework-1.10.8 here is a patch for the fix: The file in question is: library/Zend/Server/Reflection/Function/Abstract.php

--- Abstract.php 2010-11-10 17:08:37.000000000 -0700 +++ Abstract.php 2010-11-10 17:08:45.000000000 -0700 @@ -293,7 +293,7 @@ // Get param types and description if (preg_match_all('/@param\s+([^\s]+)/m', $docBlock, $matches)) { $paramTypesTmp = $matches[1]; - if (preg_match_all('/@param\s+\S+\s+(\$\S+)\s+(.?)(@|*\/)/s', $docBlock, $matches)) + if (preg_match_all('/@param\s+\S+\s+(\$\S+)\s+(.?)(?=@|*\/)/s', $docBlock, $matches)) { $paramDesc = $matches[2]; foreach ($paramDesc as $key => $value) {

Posted by Marco Kaiser (bate) on 2010-11-10T23:47:59.000+0000

fixed in r23317

Have you found an issue?

See the Overview section for more details.


© 2006-2018 by Zend, a Rogue Wave Company. Made with by awesome contributors.

This website is built using zend-expressive and it runs on PHP 7.