Hello Andi,

Sunday, June 5, 2005, 9:13:52 PM, you wrote:

> At 07:18 PM 6/5/2005 +0200, Marcus Boerger wrote:
>>2) PHP is all about the putting out text so nearly all objects created in
>>PHP are meant to put something onto the generated pages. Thus i think i am
>>not alone to suggest we put back the magic __toString function in place as
>>we said when we dropped it's support from 5.0. Also it is very hard to
>>explain why "echo $a . $obj" and "echo $a, $obj" output different things
>>when one is an object. Both is pretty much against the spirit of PHP -
>>easiness isn't it?

> I thought you were going to write a patch up. Did you look into it?

Sure but i lost track of all my patches. Maybe i should start a list
that stores their review state so i can bug you more :-) Joke aside
i forgot to do that so thanks for the reminder. You'll find it attached.

>>3) Is 5.1 coming out without filtering?

> Obviously not. (...). I want to try and work on an API proposal
> first because I believe the API is where the issue is and not the coding...

Cool :-)

>>5) tons of other stuff i menationed offline and in public - since i lost
>>the energy in tracking all that issues i guess the work and time in those
>>wasn't worse the effort and they can wait anyway :-)

> Yes (...). Most important is to make sure that PHP 5.1 is only better and not
> worse than PHP 5.0, which I'm confident it is. And bringing PDO to the PHP
> community, and allowing for Unicode work to fold into PHP dev tree is the 
> most important goal.

It is already much faster and i heared many people claiming 5.0 was to slow.
Also going for unicode seems very important.

marcus
Index: tests/classes/tostring.phpt
===================================================================
RCS file: /repository/php-src/tests/classes/tostring.phpt,v
retrieving revision 1.5
diff -u -p -d -r1.5 tostring.phpt
--- tests/classes/tostring.phpt 28 Mar 2004 14:09:47 -0000      1.5
+++ tests/classes/tostring.phpt 5 Jun 2005 19:50:35 -0000
@@ -34,9 +34,11 @@ echo "string:".$o;
 
 echo "====test5====\n";
 echo 1 . $o;
+echo 1 . $o;
 
 echo "====test6====\n";
 echo $o.$o;
+echo $o,$o;
 
 echo "====test7====\n";
 $ar = array();
@@ -56,8 +58,10 @@ echo sprintf("%s", $o);
 test1 Object
 (
 )
-string(1%d) "Object id #%d"
-object(test1)#%d (%d) {
+
+Notice: Object of class test1 could not be converted to string in 
%stostring.php on line %d
+string(12) "Object id #%d"
+object(test1)#%d (0) {
 }
 ====test2====
 test2 Object
@@ -65,22 +69,38 @@ test2 Object
 )
 test2::__toString()
 Converted
-object(test2)#%d (%d) {
+object(test2)#%d (0) {
 }
 ====test3====
 test2::__toString()
 Converted
 ====test4====
-string:Object id #%d====test5====
-1Object id #%d====test6====
-Object id #%dObject id #2====test7====
+test2::__toString()
+string:Converted
+====test5====
+test2::__toString()
+1Converted
+test2::__toString()
+1Converted
+====test6====
+test2::__toString()
+test2::__toString()
+Converted
+Converted
+test2::__toString()
+Converted
+test2::__toString()
+Converted
+====test7====
 test2::__toString()
 
 Warning: Illegal offset type in %stostring.php on line %d
 ====test8====
-
-Notice: Object of class test2 to string conversion in %stostring.php on line %d
-string(6) "Object"
-string(1%d) "Object id #%d"
+test2::__toString()
+string(9) "Converted"
+test2::__toString()
+string(9) "Converted"
 ====test9====
-Object id #%d====DONE!====
+test2::__toString()
+Converted
+====DONE!====
Index: Zend/zend.c
===================================================================
RCS file: /repository/ZendEngine2/zend.c,v
retrieving revision 1.301
diff -u -p -d -r1.301 zend.c
--- Zend/zend.c 22 May 2005 11:10:38 -0000      1.301
+++ Zend/zend.c 5 Jun 2005 19:50:35 -0000
@@ -216,7 +216,7 @@ ZEND_API void zend_make_printable_zval(z
                case IS_OBJECT:
                        {
                                TSRMLS_FETCH();
-#if 0
+
                                /* Standard PHP objects */
                                if (Z_OBJ_HT_P(expr) == &std_object_handlers || 
!Z_OBJ_HT_P(expr)->cast_object) {
                                        if (zend_std_cast_object_tostring(expr, 
expr_copy, IS_STRING, 0 TSRMLS_CC) == SUCCESS) {
@@ -224,7 +224,6 @@ ZEND_API void zend_make_printable_zval(z
                                        }
                                        zend_error(E_NOTICE, "Object of class 
%s could not be converted to string", Z_OBJCE_P(expr)->name);
                                }
-#endif
                                if (Z_OBJ_HANDLER_P(expr, cast_object)) {
                                        if(Z_OBJ_HANDLER_P(expr, 
cast_object)(expr, expr_copy, IS_STRING, 0 TSRMLS_CC) == SUCCESS) {
                                                break;
Index: Zend/zend_object_handlers.c
===================================================================
RCS file: /repository/ZendEngine2/zend_object_handlers.c,v
retrieving revision 1.125
diff -u -p -d -r1.125 zend_object_handlers.c
--- Zend/zend_object_handlers.c 18 May 2005 15:30:35 -0000      1.125
+++ Zend/zend_object_handlers.c 5 Jun 2005 19:50:36 -0000
@@ -894,13 +894,11 @@ ZEND_API int zend_std_cast_object_tostri
                case IS_STRING:
                        ZVAL_STRING(&fname, "__tostring", 0);
                        if (call_user_function_ex(NULL, &readobj, &fname, 
&retval, 0, NULL, 0, NULL TSRMLS_CC) == SUCCESS) {
-                               if (retval) {
-                                       if (Z_TYPE_P(retval) != IS_STRING) {
-                                               zend_error(E_ERROR, "Method 
%s::__toString() must return a string value", Z_OBJCE_P(readobj)->name);
-                                       }
-                               } else {
-                                       MAKE_STD_ZVAL(retval);
-                                       ZVAL_STRINGL(retval, "", 0, 1);
+                               if (! retval || Z_TYPE_P(retval) != IS_STRING) {
+                                       zend_error(E_ERROR, "Method 
%s::__toString() must return a string value", Z_OBJCE_P(readobj)->name);
+                                       INIT_PZVAL(writeobj);
+                                       ZVAL_STRINGL(writeobj, "", 0, 1);
+                                       return FAILURE;
                                }
                                *writeobj = *retval;
                                zval_copy_ctor(writeobj);
@@ -939,7 +937,7 @@ ZEND_API zend_object_handlers std_object
        zend_std_object_get_class,                              /* 
get_class_entry */
        zend_std_object_get_class_name,                 /* get_class_name */
        zend_std_compare_objects,                               /* 
compare_objects */
-       NULL,                                                                   
/* cast_object */
+       zend_std_cast_object_tostring,                  /* cast_object */
        NULL,                                                                   
/* count_elements */
 };
 
-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to