Skip to content

Commit 4d58b64

Browse files
committed
Fixed unicode support
1 parent d00dfb0 commit 4d58b64

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

Zend/tests/closure_015.phpt

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
--TEST--
2+
Closure 015: converting to string/unicode
3+
--FILE--
4+
<?php
5+
$x = function() { return 1; };
6+
print (string) $x;
7+
print "\n";
8+
print (unicode) $x;
9+
print "\n";
10+
print $x;
11+
print "\n";
12+
?>
13+
--EXPECT--
14+
Closure object
15+
Closure object
16+
Closure object

Zend/zend_closures.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
#include "zend_globals.h"
2828

2929
#define ZEND_INVOKE_FUNC_NAME "__invoke"
30+
#define ZEND_CLOSURE_PRINT_NAME "Closure object"
3031

3132
typedef struct _zend_closure {
3233
zend_object std;
@@ -88,9 +89,12 @@ static int zend_closure_cast_object_tostring(zval *readobj, zval *writeobj, int
8889

8990
switch (type) {
9091
case IS_STRING:
92+
INIT_PZVAL(writeobj);
93+
ZVAL_STRINGL(writeobj, ZEND_CLOSURE_PRINT_NAME, sizeof(ZEND_CLOSURE_PRINT_NAME)-1, 1);
94+
return SUCCESS;
9195
case IS_UNICODE:
9296
INIT_PZVAL(writeobj);
93-
ZVAL_ASCII_STRINGL(writeobj, "Closure object", sizeof("Closure object")-1, ZSTR_DUPLICATE);
97+
ZVAL_UNICODEL(writeobj, USTR_MAKE(ZEND_CLOSURE_PRINT_NAME), sizeof(ZEND_CLOSURE_PRINT_NAME)-1, 0);
9498
return SUCCESS;
9599
default:
96100
ce = Z_OBJCE_P(readobj);

0 commit comments

Comments
 (0)