Req #51674 [Opn->Wfx]: Valid phpdoc comments are treated as T_COMMENT (and not T_DOC_COMMENT)
| From: | nikic@php.net | Date: | Sat, 29 Sep 2018 09:50:19 +0000 |
| Subject: | Req #51674 [Opn->Wfx]: Valid phpdoc comments are treated as T_COMMENT (and not T_DOC_COMMENT) | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-217275@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=51674&edit=1
ID: 51674
Updated by: nikic@php.net
Reported by: cogo at starzinger dot net
Summary: Valid phpdoc comments are treated as T_COMMENT (and
not T_DOC_COMMENT)
-Status: Open
+Status: Wont fix
Type: Feature/Change Request
Package: Scripting Engine problem
PHP Version: 5.3SVN-2010-04-27 (SVN)
Block user comment: N
Private report: N
New Comment:
I'm closing this as won't fix, as this syntax is, to the best of my knowledge, neither
commonly used nor widely supported. PSR-5, the closest we currently have to a specification for
phpdoc, also does not include this syntax.
Previous Comments:
------------------------------------------------------------------------
[2010-04-28 10:34:12] cogo at starzinger dot net
Since support for phpdoc was added to the lexer I don't see why it needs to be incomplete.
It's a small fix that would complete the support for it. As you say the easiest way to fix this
is to remove the whitespace requirement that was added back in 2004 (as a request from Derick I
think).
------------------------------------------------------------------------
[2010-04-27 22:19:37] colder@php.net
Complexifying the lexer just to have strange syntax introduced by phpdoc detected
as such makes little sense.
What if project FOO wants /**%%FOO%% */ to be detected as T_DOC_COMMENT as well?
------------------------------------------------------------------------
[2010-04-27 14:37:51] cogo at starzinger dot net
That would also work, but then you would allow /*** */ to be treated as T_DOC_COMMENT, which was why
the whitespace requirement was added in the first place (according to the changelog). You would also
get T_DOC_COMMENT when using /**#@- */ which is not valid according to the phpdoc manual.
------------------------------------------------------------------------
[2010-04-27 14:24:17] colder@php.net
It looks wrong to add cases for that in the lexer, I believe we should rather
simplify it by lifting the whitespace requirement after /**
------------------------------------------------------------------------
[2010-04-27 14:12:02] cogo at starzinger dot net
Description:
------------
phpdoc templates are labeled as T_COMMENT tokens, and not T_DOC_COMMENT. The reason for this is that
the language scanner requires a whitespace char following /** for phpdoc comments. phpdoc templates
use the following syntax:
Start a template:
/**#@+
*
*/
End a template:
/**#@-*/
These do not have a whitespace following /** so it is treated as a regular multiline comment.
Docs about phpdoc templates is available at http://manual.phpdoc.org/HTMLSmartyConverter/HandS/phpDocumentor/tutorial_phpDocumentor.howto.pkg.html#basics.docblocktemplate
My patch includes a change in the language scanner to include these types of comments and a changed
test in the tokenizer extension that tests for these comments as well.
The patch is made against the 5.3 branch.
This is the same issue that is mentioned in bug #26948 but the problem is not in the tokenizer
extension, but the language scanner.
Test script:
---------------
<?php
$source = '<?php
/**#@+
* Start a template
*/
/**#@-*/
/**#@- */';
foreach (token_get_all($source) as $token) {
print(token_name($token[0]) . PHP_EOL);
}
Expected result:
----------------
T_OPEN_TAG
T_DOC_COMMENT
T_WHITESPACE
T_DOC_COMMENT
T_WHITESPACE
T_COMMENT
Actual result:
--------------
T_OPEN_TAG
T_COMMENT
T_WHITESPACE
T_COMMENT
T_WHITESPACE
T_COMMENT
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=51674&edit=1