ZF-8373: Zend_Reflection_Docblock_Tag_Return and _Param do not recognize arrays

Issue Type: Bug Created: 2009-11-23T08:05:12.000+0000 Last Updated: 2011-08-26T17:36:28.000+0000 Status: Resolved Fix version(s): - 1.11.11 (29/Sep/11)

Reporter: Daniel Kreuer (dkreuer) Assignee: Ralph Schindler (ralph) Tags: - Zend_Reflection

  • zf-crteam-padraic
  • zf-crteam-priority

Related issues: Attachments: - regex.patch


It's common (at least to me) to specify arrays in docblocks in either one of two ways:

<pre class="highlight">
 * @param string[] $bar description
function foo ($bar)

<pre class="highlight">
 * @param array(string) $bar description
function foo ($bar)

The actual implementation of Zend_Reflection_Docblock_Tag_Return and Zend_Reflection_Docblock_Tag_Param does not recognize these array specifications (but Zend_Server_Reflection does at least the first). Worse, if using one of these array specifications, neither the correct type nor the description are parsed correctly.

In case 1 the reflection would contain: type => "string" description => NULL

In case 2 the reflection would contain: type => "array" description => NULL

The regex used are

<pre class="literal">
@param      ^@(\w+)\s+([\w|\\\]+)(?:\s+(\$\S+))?(?:\s+(.*))?
@return     ^@(\w+)\s+([\w|\\\]+)(?:\s+(.*))?

With the following regexes at least all components will be matched, whereas I don't know if it's sufficient.

<pre class="literal">
@param      ^@(\w+)\s+([^\s]+)(?:\s+(\$\S+))?(?:\s+(.*))?
@return     ^@(\w+)\s+([^\s]+)(?:\s+(.*))?


Posted by Daniel Kreuer (dkreuer) on 2009-11-23T08:09:28.000+0000

Patch file for described changes

Posted by Ralph Schindler (ralph) on 2011-08-26T17:36:28.000+0000

Fixed in r24405 of release branch 1.11 and in r24404 of trunk

Have you found an issue?

See the Overview section for more details.


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

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