ZF-6726: Allow a tag with no parameters and multiple spaces between tag/value/description

Description

Hi!

It would be great to allow a single tag and multiple spaces in tags. E.g. i annotated all my service methods with @service, but zend_reflection complains because no value is present

I also like to "format" my tags:


* @myfirsttag
* @mysecondtag tagvalue
* @param       int    $var
* @return      string some value

These changes are done with minor regular-expression-updates:


--- Tag.php (revision 15636)
+++ Tag.php (working copy)
@@ -55,7 +55,7 @@
-        if (!preg_match('#^@(\w+)\s#', $tagDocblockLine, $matches)) {
+        if (!preg_match('#^@(\w+)(\s|$)#', $tagDocblockLine, $matches)) {
@@ -107,13 +107,13 @@
-        if (!preg_match('#^@(\w+)\s(.*)?#', $tagDocblockLine, $matches)) {
+        if (!preg_match('#^@(\w+)(?:\s+([^\s].*)|$)?#', $tagDocblockLine, $matches)) {
===================================================================
--- Tag/Param.php   (revision 15636)
+++ Tag/Param.php   (working copy)
@@ -49,7 +49,7 @@
-        if (!preg_match('#^@(\w+)\s(\w+)(?:\s(\$\S+))?(?:\s(.*))?#s', $tagDocblockLine, $matches)) {
+        if (!preg_match('#^@(\w+)\s+(\w+)(?:\s(\$\S+))?(?:\s([^\s].*))?#s', $tagDocblockLine, $matches)) {
===================================================================
--- Tag/Return.php  (revision 15636)
+++ Tag/Return.php  (working copy)
@@ -43,7 +43,7 @@
-        if (!preg_match('#^@(\w+)\s(\w+)(?:\s(.*))?#', $tagDocblockLine, $matches)) {
+        if (!preg_match('#^@(\w+)\s+(\w+)(?:\s+([^\s].*))?#', $tagDocblockLine, $matches)) {

thanks.

Comments

I also know now why a single-tag did work under windows and not under linux: because of \r\n newlines the $tagDocblockLine contains the \r!

So the expression "@\w+\s" did match becuase \s matches \r's

maybe we should add a change request for this issue too?

regards, Daniel.

Unit tests for this issue. Fail before fix.

Patch file fixing issue. New tests all pass.

Ralph,

I have the changeset for this issue and ZF-7227 waiting for your okay. Let me know if there are any problems and I'll fix/commit.

Regards, Carlton

Carlton can you please commit this fixes? I cant review them without them being in trunk :-)

Okay: Committed revision 18072.

Ralph said he'd review the patch, then I'd commit. Still learning. :-)

Merged to 1.9 release branch by r18160