Annotation of embedaddon/php/tests/classes/tostring_004.phpt, revision 1.1.1.1

1.1       misho       1: --TEST--
                      2: Object to string conversion: error cases and behaviour variations.
                      3: --FILE--
                      4: <?php
                      5: function test_error_handler($err_no, $err_msg, $filename, $linenum, $vars) {
                      6:         echo "Error: $err_no - $err_msg\n";
                      7: }
                      8: set_error_handler('test_error_handler');
                      9: error_reporting(8191);
                     10: 
                     11: 
                     12: echo "Object with no __toString():\n";
                     13: $obj = new stdClass;
                     14: echo "Try 1:\n";
                     15: printf($obj);
                     16: printf("\n");
                     17: 
                     18: echo "\nTry 2:\n";
                     19: printf($obj . "\n");
                     20: 
                     21: 
                     22: echo "\n\nObject with bad __toString():\n";
                     23: class badToString {
                     24:        function __toString() {
                     25:                return 0;
                     26:        }       
                     27: }
                     28: $obj = new badToString;
                     29: echo "Try 1:\n";
                     30: printf($obj);
                     31: printf("\n");
                     32: 
                     33: echo "\nTry 2:\n";
                     34: printf($obj . "\n");
                     35: 
                     36: ?>
                     37: --EXPECTF--
                     38: Object with no __toString():
                     39: Try 1:
                     40: Error: 4096 - Object of class stdClass could not be converted to string
                     41: Error: 8 - Object of class stdClass to string conversion
                     42: Object
                     43: 
                     44: Try 2:
                     45: Error: 4096 - Object of class stdClass could not be converted to string
                     46: 
                     47: 
                     48: 
                     49: Object with bad __toString():
                     50: Try 1:
                     51: Error: 4096 - Method badToString::__toString() must return a string value
                     52: 
                     53: 
                     54: Try 2:
                     55: Error: 4096 - Method badToString::__toString() must return a string value
                     56: 

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>