From ccc5150f15c747fe5e9b5a17fcb135e7989d0181 Mon Sep 17 00:00:00 2001 From: Grigorii Sokolik Date: Fri, 11 Mar 2016 19:28:45 +0300 Subject: [PATCH] Fix bug #71767 --- NEWS | 2 ++ Zend/tests/grammar/regression_004.phpt | 2 +- Zend/zend_language_parser.y | 32 +++++++++---------- ext/reflection/tests/bug71767.phpt | 44 ++++++++++++++++++++++++++ 4 files changed, 63 insertions(+), 17 deletions(-) create mode 100644 ext/reflection/tests/bug71767.phpt diff --git a/NEWS b/NEWS index 1f9f3ebf9b..bf9223b6f6 100644 --- a/NEWS +++ b/NEWS @@ -23,6 +23,8 @@ PHP NEWS . Fixed bug #71575 (ISO C does not allow extra ‘;’ outside of a function). (asgrim) . Fixed bug #71724 (yield from does not count EOLs). (Nikita) + . Fixed bug #71767 (ReflectionMethod::getDocComment returns the wrong + comment). (Grigorii Sokolik) - Curl: . Fixed bug #71694 (Support constant CURLM_ADDED_ALREADY). (mpyw) diff --git a/Zend/tests/grammar/regression_004.phpt b/Zend/tests/grammar/regression_004.phpt index e95674d8c9..edb32032ea 100644 --- a/Zend/tests/grammar/regression_004.phpt +++ b/Zend/tests/grammar/regression_004.phpt @@ -12,4 +12,4 @@ class Obj function echo(){} // not valid --EXPECTF-- -Parse error: syntax error, unexpected 'echo' (T_ECHO), expecting identifier (T_STRING) or '(' in %s on line 9 +Parse error: syntax error, unexpected 'echo' (T_ECHO), expecting %s in %s on line 9 diff --git a/Zend/zend_language_parser.y b/Zend/zend_language_parser.y index 49027b787e..804ed37473 100644 --- a/Zend/zend_language_parser.y +++ b/Zend/zend_language_parser.y @@ -473,10 +473,10 @@ unset_variable: ; function_declaration_statement: - function returns_ref T_STRING '(' parameter_list ')' return_type - backup_doc_comment '{' inner_statement_list '}' - { $$ = zend_ast_create_decl(ZEND_AST_FUNC_DECL, $2, $1, $8, - zend_ast_get_str($3), $5, NULL, $10, $7); } + function returns_ref T_STRING backup_doc_comment '(' parameter_list ')' return_type + '{' inner_statement_list '}' + { $$ = zend_ast_create_decl(ZEND_AST_FUNC_DECL, $2, $1, $4, + zend_ast_get_str($3), $6, NULL, $10, $8); } ; is_reference: @@ -705,10 +705,10 @@ class_statement: { $$ = $2; RESET_DOC_COMMENT(); } | T_USE name_list trait_adaptations { $$ = zend_ast_create(ZEND_AST_USE_TRAIT, $2, $3); } - | method_modifiers function returns_ref identifier '(' parameter_list ')' - return_type backup_doc_comment method_body - { $$ = zend_ast_create_decl(ZEND_AST_METHOD, $3 | $1, $2, $9, - zend_ast_get_str($4), $6, NULL, $10, $8); } + | method_modifiers function returns_ref identifier backup_doc_comment '(' parameter_list ')' + return_type method_body + { $$ = zend_ast_create_decl(ZEND_AST_METHOD, $3 | $1, $2, $5, + zend_ast_get_str($4), $7, NULL, $10, $9); } ; name_list: @@ -959,16 +959,16 @@ expr_without_variable: | T_YIELD expr { $$ = zend_ast_create(ZEND_AST_YIELD, $2, NULL); } | T_YIELD expr T_DOUBLE_ARROW expr { $$ = zend_ast_create(ZEND_AST_YIELD, $4, $2); } | T_YIELD_FROM expr { $$ = zend_ast_create(ZEND_AST_YIELD_FROM, $2); } - | function returns_ref '(' parameter_list ')' lexical_vars return_type - backup_doc_comment '{' inner_statement_list '}' - { $$ = zend_ast_create_decl(ZEND_AST_CLOSURE, $2, $1, $8, + | function returns_ref backup_doc_comment '(' parameter_list ')' lexical_vars return_type + '{' inner_statement_list '}' + { $$ = zend_ast_create_decl(ZEND_AST_CLOSURE, $2, $1, $3, zend_string_init("{closure}", sizeof("{closure}") - 1, 0), - $4, $6, $10, $7); } - | T_STATIC function returns_ref '(' parameter_list ')' lexical_vars - return_type backup_doc_comment '{' inner_statement_list '}' - { $$ = zend_ast_create_decl(ZEND_AST_CLOSURE, $3 | ZEND_ACC_STATIC, $2, $9, + $5, $7, $10, $8); } + | T_STATIC function returns_ref backup_doc_comment '(' parameter_list ')' lexical_vars + return_type '{' inner_statement_list '}' + { $$ = zend_ast_create_decl(ZEND_AST_CLOSURE, $3 | ZEND_ACC_STATIC, $2, $4, zend_string_init("{closure}", sizeof("{closure}") - 1, 0), - $5, $7, $11, $8); } + $6, $8, $11, $9); } ; function: diff --git a/ext/reflection/tests/bug71767.phpt b/ext/reflection/tests/bug71767.phpt new file mode 100644 index 0000000000..8c4059abf4 --- /dev/null +++ b/ext/reflection/tests/bug71767.phpt @@ -0,0 +1,44 @@ +--TEST-- +Bug #71767 (ReflectionMethod::getDocComment returns the wrong comment) +--FILE-- +getDocComment() . PHP_EOL; +echo $reflectionClass->getMethod('bar')->getDocComment() . PHP_EOL; +echo $reflectionClosure->getDocComment() . PHP_EOL; + +echo "Done\n"; +?> +--EXPECTF-- +/** Correct docblock */ +/** Correct docblock */ +/** Correct docblock */ +Done -- 2.40.0