1
0
mirror of https://github.com/php/php-src.git synced 2026-03-24 00:02:20 +01:00

Fix GH-19476: pipe operator fails to correctly handle returning by reference (GH-19478)

This commit is contained in:
Alexandre Daubois
2025-08-14 16:34:21 +02:00
committed by GitHub
parent fb87b14b6c
commit 6009b8a100
3 changed files with 30 additions and 1 deletions

2
NEWS
View File

@@ -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)

View File

@@ -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

View File

@@ -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;
}
/* }}} */