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: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: jonathan at moo dot com
New email:
PHP Version: OS:

 

 [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

Pull Requests

Pull requests:

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
 [2014-10-07 23:18 UTC] stas@php.net
Automatic comment on behalf of stas
Revision: http://git.php.net/?p=php-src-security.git;a=commit;h=2208447d428542960c73cfeceaf52e95ff0ca2d0
Log: Fix bug #64936 - clean doc comment state at the beginning and end of the scan
 [2014-10-07 23:29 UTC] stas@php.net
Automatic comment on behalf of stas
Revision: http://git.php.net/?p=php-src-security.git;a=commit;h=2208447d428542960c73cfeceaf52e95ff0ca2d0
Log: Fix bug #64936 - clean doc comment state at the beginning and end of the scan
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Nov 21 11:01:29 2024 UTC