Edit report at http://bugs.php.net/bug.php?id=51674&edit=1

 ID:          51674
 Comment by:  cogo at starzinger dot net
 Reported by: cogo at starzinger dot net
 Summary:     Valid phpdoc comments are treated as T_COMMENT (and not
              T_DOC_COMMENT)
 Status:      Open
 Type:        Feature/Change Request
 Package:     Scripting Engine problem
 PHP Version: 5.3SVN-2010-04-27 (SVN)

 New Comment:

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


Previous Comments:
------------------------------------------------------------------------
[2010-04-27 22:19:37] [email protected]

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] [email protected]

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 http://bugs.php.net/bug.php?id=51674&edit=1

Reply via email to