Removed Closure::__toString()

This commit is contained in:
Dmitry Stogov 2008-07-31 07:10:33 +00:00
parent a31dc18b39
commit f02f9b0545
2 changed files with 9 additions and 24 deletions

View file

@ -2,12 +2,18 @@
Closure 015: converting to string/unicode Closure 015: converting to string/unicode
--FILE-- --FILE--
<?php <?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; }; $x = function() { return 1; };
print (string) $x; print (string) $x;
print "\n"; print "\n";
print $x; print $x;
print "\n"; print "\n";
?> ?>
--EXPECT-- --EXPECTF--
Closure object Error: Object of class Closure could not be converted to string at %sclosure_015.php(8)
Closure object
Error: Object of class Closure could not be converted to string at %sclosure_015.php(10)

View file

@ -85,26 +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 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;
default:
ce = Z_OBJCE_P(readobj);
zend_error(E_NOTICE, "Object of class %s 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, char *method_name, int method_len TSRMLS_DC) /* {{{ */ static zend_function *zend_closure_get_method(zval **object_ptr, char *method_name, int method_len TSRMLS_DC) /* {{{ */
{ {
char *lc_name; char *lc_name;
@ -226,7 +206,6 @@ void zend_register_closure_ce(TSRMLS_D) /* {{{ */
closure_handlers.has_property = zend_closure_has_property; closure_handlers.has_property = zend_closure_has_property;
closure_handlers.unset_property = zend_closure_unset_property; closure_handlers.unset_property = zend_closure_unset_property;
closure_handlers.compare_objects = zend_closure_compare_objects; closure_handlers.compare_objects = zend_closure_compare_objects;
closure_handlers.cast_object = zend_closure_cast_object_tostring;
closure_handlers.clone_obj = NULL; closure_handlers.clone_obj = NULL;
} }
/* }}} */ /* }}} */