diff options
author | Marcus Boerger <helly@php.net> | 2003-12-15 16:59:21 +0000 |
---|---|---|
committer | Marcus Boerger <helly@php.net> | 2003-12-15 16:59:21 +0000 |
commit | d4f64f88badd33ae87b9ec9b3120d532c8352b05 (patch) | |
tree | a8830cb4ed9cc2bd3f831980a1dc4d56bd02abee /tests | |
parent | 18096396d2e0d0545946a09087ec633f250b9dfd (diff) | |
download | php-git-d4f64f88badd33ae87b9ec9b3120d532c8352b05.tar.gz |
Reenable __tostring() magic for print,echo,concatenation,function naming...
but not for other internal things.
# As discussed with Andi
Diffstat (limited to 'tests')
-rw-r--r-- | tests/classes/tostring.phpt | 46 |
1 files changed, 41 insertions, 5 deletions
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!==== |