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:
committed by
GitHub
parent
fb87b14b6c
commit
6009b8a100
2
NEWS
2
NEWS
@@ -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)
|
||||
|
||||
26
Zend/tests/pipe_operator_reference_context.phpt
Normal file
26
Zend/tests/pipe_operator_reference_context.phpt
Normal 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
|
||||
@@ -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;
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
|
||||
Reference in New Issue
Block a user