File tree Expand file tree Collapse file tree 1 file changed +53
-0
lines changed Expand file tree Collapse file tree 1 file changed +53
-0
lines changed Original file line number Diff line number Diff line change
1
+ --TEST--
2
+ Observer: Generator with uncaught exception
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
+ function fooResults () {
12
+ yield 0 ;
13
+ yield 1 ;
14
+ throw new RuntimeException ('Oops! ' );
15
+ }
16
+
17
+ function doSomething () {
18
+ $ generator = fooResults ();
19
+ foreach ($ generator as $ value ) {
20
+ echo $ value . PHP_EOL ;
21
+ }
22
+
23
+ return 'You should not see this ' ;
24
+ }
25
+
26
+ echo doSomething () . PHP_EOL ;
27
+ ?>
28
+ --EXPECTF--
29
+ <!-- init '%s/observer_generator_%d.php' -->
30
+ <file '%s/observer_generator_%d.php'>
31
+ <!-- init doSomething() -->
32
+ <doSomething>
33
+ <!-- init fooResults() -->
34
+ <fooResults>
35
+ </fooResults:0>
36
+ 0
37
+ <fooResults>
38
+ </fooResults:1>
39
+ 1
40
+ <fooResults>
41
+ <!-- Exception: RuntimeException -->
42
+ </fooResults:NULL>
43
+ <!-- Exception: RuntimeException -->
44
+ </doSomething:NULL>
45
+ <!-- Exception: RuntimeException -->
46
+ </file '%s/observer_generator_%d.php'>
47
+
48
+ Fatal error: Uncaught RuntimeException: Oops! in %s/observer_generator_%d.php:%d
49
+ Stack trace:
50
+ #0 %s/observer_generator_%d.php(%d): fooResults()
51
+ #1 %s/observer_generator_%d.php(%d): doSomething()
52
+ #2 {main}
53
+ thrown in %s/observer_generator_%d.php on line %d
You can’t perform that action at this time.
0 commit comments