Skip to content

Commit f02f9b0

Browse files
committed
Removed Closure::__toString()
1 parent a31dc18 commit f02f9b0

File tree

2 files changed

+9
-24
lines changed

2 files changed

+9
-24
lines changed

Zend/tests/closure_015.phpt

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,18 @@
22
Closure 015: converting to string/unicode
33
--FILE--
44
<?php
5+
set_error_handler('myErrorHandler', E_RECOVERABLE_ERROR);
6+
function myErrorHandler($errno, $errstr, $errfile, $errline) {
7+
echo "Error: $errstr at $errfile($errline)\n";
8+
return true;
9+
}
510
$x = function() { return 1; };
611
print (string) $x;
712
print "\n";
813
print $x;
914
print "\n";
1015
?>
11-
--EXPECT--
12-
Closure object
13-
Closure object
16+
--EXPECTF--
17+
Error: Object of class Closure could not be converted to string at %sclosure_015.php(8)
18+
19+
Error: Object of class Closure could not be converted to string at %sclosure_015.php(10)

Zend/zend_closures.c

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -85,26 +85,6 @@ static int zend_closure_compare_objects(zval *o1, zval *o2 TSRMLS_DC) /* {{{ */
8585
}
8686
/* }}} */
8787

88-
static int zend_closure_cast_object_tostring(zval *readobj, zval *writeobj, int type TSRMLS_DC) /* {{{ */
89-
{
90-
zend_class_entry *ce;
91-
92-
switch (type) {
93-
case IS_STRING:
94-
INIT_PZVAL(writeobj);
95-
ZVAL_STRINGL(writeobj, ZEND_CLOSURE_PRINT_NAME, sizeof(ZEND_CLOSURE_PRINT_NAME)-1, 1);
96-
return SUCCESS;
97-
default:
98-
ce = Z_OBJCE_P(readobj);
99-
zend_error(E_NOTICE, "Object of class %s could not be converted to %s", ce->name, zend_get_type_by_const(type));
100-
INIT_PZVAL(writeobj);
101-
Z_TYPE_P(writeobj) = IS_NULL;
102-
break;
103-
}
104-
return FAILURE;
105-
}
106-
/* }}} */
107-
10888
static zend_function *zend_closure_get_method(zval **object_ptr, char *method_name, int method_len TSRMLS_DC) /* {{{ */
10989
{
11090
char *lc_name;
@@ -226,7 +206,6 @@ void zend_register_closure_ce(TSRMLS_D) /* {{{ */
226206
closure_handlers.has_property = zend_closure_has_property;
227207
closure_handlers.unset_property = zend_closure_unset_property;
228208
closure_handlers.compare_objects = zend_closure_compare_objects;
229-
closure_handlers.cast_object = zend_closure_cast_object_tostring;
230209
closure_handlers.clone_obj = NULL;
231210
}
232211
/* }}} */

0 commit comments

Comments
 (0)