]> granicus.if.org Git - php/commitdiff
Removed Closure::__toString()
authorDmitry Stogov <dmitry@php.net>
Thu, 31 Jul 2008 07:10:43 +0000 (07:10 +0000)
committerDmitry Stogov <dmitry@php.net>
Thu, 31 Jul 2008 07:10:43 +0000 (07:10 +0000)
Zend/tests/closure_015.phpt
Zend/zend_closures.c

index ee1e485b91e9545a433603c11547561925b024a1..debcc2e6409a3578d2f51d6424104a34623a4589 100644 (file)
@@ -2,6 +2,11 @@
 Closure 015: converting to string/unicode
 --FILE--
 <?php
+set_error_handler('myErrorHandler', E_RECOVERABLE_ERROR);
+function myErrorHandler($errno, $errstr, $errfile, $errline) {
+  echo "Error: $errstr at $errfile($errline)\n";
+  return true;
+}
 $x = function() { return 1; };
 print (string) $x;
 print "\n";
@@ -10,7 +15,9 @@ print "\n";
 print $x;
 print "\n";
 ?>
---EXPECT--
-Closure object
-Closure object
-Closure object
+--EXPECTF--
+Error: Object of class Closure could not be converted to string at %sclosure_015.php(8)
+
+Error: Object of class Closure could not be converted to string at %sclosure_015.php(10)
+
+Error: Object of class Closure could not be converted to string at %sclosure_015.php(12)
index 8a83f2bfcf6a44a5b8eee82f8d87c217b0214516..bdfcee2757adc7d102c971202bcbbd9334f1397d 100644 (file)
@@ -85,30 +85,6 @@ static int zend_closure_compare_objects(zval *o1, zval *o2 TSRMLS_DC) /* {{{ */
 }
 /* }}} */
 
-static int zend_closure_cast_object_tostring(zval *readobj, zval *writeobj, int type, void *extra TSRMLS_DC) /* {{{ */
-{
-       zend_class_entry *ce;
-
-       switch (type) {
-               case IS_STRING:
-                       INIT_PZVAL(writeobj);
-                       ZVAL_STRINGL(writeobj, ZEND_CLOSURE_PRINT_NAME, sizeof(ZEND_CLOSURE_PRINT_NAME)-1, 1);
-                       return SUCCESS;
-               case IS_UNICODE:
-                       INIT_PZVAL(writeobj);
-                       ZVAL_UNICODEL(writeobj, USTR_MAKE(ZEND_CLOSURE_PRINT_NAME), sizeof(ZEND_CLOSURE_PRINT_NAME)-1, 0);
-                       return SUCCESS;
-               default:
-                       ce = Z_OBJCE_P(readobj);
-                       zend_error(E_NOTICE, "Object of class %v could not be converted to %s", ce->name, zend_get_type_by_const(type));
-                       INIT_PZVAL(writeobj);
-                       Z_TYPE_P(writeobj) = IS_NULL;
-                       break;
-       }
-       return FAILURE;
-}
-/* }}} */
-
 static zend_function *zend_closure_get_method(zval **object_ptr, zstr method_name, int method_len TSRMLS_DC) /* {{{ */
 {
        unsigned int lc_name_len;
@@ -235,7 +211,6 @@ void zend_register_closure_ce(TSRMLS_D) /* {{{ */
        closure_handlers.has_property = zend_closure_has_property;
        closure_handlers.unset_property = zend_closure_unset_property;
        closure_handlers.compare_objects = zend_closure_compare_objects;
-       closure_handlers.cast_object = zend_closure_cast_object_tostring;
        closure_handlers.clone_obj = NULL;
 }
 /* }}} */