Skip to content

Commit

Permalink
Fixed unicode support
Browse files Browse the repository at this point in the history
  • Loading branch information
dstogov committed Jul 10, 2008
1 parent d00dfb0 commit 4d58b64
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
16 changes: 16 additions & 0 deletions Zend/tests/closure_015.phpt
Original file line number Diff line number Diff line change
@@ -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
6 changes: 5 additions & 1 deletion Zend/zend_closures.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 4d58b64

Please sign in to comment.