From d4f64f88badd33ae87b9ec9b3120d532c8352b05 Mon Sep 17 00:00:00 2001 From: Marcus Boerger Date: Mon, 15 Dec 2003 16:59:21 +0000 Subject: Reenable __tostring() magic for print,echo,concatenation,function naming... but not for other internal things. # As discussed with Andi --- tests/classes/tostring.phpt | 46 ++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 41 insertions(+), 5 deletions(-) (limited to 'tests') diff --git a/tests/classes/tostring.phpt b/tests/classes/tostring.phpt index 0f4c80517d..6aae070135 100644 --- a/tests/classes/tostring.phpt +++ b/tests/classes/tostring.phpt @@ -10,7 +10,8 @@ class test1 { class test2 { function __toString() { - return "Converted"; + echo __METHOD__ . "()\n"; + return "Converted\n"; } } @@ -23,10 +24,26 @@ var_dump($o); echo "====test2====\n"; $o = new test2; print_r($o); -var_dump((string)$o); +print $o; var_dump($o); -echo "====done!====\n"; +echo "====test3====\n"; +echo $o; + +echo "====test4====\n"; +echo "string:".$o; + +echo "====test5====\n"; +echo 1 . $o; + +echo "====test6====\n"; +echo $o.$o; + +echo "====test7====\n"; +$ar = array(); +$ar[$o->__toString()] = "ERROR"; +echo $ar[$o]; ?> +====DONE!==== --EXPECTF-- ====test1==== test1 Object @@ -41,7 +58,26 @@ object(test1)#%d (0) { test2 Object ( ) -string(9) "Converted" +test2::__toString() +Converted object(test2)#%d (0) { } -====done!==== +====test3==== +test2::__toString() +Converted +====test4==== +test2::__toString() +string:Converted +====test5==== +test2::__toString() +1Converted +====test6==== +test2::__toString() +test2::__toString() +Converted +Converted +====test7==== +test2::__toString() + +Warning: Illegal offset type in %stostring.php on line %d +====DONE!==== -- cgit v1.2.1