Skip to content

Commit d87c9bd

Browse files
committed
zend_inheritance: Improve placement of return-by-ref & in zend_get_function_declaration()
The space after `&` looked super odd. Remove it and put the `&` right before the function name (after the class name), matching the actual syntax for declaring a by-ref return.
1 parent f905950 commit d87c9bd

File tree

4 files changed

+7
-7
lines changed

4 files changed

+7
-7
lines changed

Zend/tests/inheritance/argument_restriction_001.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,4 @@ class Sub extends Base {
1313
}
1414
?>
1515
--EXPECTF--
16-
Fatal error: Declaration of & Sub::test() must be compatible with & Base::test($foo, array $bar, $option = null, $extra = 'llllllllll...') in %s on line %d
16+
Fatal error: Declaration of Sub::&test() must be compatible with Base::&test($foo, array $bar, $option = null, $extra = 'llllllllll...') in %s on line %d

Zend/tests/objects/objects_005.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,4 @@ class test3 extends test {
1919

2020
?>
2121
--EXPECTF--
22-
Fatal error: Declaration of test3::foo() must be compatible with & test::foo() in %s on line %d
22+
Fatal error: Declaration of test3::foo() must be compatible with test::&foo() in %s on line %d

Zend/tests/property_hooks/get_by_ref_implemented_by_val.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,4 @@ class A implements I {
1515

1616
?>
1717
--EXPECTF--
18-
Fatal error: Declaration of A::$prop::get() must be compatible with & I::$prop::get() in %s on line %d
18+
Fatal error: Declaration of A::$prop::get() must be compatible with I::&$prop::get() in %s on line %d

Zend/zend_inheritance.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -915,10 +915,6 @@ static ZEND_COLD zend_string *zend_get_function_declaration(
915915
{
916916
smart_str str = {0};
917917

918-
if (fptr->op_array.fn_flags & ZEND_ACC_RETURN_REFERENCE) {
919-
smart_str_appends(&str, "& ");
920-
}
921-
922918
if (fptr->common.scope) {
923919
if (fptr->common.scope->ce_flags & ZEND_ACC_ANON_CLASS) {
924920
/* cut off on NULL byte ... class@anonymous */
@@ -929,6 +925,10 @@ static ZEND_COLD zend_string *zend_get_function_declaration(
929925
smart_str_appends(&str, "::");
930926
}
931927

928+
if (fptr->op_array.fn_flags & ZEND_ACC_RETURN_REFERENCE) {
929+
smart_str_appendc(&str, '&');
930+
}
931+
932932
smart_str_append(&str, fptr->common.function_name);
933933
smart_str_appendc(&str, '(');
934934

0 commit comments

Comments
 (0)