Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ PHP NEWS
- Core:
. Fixed bug GH-18850 (Repeated inclusion of file with __halt_compiler()
triggers "Constant already defined" warning). (ilutov)
. Fixed bug GH-19476 (pipe operator fails to correctly handle returning
by reference). (alexandre-daubois)

- ODBC:
. Remove ODBCVER and assume ODBC 3.5. (Calvin Buckley)
Expand Down
26 changes: 26 additions & 0 deletions Zend/tests/pipe_operator_reference_context.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
--TEST--
Fix GH-19476: Pipe operator with function returning by reference
--FILE--
<?php

function &get_ref($_): string {
static $a = "original";

$a .= " ".$_;

return $a;
}

function &test_pipe_ref(): string {
return "input" |> get_ref(...);
}

$ref = &test_pipe_ref();
echo "Before: " . $ref . "\n";
$ref = "changed";
echo "After: " . test_pipe_ref() . "\n";

?>
--EXPECT--
Before: original input
After: changed input
3 changes: 2 additions & 1 deletion Zend/zend_compile.c
Original file line number Diff line number Diff line change
Expand Up @@ -2726,7 +2726,8 @@ static inline bool zend_is_call(zend_ast *ast) /* {{{ */
return ast->kind == ZEND_AST_CALL
|| ast->kind == ZEND_AST_METHOD_CALL
|| ast->kind == ZEND_AST_NULLSAFE_METHOD_CALL
|| ast->kind == ZEND_AST_STATIC_CALL;
|| ast->kind == ZEND_AST_STATIC_CALL
|| ast->kind == ZEND_AST_PIPE;
}
/* }}} */

Expand Down