Annotation of embedaddon/php/Zend/tests/bug26166.phpt, revision 1.1.1.1
1.1 misho 1: --TEST--
2: Bug #26166 (__toString() crash when no values returned)
3: --FILE--
4: <?php
5:
6: class Foo
7: {
8: function __toString()
9: {
10: return "Hello World!\n";
11: }
12: }
13:
14: class Bar
15: {
16: private $obj;
17:
18: function __construct()
19: {
20: $this->obj = new Foo();
21: }
22:
23: function __toString()
24: {
25: return $this->obj->__toString();
26: }
27: }
28:
29: $o = new Bar;
30: echo $o;
31:
32: echo "===NONE===\n";
33:
34: function my_error_handler($errno, $errstr, $errfile, $errline) {
35: var_dump($errstr);
36: }
37:
38: set_error_handler('my_error_handler');
39:
40: class None
41: {
42: function __toString() {
43: }
44: }
45:
46: $o = new None;
47: echo $o;
48:
49: echo "===THROW===\n";
50:
51: class Error
52: {
53: function __toString() {
54: throw new Exception("This is an error!");
55: }
56: }
57:
58: $o = new Error;
59: try {
60: echo $o;
61: }
62: catch (Exception $e) {
63: echo "Got the exception\n";
64: }
65:
66: ?>
67: ===DONE===
68: --EXPECTF--
69: Hello World!
70: ===NONE===
71: string(52) "Method None::__toString() must return a string value"
72: ===THROW===
73:
74: Fatal error: Method Error::__toString() must not throw an exception in %sbug26166.php on line %d
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>