-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[3.0] Test for changing returning value by deferred code (#17)
- Loading branch information
1 parent
6c57294
commit 1700096
Showing
3 changed files
with
35 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
--INI-- | ||
track_errors=0 | ||
--FILE-- | ||
<?php | ||
|
||
// example in GO https://play.golang.org/p/8RGPPPQLgQu | ||
|
||
require \implode(\DIRECTORY_SEPARATOR, array(__DIR__, '..', '..', 'vendor', 'autoload.php')); | ||
|
||
/** | ||
* Function must return value by reference. | ||
*/ | ||
function &foo() | ||
{ | ||
// variable $result must be passed to anonymous function by reference | ||
defer($_, function () use (&$result) { | ||
$result = 'Change World'; | ||
}); | ||
|
||
$result = 'Hello World'; | ||
|
||
return $result; | ||
} | ||
|
||
echo foo(); | ||
|
||
?> | ||
--EXPECT-- | ||
Change World |