- Add returnsByRef property to FunctionDef entity - Remove restriction on reference return types in Preprocessor - Implement proper reference return handling in CompilerBase - Add validation for reference assignment from function calls - Update Translator to generate correct C++ code for reference returns - Add compatibility checks for method override with reference returns - Include test case for function returning by reference preserving aliasespull/16/head
parent
86b4d64d7d
commit
128bfa7e85
7 changed files with 101 additions and 7 deletions
@ -0,0 +1,4 @@ |
|||||||
|
<?php |
||||||
|
$requireAlias =& value_ref(); |
||||||
|
$requireAlias = 'from require'; |
||||||
|
?> |
||||||
@ -0,0 +1,39 @@ |
|||||||
|
--TEST-- |
||||||
|
function returning by reference preserves aliases |
||||||
|
--FILE-- |
||||||
|
<?php |
||||||
|
function &value_ref() |
||||||
|
{ |
||||||
|
global $value; |
||||||
|
return $value; |
||||||
|
} |
||||||
|
function main() |
||||||
|
{ |
||||||
|
global $value; |
||||||
|
$value = 1; |
||||||
|
$alias =& value_ref(); |
||||||
|
$alias = 42; |
||||||
|
var_dump(value_ref()); |
||||||
|
|
||||||
|
$localAlias =& local_ref(); |
||||||
|
$localAlias = 'kept alive'; |
||||||
|
var_dump($localAlias); |
||||||
|
|
||||||
|
eval('$evalAlias =& value_ref(); $evalAlias = "from eval";'); |
||||||
|
var_dump(value_ref()); |
||||||
|
|
||||||
|
require __DIR__ . '/function-return-reference-require.inc'; |
||||||
|
var_dump(value_ref()); |
||||||
|
} |
||||||
|
|
||||||
|
function &local_ref() |
||||||
|
{ |
||||||
|
$value = 1; |
||||||
|
return $value; |
||||||
|
} |
||||||
|
?> |
||||||
|
--EXPECT-- |
||||||
|
int(42) |
||||||
|
string(10) "kept alive" |
||||||
|
string(9) "from eval" |
||||||
|
string(12) "from require" |
||||||
Loading…
Reference in new issue