Skip to content
Closed
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 Zend/zend_language_parser.y
Original file line number Diff line number Diff line change
Expand Up @@ -1015,6 +1015,8 @@ lexical_var_list:
lexical_var:
T_VARIABLE { $$ = $1; }
| '&' T_VARIABLE { $$ = $2; $$->attr = 1; }
| '&' '$' '{' T_CONSTANT_ENCAPSED_STRING '}' { $$ = $4; $$->attr = 1; }
| '$' '{' T_CONSTANT_ENCAPSED_STRING '}' { $$ = $3; }
;

function_call:
Expand Down
14 changes: 14 additions & 0 deletions tests/func/012.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
--TEST--
Assert dynamic string variables can be imported to function scope with T_USE
--FILE--
<?php
${'+'} = function ($x, $y) { return $x + $y; };

$test_add = (function ($a, $b) use (${'+'}) {
return ${'+'}($a, $b);
})(10, 20);

echo $test_add;
?>
--EXPECT--
30
16 changes: 16 additions & 0 deletions tests/func/013.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
--TEST--
Assert dynamic reference string variables can be imported to function scope with T_USE
--FILE--
<?php
${'+'} = 10;

$test_ref = function () use (&${'+'}) {
${'+'} = 20;
};

$test_ref();

echo ${'+'};
?>
--EXPECT--
20