php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #64936 doc comments picked up from previous scanner run
Submitted: 2013-05-28 12:58 UTC Modified: -
From: jonathan at moo dot com Assigned:
Status: Closed Package: Reflection related
PHP Version: master-Git-2013-05-28 (Git) OS:
Private report: No CVE-ID:
 [2013-05-28 12:58 UTC] jonathan at moo dot com
Description:
------------
The doc_comment compiler global is not reset when scanning of a new file/string 
starts. This leads to the last doc_comment seen by the tokenizer, but unclaimed 
by anything, being incorrectly assigned to the next thing the compiler sees.

I think that the doc_comment and doc_comment_len globals should probably be 
saved/restored by zend_(save|restore)_lexical_state, and reset whenever scanning 
for a new file or string starts (pretty much everywhere zend_lineno gets 
initialised.)

Test script:
---------------
token_get_all("<?php\n/**\n * Foo\n */"); // doc_comment compiler global now contains this Foo comment

eval("class Foo { }"); // Could also be an include of a file containing similar

$rc = new ReflectionClass("Foo");
var_dump($rc->getDocComment()); // Foo shouldn't have a doc comment, and yet it does.

Expected result:
----------------
bool(false)

Actual result:
--------------
string(14) "/**\n * Foo\n */"

Patches

Add a Patch

Pull Requests

Pull requests:

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2013-06-16 22:29 UTC] stas@php.net
Automatic comment on behalf of stas
Revision: http://git.php.net/?p=php-src.git;a=commit;h=2208447d428542960c73cfeceaf52e95ff0ca2d0
Log: Fix bug #64936 - clean doc comment state at the beginning and end of the scan
 [2013-06-16 22:29 UTC] stas@php.net
-Status: Open +Status: Closed
 [2013-06-16 22:30 UTC] stas@php.net
Automatic comment on behalf of stas
Revision: http://git.php.net/?p=php-src.git;a=commit;h=2208447d428542960c73cfeceaf52e95ff0ca2d0
Log: Fix bug #64936 - clean doc comment state at the beginning and end of the scan
 
PHP Copyright © 2001-2014 The PHP Group
All rights reserved.
Last updated: Sat Apr 19 06:02:27 2014 UTC