Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit fb1019f

Browse files
committed
Add a test to ensure the return variable prior to the end observer executing
1 parent ac862c2 commit fb1019f

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
--TEST--
2+
Observer: Retvals are modifiable by observers
3+
--EXTENSIONS--
4+
zend_test
5+
--INI--
6+
zend_test.observer.enabled=1
7+
zend_test.observer.show_output=1
8+
zend_test.observer.show_return_value=1
9+
zend_test.observer.observe_function_names=foo
10+
zend_test.observer.observe_end_call_function_name=hook
11+
--FILE--
12+
<?php
13+
function foo(string $pin): string {
14+
15+
return 'original return value';
16+
}
17+
18+
function hook(): string {
19+
return 'hook value';
20+
}
21+
22+
$res = foo('some value'); // Retval used
23+
var_dump($res);
24+
echo 'Done' . PHP_EOL;
25+
?>
26+
--EXPECTF--
27+
<!-- init '%s/observer_retval_alter_%d.php' -->
28+
<!-- init foo() -->
29+
<foo>
30+
<!-- init hook() -->
31+
</foo:'original return value'>
32+
<!-- init var_dump() -->
33+
string(10) "hook value"
34+
Done

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /