Issues

ZF-8373: Zend_Reflection_Docblock_Tag_Return and _Param do not recognize arrays

Description

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


/**
 * @param string[] $bar description
 */
function foo ($bar)
{}

/**
 * @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

@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.

@param      ^@(\w+)\s+([^\s]+)(?:\s+(\$\S+))?(?:\s+(.*))?
@return     ^@(\w+)\s+([^\s]+)(?:\s+(.*))?

Comments

Patch file for described changes

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