diff options
author | Marcus Boerger <helly@php.net> | 2003-11-08 14:06:08 +0000 |
---|---|---|
committer | Marcus Boerger <helly@php.net> | 2003-11-08 14:06:08 +0000 |
commit | 316854323d63ed98cb0ce289a5ffd17f9ee938d0 (patch) | |
tree | f70748696fd9420dd73445493f3dccf5e05b9759 /Zend/tests/bug26166.phpt | |
parent | ed451570470ebaf24ffe2a2d20403c6749d32318 (diff) | |
download | php-git-316854323d63ed98cb0ce289a5ffd17f9ee938d0.tar.gz |
Handle exceptions in casting more gracefully.
This fixes bug #26166
Diffstat (limited to 'Zend/tests/bug26166.phpt')
-rwxr-xr-x | Zend/tests/bug26166.phpt | 67 |
1 files changed, 67 insertions, 0 deletions
diff --git a/Zend/tests/bug26166.phpt b/Zend/tests/bug26166.phpt new file mode 100755 index 0000000000..46a8e3a614 --- /dev/null +++ b/Zend/tests/bug26166.phpt @@ -0,0 +1,67 @@ +--TEST-- +Bug #26166: __toString() crash when no values returned +--FILE-- +<?php +class Foo +{ + function __toString() + { + return "Hello World!\n"; + } +} + +class Bar +{ + private $obj; + + function __construct() + { + $this->obj = new Foo(); + } + + function __toString() + { + return $this->obj->__toString(); + } +} + +$o = new Bar; +echo $o; + +echo "===THROW===\n"; + +class Error +{ + function __toString() { + throw new Exception("This is an error!"); + } +} + +$o = new Error; +try { + echo $o; +} +catch (Exception $e) { + echo "Got the exception\n"; +} + +echo "===NONE===\n"; + +class None +{ + function __toString() { + } +} + +$o = new None; +echo $o; + +?> +===DONE=== +--EXPECTF-- +Hello World! +===THROW=== +Got the exception +===NONE=== + +Fatal error: Method none::__toString() must return a string value in %sbug26166.php on line %d |