doc comments picked up from previous scanner run

 [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 */"

 [2013-06-16 22:29 UTC] stas@php.net

-Status: Open +Status: Closed