Skip to content

Commit 2241878

Browse files
committed
Fix issues
1 parent adb2677 commit 2241878

7 files changed

+101
-56
lines changed

Zend/tests/explicitSendByRef/call_user_func.phpt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,10 @@ var_dump($i);
2626

2727
?>
2828
--EXPECTF--
29-
Warning: Foo\inc() expects argument #1 ($i) to be passed by reference, value given in %s on line %d
29+
Warning: Foo\inc(): Argument #1 ($i) must be passed by reference, value given in %s on line %d
3030
int(0)
3131
int(1)
3232

33-
Warning: Foo\inc() expects argument #1 ($i) to be passed by reference, value given in %s on line %d
33+
Warning: Foo\inc(): Argument #1 ($i) must be passed by reference, value given in %s on line %d
3434
int(0)
3535
int(1)

Zend/tests/explicitSendByRef/parseErrorOnNonVariable.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@ byRef(&null);
88

99
?>
1010
--EXPECTF--
11-
Parse error: syntax error, unexpected ')', expecting %s in %s on line %d
11+
Parse error: syntax error, unexpected token ")", expecting "->" or "?->" or "{" or "[" in %s on line %d

Zend/tests/explicitSendByRef/requiredExplicitSendByRef.phpt

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -114,10 +114,10 @@ function test2($foo, &$bar) {
114114

115115
?>
116116
--EXPECT--
117-
Cannot pass parameter 2 by reference
118-
Cannot pass parameter 2 by reference
119-
Cannot pass parameter 2 by reference
120-
Cannot pass parameter 2 by reference
117+
test1(): Argument #2 ($bar) could not be passed by reference
118+
test1(): Argument #2 ($bar) could not be passed by reference
119+
test1(): Argument #2 ($bar) could not be passed by reference
120+
test1(): Argument #2 ($bar) could not be passed by reference
121121
string(6) "foobar"
122122
int(0)
123123
string(9) "foobarbaz"
@@ -126,10 +126,10 @@ string(6) "barfoo"
126126
int(2)
127127
string(6) "foobar"
128128
int(3)
129-
Cannot pass parameter 2 by reference
130-
Cannot pass parameter 2 by reference
131-
Cannot pass parameter 2 by reference
132-
Cannot pass parameter 2 by reference
129+
test2(): Argument #2 ($bar) could not be passed by reference
130+
test2(): Argument #2 ($bar) could not be passed by reference
131+
test2(): Argument #2 ($bar) could not be passed by reference
132+
test2(): Argument #2 ($bar) could not be passed by reference
133133
string(6) "foobar"
134134
int(0)
135135
string(9) "foobarbaz"

Zend/zend_execute_API.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -891,7 +891,7 @@ zend_result zend_call_function(zend_fcall_info *fci, zend_fcall_info_cache *fci_
891891

892892
if (ARG_SHOULD_BE_SENT_BY_REF(func, arg_num)) {
893893
if (UNEXPECTED(!Z_ISREF_P(arg))) {
894-
if (!ARG_MAY_BE_SENT_BY_REF(func, arg_num)) {
894+
if (ARG_MUST_BE_SENT_BY_REF(func, arg_num)) {
895895
/* By-value send is not allowed -- emit a warning,
896896
* and perform the call with the value wrapped in a reference. */
897897
zend_param_must_be_ref(func, arg_num);

Zend/zend_language_parser.y

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -904,7 +904,7 @@ argument:
904904
| identifier ':' expr
905905
{ $$ = zend_ast_create(ZEND_AST_NAMED_ARG, $1, $3); }
906906
| T_ELLIPSIS expr { $$ = zend_ast_create(ZEND_AST_UNPACK, $2); }
907-
| '&' variable { $$ = zend_ast_create(ZEND_AST_REF, $2); }
907+
| ampersand variable { $$ = zend_ast_create(ZEND_AST_REF, $2); }
908908
;
909909

910910
global_var_list:

Zend/zend_vm_def.h

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4863,7 +4863,7 @@ ZEND_VM_HOT_SEND_HANDLER(50, ZEND_SEND_VAR_NO_REF_EX, VAR, CONST|UNUSED|NUM, SPE
48634863
ZVAL_COPY_VALUE(arg, varptr);
48644864

48654865
if (EXPECTED(Z_ISREF_P(varptr) ||
4866-
QUICK_ARG_MAY_BE_SENT_BY_REF(EX(call)->func, arg_num))) {
4866+
!ARG_MUST_BE_SENT_BY_REF(EX(call)->func, arg_num))) {
48674867
ZEND_VM_NEXT_OPCODE();
48684868
}
48694869
} else {
@@ -4875,7 +4875,7 @@ ZEND_VM_HOT_SEND_HANDLER(50, ZEND_SEND_VAR_NO_REF_EX, VAR, CONST|UNUSED|NUM, SPE
48754875
ZVAL_COPY_VALUE(arg, varptr);
48764876

48774877
if (EXPECTED(Z_ISREF_P(varptr) ||
4878-
ARG_MAY_BE_SENT_BY_REF(EX(call)->func, arg_num))) {
4878+
!ARG_MUST_BE_SENT_BY_REF(EX(call)->func, arg_num))) {
48794879
ZEND_VM_NEXT_OPCODE();
48804880
}
48814881
}
@@ -5572,15 +5572,24 @@ ZEND_VM_HANDLER(120, ZEND_SEND_USER, CONST|TMP|VAR|CV, NUM, REF)
55725572

55735573
SAVE_OPLINE();
55745574

5575-
// FIXME: Re-add changes from Nikita
5576-
arg = GET_OP1_ZVAL_PTR_DEREF(BP_VAR_R);
55775575
param = ZEND_CALL_VAR(EX(call), opline->result.var);
5578-
if (UNEXPECTED(ARG_MUST_BE_SENT_BY_REF(EX(call)->func, opline->op2.num))) {
5579-
zend_param_must_be_ref(EX(call)->func, opline->op2.num);
5580-
Z_TRY_ADDREF_P(arg);
5581-
ZVAL_NEW_REF(param, arg);
5576+
if (opline->extended_value) {
5577+
arg = GET_OP1_ZVAL_PTR_PTR(BP_VAR_W);
5578+
if (Z_ISREF_P(arg)) {
5579+
Z_ADDREF_P(arg);
5580+
} else {
5581+
ZVAL_MAKE_REF_EX(arg, 2);
5582+
}
5583+
ZVAL_REF(param, Z_REF_P(arg));
55825584
} else {
5583-
ZVAL_COPY(param, arg);
5585+
arg = GET_OP1_ZVAL_PTR_DEREF(BP_VAR_R);
5586+
if (UNEXPECTED(ARG_MUST_BE_SENT_BY_REF(EX(call)->func, opline->op2.num))) {
5587+
zend_param_must_be_ref(EX(call)->func, opline->op2.num);
5588+
Z_TRY_ADDREF_P(arg);
5589+
ZVAL_NEW_REF(param, arg);
5590+
} else {
5591+
ZVAL_COPY(param, arg);
5592+
}
55845593
}
55855594

55865595
FREE_OP1();

Zend/zend_vm_execute.h

Lines changed: 70 additions & 34 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)