}
/* }}} */
-static zend_class_entry * spl_find_ce_by_name(char *name, int len, zend_bool autoload TSRMLS_DC)
+static zend_class_entry * spl_find_ce_by_name(zend_uchar ztype, void *name, int len, zend_bool autoload TSRMLS_DC)
{
zend_class_entry **ce;
int found;
+
if (!autoload) {
char *lc_name;
- lc_name = do_alloca(len + 1);
- zend_str_tolower_copy(lc_name, name, len);
-
- found = zend_hash_find(EG(class_table), lc_name, len +1, (void **) &ce);
- free_alloca(lc_name);
+ lc_name = zend_u_str_tolower_dup(ztype, name, len);
+ found = zend_u_hash_find(EG(class_table), ztype, lc_name, len +1, (void **) &ce);
+ efree(lc_name);
} else {
- found = zend_lookup_class(name, len, &ce TSRMLS_CC);
+ found = zend_u_lookup_class(ztype, name, len, &ce TSRMLS_CC);
}
if (found != SUCCESS) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "Class %s does not exist%s", name, autoload ? " and could not be loaded" : "");
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Class %v does not exist%s", name, autoload ? " and could not be loaded" : "");
return NULL;
}
RETURN_FALSE;
}
- if (Z_TYPE_P(obj) != IS_OBJECT && Z_TYPE_P(obj) != IS_STRING) {
+ if (Z_TYPE_P(obj) != IS_OBJECT && Z_TYPE_P(obj) != IS_STRING && Z_TYPE_P(obj) != IS_UNICODE) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "object or string expected");
RETURN_FALSE;
}
- if (Z_TYPE_P(obj) == IS_STRING) {
- if (NULL == (ce = spl_find_ce_by_name(Z_STRVAL_P(obj), Z_STRLEN_P(obj), autoload TSRMLS_CC))) {
+ if (Z_TYPE_P(obj) == IS_STRING || Z_TYPE_P(obj) == IS_UNICODE) {
+ if (NULL == (ce = spl_find_ce_by_name(Z_TYPE_P(obj), Z_UNIVAL_P(obj), Z_UNILEN_P(obj), autoload TSRMLS_CC))) {
RETURN_FALSE;
}
} else {
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z|b", &obj, &autoload) == FAILURE) {
RETURN_FALSE;
}
- if (Z_TYPE_P(obj) != IS_OBJECT && Z_TYPE_P(obj) != IS_STRING) {
+ if (Z_TYPE_P(obj) != IS_OBJECT && Z_TYPE_P(obj) != IS_STRING && Z_TYPE_P(obj) != IS_UNICODE) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "object or string expected");
RETURN_FALSE;
}
- if (Z_TYPE_P(obj) == IS_STRING) {
- if (NULL == (ce = spl_find_ce_by_name(Z_STRVAL_P(obj), Z_STRLEN_P(obj), autoload TSRMLS_CC))) {
+ if (Z_TYPE_P(obj) == IS_STRING || Z_TYPE_P(obj) == IS_UNICODE) {
+ if (NULL == (ce = spl_find_ce_by_name(Z_TYPE_P(obj), Z_UNIVAL_P(obj), Z_UNILEN_P(obj), autoload TSRMLS_CC))) {
RETURN_FALSE;
}
} else {
/* }}} */
#define SPL_ADD_CLASS(class_name, z_list, sub, allow, ce_flags) \
- spl_add_classes(&spl_ce_ ## class_name, z_list, sub, allow, ce_flags TSRMLS_CC)
+ spl_add_classes(U_CLASS_ENTRY(spl_ce_ ## class_name), z_list, sub, allow, ce_flags TSRMLS_CC)
#define SPL_LIST_CLASSES(z_list, sub, allow, ce_flags) \
SPL_ADD_CLASS(AppendIterator, z_list, sub, allow, ce_flags); \
if (!allow || (allow > 0 && pce->ce_flags & ce_flags) || (allow < 0 && !(pce->ce_flags & ce_flags))) {
size_t len = pce->name_length;
zval *tmp;
+ zend_uchar ztype = UG(unicode)?IS_UNICODE:IS_STRING;
- if (zend_hash_find(Z_ARRVAL_P(list), pce->name, len+1, (void*)&tmp) == FAILURE) {
+ if (zend_u_hash_find(Z_ARRVAL_P(list), ztype, pce->name, len+1, (void*)&tmp) == FAILURE) {
MAKE_STD_ZVAL(tmp);
- ZVAL_STRING(tmp, pce->name, 1);
- zend_hash_add(Z_ARRVAL_P(list), pce->name, len+1, &tmp, sizeof(zval *), NULL);
+ if (UG(unicode)) {
+ ZVAL_UNICODEL(tmp, pce->name, pce->name_length, 1);
+ } else {
+ ZVAL_STRINGL(tmp, pce->name, pce->name_length, 1);
+ }
+ zend_u_hash_add(Z_ARRVAL_P(list), ztype, pce->name, len+1, &tmp, sizeof(zval *), NULL);
}
}
}
/* }}} */
/* {{{ spl_add_classes */
-int spl_add_classes(zend_class_entry ** ppce, zval *list, int sub, int allow, int ce_flags TSRMLS_DC)
+int spl_add_classes(zend_class_entry *pce, zval *list, int sub, int allow, int ce_flags TSRMLS_DC)
{
- zend_class_entry *pce = *ppce;
-
if (!pce) {
return 0;
}
spl_add_interfaces(list, pce, allow, ce_flags TSRMLS_CC);
while (pce->parent) {
pce = pce->parent;
- spl_add_classes(&pce, list, sub, allow, ce_flags TSRMLS_CC);
+ spl_add_classes(pce, list, sub, allow, ce_flags TSRMLS_CC);
}
}
return 0;
*/
void spl_add_class_name(zval * list, zend_class_entry * pce, int allow, int ce_flags TSRMLS_DC);
void spl_add_interfaces(zval * list, zend_class_entry * pce, int allow, int ce_flags TSRMLS_DC);
-int spl_add_classes(zend_class_entry ** ppce, zval *list, int sub, int allow, int ce_flags TSRMLS_DC);
+int spl_add_classes(zend_class_entry *pce, zval *list, int sub, int allow, int ce_flags TSRMLS_DC);
#define SPL_ME(class_name, function_name, arg_info, flags) \
PHP_ME( spl_ ## class_name, function_name, arg_info, flags)
zend_throw_exception_ex(U_CLASS_ENTRY(spl_ce_BadMethodCallException), 0 TSRMLS_CC, "%v does not fetch string value (see CachingIterator::__construct)", Z_OBJCE_P(getThis())->name);
}
if (intern->u.caching.zstr) {
- RETURN_STRINGL(Z_STRVAL_P(intern->u.caching.zstr), Z_STRLEN_P(intern->u.caching.zstr), 1);
+ *return_value = *intern->u.caching.zstr;
+ zval_copy_ctor(return_value);
+ convert_to_text(return_value);
+ INIT_PZVAL(return_value);
+// RETURN_STRINGL(Z_STRVAL_P(intern->u.caching.zstr), Z_STRLEN_P(intern->u.caching.zstr), 1);
} else {
RETURN_NULL();
}
Warning: class_implements(): Class aaa does not exist and could not be loaded in %sspl_003.php on line %d
+Warning: class_implements(): Class bbb does not exist in %sspl_003.php on line %d
+array(0) {
+}
+array(0) {
+}
+bool(false)
+bool(false)
+===DONE===
+--UEXPECTF--
+Warning: class_parents(): Class foo does not exist in %sspl_003.php on line %d
+unicode(3) "foo"
+
+Warning: class_parents(): Class foo does not exist and could not be loaded in %sspl_003.php on line %d
+array(2) {
+ [u"b"]=>
+ unicode(1) "b"
+ [u"a"]=>
+ unicode(1) "a"
+}
+array(2) {
+ [u"b"]=>
+ unicode(1) "b"
+ [u"a"]=>
+ unicode(1) "a"
+}
+array(1) {
+ [u"a"]=>
+ unicode(1) "a"
+}
+array(1) {
+ [u"a"]=>
+ unicode(1) "a"
+}
+array(0) {
+}
+bool(false)
+bool(false)
+unicode(3) "aaa"
+
+Warning: class_implements(): Class aaa does not exist and could not be loaded in %sspl_003.php on line %d
+
Warning: class_implements(): Class bbb does not exist in %sspl_003.php on line %d
array(0) {
}
/* it the object implements Countable we call its count() method */
zval *retval;
- if (Z_OBJ_HT_P(array)->get_class_entry && instanceof_function(Z_OBJCE_P(array), spl_ce_Countable TSRMLS_CC)) {
+ if (Z_OBJ_HT_P(array)->get_class_entry && instanceof_function(Z_OBJCE_P(array), U_CLASS_ENTRY(spl_ce_Countable) TSRMLS_CC)) {
zend_call_method_with_0_params(&array, NULL, NULL, "count", &retval);
RETVAL_LONG(Z_LVAL_P(retval));
zval_ptr_dtor(&retval);