com php-src: Fix bug #71767: NEWS Zend/tests/grammar/regression _004.phpt Zend/zend_language_parser.y ext/r eflection/tests/bug71767.phpt
| From: | Nikita Popov | Date: | Fri, 11 Mar 2016 21:27:48 +0000 |
| Subject: | com php-src: Fix bug #71767: NEWS Zend/tests/grammar/regression _004.phpt Zend/zend_language_parser.y ext/r eflection/tests/bug71767.phpt | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-91330@lists.php.net to get a copy of this message | ||
Commit: ccc5150f15c747fe5e9b5a17fcb135e7989d0181
Author: Grigorii Sokolik <g.sokolik@delivery-club.ru> Fri, 11 Mar 2016 19:28:45
+0300
Committer: Nikita Popov <nikic@php.net> Fri, 11 Mar 2016 22:27:48 +0100
Parents: fca831e8ad05c344226566fbb9051230421d6578
Branches: PHP-7.0 master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=ccc5150f15c747fe5e9b5a17fcb135e7989d0181
Log:
Fix bug #71767
Bugs:
https://bugs.php.net/71767
Changed paths:
M NEWS
M Zend/tests/grammar/regression_004.phpt
M Zend/zend_language_parser.y
A ext/reflection/tests/bug71767.phpt
Diff:
diff --git a/NEWS b/NEWS
index 1f9f3eb..bf9223b 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 e95674d..edb3203 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 49027b7..804ed37 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 0000000..8c4059a
--- /dev/null
+++ b/ext/reflection/tests/bug71767.phpt
@@ -0,0 +1,44 @@
+--TEST--
+Bug #71767 (ReflectionMethod::getDocComment returns the wrong comment)
+--FILE--
+<?php
+
+/** Correct docblock */
+function foo(
+ /** wrong docblock */
+ $arg
+) {
+}
+
+class Foo {
+ /** Correct docblock */
+ public function bar(
+ /** wrong docblock */
+ $arg
+ ) {
+
+ }
+}
+
+/** Correct docblock */
+$func = function(
+ /** wrong docblock */
+ $arg
+) {
+};
+
+$reflectionFunction = new ReflectionFunction('foo');
+$reflectionClass = new ReflectionClass(Foo::class);
+$reflectionClosure = new ReflectionFunction($func);
+
+echo $reflectionFunction->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