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
Posted by daniel prieler (danielp) on 2009-05-19T07:40:01.000+0000
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.
Posted by Carlton Gibson (carlton) on 2009-09-02T05:44:37.000+0000
Unit tests for this issue. Fail before fix.
Posted by Carlton Gibson (carlton) on 2009-09-02T05:45:24.000+0000
Patch file fixing issue. New tests all pass.
Posted by Carlton Gibson (carlton) on 2009-09-02T05:47:11.000+0000
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
Posted by Benjamin Eberlei (beberlei) on 2009-09-08T11:50:30.000+0000
Carlton can you please commit this fixes? I cant review them without them being in trunk :-)
Posted by Carlton Gibson (carlton) on 2009-09-11T02:44:17.000+0000
Okay: Committed revision 18072.
Ralph said he'd review the patch, then I'd commit. Still learning. :-)
Posted by Carlton Gibson (carlton) on 2009-09-17T05:05:41.000+0000
Merged to 1.9 release branch by r18160