diff options
author | Dmitry Stogov <dmitry@php.net> | 2008-07-10 07:55:48 +0000 |
---|---|---|
committer | Dmitry Stogov <dmitry@php.net> | 2008-07-10 07:55:48 +0000 |
commit | 4d58b64a89b70cc751c055ad4c29134acee44730 (patch) | |
tree | bc45588efecc21f9378cadf289dab649c9d63566 | |
parent | d00dfb0bcb7e47446a0ab9e57e539eb97a1596dd (diff) | |
download | php-git-4d58b64a89b70cc751c055ad4c29134acee44730.tar.gz |
Fixed unicode support
-rw-r--r-- | Zend/tests/closure_015.phpt | 16 | ||||
-rw-r--r-- | Zend/zend_closures.c | 6 |
2 files changed, 21 insertions, 1 deletions
diff --git a/Zend/tests/closure_015.phpt b/Zend/tests/closure_015.phpt new file mode 100644 index 0000000000..ee1e485b91 --- /dev/null +++ b/Zend/tests/closure_015.phpt @@ -0,0 +1,16 @@ +--TEST-- +Closure 015: converting to string/unicode +--FILE-- +<?php +$x = function() { return 1; }; +print (string) $x; +print "\n"; +print (unicode) $x; +print "\n"; +print $x; +print "\n"; +?> +--EXPECT-- +Closure object +Closure object +Closure object diff --git a/Zend/zend_closures.c b/Zend/zend_closures.c index ff67d7e502..64a74bcd32 100644 --- a/Zend/zend_closures.c +++ b/Zend/zend_closures.c @@ -27,6 +27,7 @@ #include "zend_globals.h" #define ZEND_INVOKE_FUNC_NAME "__invoke" +#define ZEND_CLOSURE_PRINT_NAME "Closure object" typedef struct _zend_closure { zend_object std; @@ -88,9 +89,12 @@ static int zend_closure_cast_object_tostring(zval *readobj, zval *writeobj, int 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_ASCII_STRINGL(writeobj, "Closure object", sizeof("Closure object")-1, ZSTR_DUPLICATE); + ZVAL_UNICODEL(writeobj, USTR_MAKE(ZEND_CLOSURE_PRINT_NAME), sizeof(ZEND_CLOSURE_PRINT_NAME)-1, 0); return SUCCESS; default: ce = Z_OBJCE_P(readobj); |