File tree Expand file tree Collapse file tree 2 files changed +94
-0
lines changed Expand file tree Collapse file tree 2 files changed +94
-0
lines changed Original file line number Diff line number Diff line change
1
+ --TEST--
2
+ Observer: Function calls from a shutdown handler are observable
3
+ --SKIPIF--
4
+ <?php if (!extension_loaded ('zend-test ' )) die ('skip: zend-test extension required ' ); ?>
5
+ --INI--
6
+ zend_test.observer.enabled=1
7
+ zend_test.observer.observe_all=1
8
+ zend_test.observer.show_return_value=1
9
+ --FILE--
10
+ <?php
11
+ register_shutdown_function (function () {
12
+ echo 'Shutdown: ' . foo () . PHP_EOL ;
13
+ });
14
+
15
+ function bar () {
16
+ return 42 ;
17
+ }
18
+
19
+ function foo () {
20
+ bar ();
21
+ return bar ();
22
+ }
23
+
24
+ echo 'Done: ' . bar () . PHP_EOL ;
25
+ ?>
26
+ --EXPECTF--
27
+ <!-- init '%s/observer_shutdown_%d.php' -->
28
+ <file '%s/observer_shutdown_%d.php'>
29
+ <!-- init bar() -->
30
+ <bar>
31
+ </bar:42>
32
+ Done: 42
33
+ </file '%s/observer_shutdown_%d.php'>
34
+ <!-- init {closure}() -->
35
+ <{closure}>
36
+ <!-- init foo() -->
37
+ <foo>
38
+ <bar>
39
+ </bar:42>
40
+ <bar>
41
+ </bar:42>
42
+ </foo:42>
43
+ Shutdown: 42
44
+ </{closure}:NULL>
Original file line number Diff line number Diff line change
1
+ --TEST--
2
+ Observer: Function calls from a __destruct during shutdown are observable
3
+ --SKIPIF--
4
+ <?php if (!extension_loaded ('zend-test ' )) die ('skip: zend-test extension required ' ); ?>
5
+ --INI--
6
+ zend_test.observer.enabled=1
7
+ zend_test.observer.observe_all=1
8
+ zend_test.observer.show_return_value=1
9
+ --FILE--
10
+ <?php
11
+ class MyClass
12
+ {
13
+ public function __destruct ()
14
+ {
15
+ echo 'Shutdown: ' . foo () . PHP_EOL ;
16
+ }
17
+ }
18
+
19
+ function bar () {
20
+ return 42 ;
21
+ }
22
+
23
+ function foo () {
24
+ bar ();
25
+ return bar ();
26
+ }
27
+
28
+ $ mc = new MyClass ();
29
+
30
+ echo 'Done: ' . bar () . PHP_EOL ;
31
+ ?>
32
+ --EXPECTF--
33
+ <!-- init '%s/observer_shutdown_%d.php' -->
34
+ <file '%s/observer_shutdown_%d.php'>
35
+ <!-- init bar() -->
36
+ <bar>
37
+ </bar:42>
38
+ Done: 42
39
+ </file '%s/observer_shutdown_%d.php'>
40
+ <!-- init MyClass::__destruct() -->
41
+ <MyClass::__destruct>
42
+ <!-- init foo() -->
43
+ <foo>
44
+ <bar>
45
+ </bar:42>
46
+ <bar>
47
+ </bar:42>
48
+ </foo:42>
49
+ Shutdown: 42
50
+ </MyClass::__destruct:NULL>
You can’t perform that action at this time.
0 commit comments