Browse Source

Fix bug #64936 - clean doc comment state at the beginning and end of the scan

PHP-5.4.17
Stanislav Malyshev 13 years ago
parent
commit
2208447d42
  1. 2
      NEWS
  2. 685
      Zend/zend_language_scanner.c
  3. 3
      Zend/zend_language_scanner.l
  4. 2
      Zend/zend_language_scanner_defs.h
  5. 5
      ext/reflection/tests/bug64936.inc
  6. 34
      ext/reflection/tests/bug64936.phpt

2
NEWS

@ -6,6 +6,8 @@ PHP NEWS
. Fixed bug #64988 (Class loading order affects E_STRICT warning). (Laruence)
. Fixed bug #64966 (segfault in zend_do_fcall_common_helper_SPEC). (Laruence)
. Fixed bug #64960 (Segfault in gc_zval_possible_root). (Laruence)
. Fixed bug #64936 (doc comments picked up from previous scanner run). (Stas,
Jonathan Oddy)
. Fixed bug #64934 (Apache2 TS crash with get_browser()). (Anatol)
- DateTime:

685
Zend/zend_language_scanner.c
File diff suppressed because it is too large
View File

3
Zend/zend_language_scanner.l

@ -256,6 +256,7 @@ ZEND_API void zend_restore_lexical_state(zend_lex_state *lex_state TSRMLS_DC)
CG(heredoc) = NULL;
CG(heredoc_len) = 0;
}
RESET_DOC_COMMENT();
}
ZEND_API void zend_destroy_file_handle(zend_file_handle *file_handle TSRMLS_DC)
@ -539,6 +540,7 @@ ZEND_API int open_file_for_scanning(zend_file_handle *file_handle TSRMLS_DC)
CG(zend_lineno) = 1;
}
RESET_DOC_COMMENT();
CG(increment_lineno) = 0;
return SUCCESS;
}
@ -689,6 +691,7 @@ ZEND_API int zend_prepare_string_for_scanning(zval *str, char *filename TSRMLS_D
zend_set_compiled_filename(filename TSRMLS_CC);
CG(zend_lineno) = 1;
CG(increment_lineno) = 0;
RESET_DOC_COMMENT();
return SUCCESS;
}

2
Zend/zend_language_scanner_defs.h

@ -1,4 +1,4 @@
/* Generated by re2c 0.13.5 on Wed Mar 27 23:52:29 2013 */
/* Generated by re2c 0.13.5 on Sun Jun 16 14:52:22 2013 */
#line 3 "Zend/zend_language_scanner_defs.h"
enum YYCONDTYPE {

5
ext/reflection/tests/bug64936.inc

@ -0,0 +1,5 @@
<?php
class B {
}

34
ext/reflection/tests/bug64936.phpt

@ -0,0 +1,34 @@
--TEST--
ReflectionMethod::getDocComment() uses left over doc comment from previous scanner run
--INI--
opcache.save_comments=1
opcache.load_comments=1
--FILE--
<?php
function strip_doc_comment($c)
{
if (!strlen($c) || $c === false) return $c;
return trim(substr($c, 3, -2));
}
token_get_all("<?php\n/**\n * Foo\n */"); // doc_comment compiler global now contains this Foo comment
eval('class A { }'); // Could also be an include of a file containing similar
$ra = new ReflectionClass('A');
var_dump(strip_doc_comment($ra->getDocComment()));
token_get_all("<?php\n/**\n * Foo\n */"); // doc_comment compiler global now contains this Foo comment
include('bug64936.inc');
$rb = new ReflectionClass('B');
var_dump(strip_doc_comment($rb->getDocComment()));
?>
===DONE===
--EXPECT--
bool(false)
bool(false)
===DONE===
Loading…
Cancel
Save