From efa7f87de4d16bd8a8e1292b5c7431912d41f7a6 Mon Sep 17 00:00:00 2001 From: Remi Collet Date: Fri, 26 Sep 2014 08:56:42 +0200 Subject: Fixed bug #68103 Dupplicate entry in Reflection $ php -r '$r=new ReflectionExtension("pthreads"); print_r($r->getClassNames());' Array ( [0] => Threaded [1] => stackable [2] => Thread [3] => Worker [4] => Mutex [5] => Cond [6] => Collectable [7] => Pool ) In getClasses() output, it is possible to compare key (ex "stackable") with $obj->name (ex "Threaded") to detect class alias. ... [Threaded] => ReflectionClass Object ( [name] => Threaded ) [stackable] => ReflectionClass Object ( [name] => Threaded ) ... --- ext/reflection/php_reflection.c | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) (limited to 'ext/reflection/php_reflection.c') diff --git a/ext/reflection/php_reflection.c b/ext/reflection/php_reflection.c index 31d836a7ac..4294ceac81 100644 --- a/ext/reflection/php_reflection.c +++ b/ext/reflection/php_reflection.c @@ -1007,9 +1007,12 @@ static int _extension_class_string(zend_class_entry **pce TSRMLS_DC, int num_arg int *num_classes = va_arg(args, int*); if (((*pce)->type == ZEND_INTERNAL_CLASS) && (*pce)->info.internal.module && !strcasecmp((*pce)->info.internal.module->name, module->name)) { - string_printf(str, "\n"); - _class_string(str, *pce, NULL, indent TSRMLS_CC); - (*num_classes)++; + /* dump class if it is not an alias */ + if (!zend_binary_strcasecmp((*pce)->name, (*pce)->name_length, hash_key->arKey, hash_key->nKeyLength-1)) { + string_printf(str, "\n"); + _class_string(str, *pce, NULL, indent TSRMLS_CC); + (*num_classes)++; + } } return ZEND_HASH_APPLY_KEEP; } @@ -5360,12 +5363,24 @@ static int add_extension_class(zend_class_entry **pce TSRMLS_DC, int num_args, v int add_reflection_class = va_arg(args, int); if (((*pce)->type == ZEND_INTERNAL_CLASS) && (*pce)->info.internal.module && !strcasecmp((*pce)->info.internal.module->name, module->name)) { + const char *name; + int nlen; + + if (zend_binary_strcasecmp((*pce)->name, (*pce)->name_length, hash_key->arKey, hash_key->nKeyLength-1)) { + /* This is an class alias, use alias name */ + name = hash_key->arKey; + nlen = hash_key->nKeyLength-1; + } else { + /* Use class name */ + name = (*pce)->name; + nlen = (*pce)->name_length; + } if (add_reflection_class) { ALLOC_ZVAL(zclass); zend_reflection_class_factory(*pce, zclass TSRMLS_CC); - add_assoc_zval_ex(class_array, (*pce)->name, (*pce)->name_length + 1, zclass); + add_assoc_zval_ex(class_array, name, nlen+1, zclass); } else { - add_next_index_stringl(class_array, (*pce)->name, (*pce)->name_length, 1); + add_next_index_stringl(class_array, name, nlen, 1); } } return ZEND_HASH_APPLY_KEEP; -- cgit v1.2.1 From 136dd53ac29fabce18127b8ecb95b606f141d42d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20Schl=C3=BCter?= Date: Sat, 4 Oct 2014 19:59:21 +0200 Subject: Fix arginfo --- ext/reflection/php_reflection.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'ext/reflection/php_reflection.c') diff --git a/ext/reflection/php_reflection.c b/ext/reflection/php_reflection.c index 4294ceac81..5040de5e19 100644 --- a/ext/reflection/php_reflection.c +++ b/ext/reflection/php_reflection.c @@ -5670,7 +5670,7 @@ static const zend_function_entry reflection_exception_functions[] = { PHP_FE_END }; -ZEND_BEGIN_ARG_INFO(arginfo_reflection__void, 0) +ZEND_BEGIN_ARG_INF(arginfo_reflection__void, 0) ZEND_END_ARG_INFO() @@ -6061,7 +6061,7 @@ ZEND_END_ARG_INFO() static const zend_function_entry reflection_zend_extension_functions[] = { ZEND_ME(reflection, __clone, arginfo_reflection__void, ZEND_ACC_PRIVATE|ZEND_ACC_FINAL) ZEND_ME(reflection_zend_extension, export, arginfo_reflection_extension_export, ZEND_ACC_STATIC|ZEND_ACC_PUBLIC) - ZEND_ME(reflection_zend_extension, __construct, arginfo_reflection_extension___construct, 0) + ZEND_ME(reflection_zend_extension, __construct, arginfo_reflection_zend_extension___construct, 0) ZEND_ME(reflection_zend_extension, __toString, arginfo_reflection__void, 0) ZEND_ME(reflection_zend_extension, getName, arginfo_reflection__void, 0) ZEND_ME(reflection_zend_extension, getVersion, arginfo_reflection__void, 0) -- cgit v1.2.1 From b386991471bc0f2af793a44c1509464cbcd73f6f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20Schl=C3=BCter?= Date: Sat, 4 Oct 2014 20:06:02 +0200 Subject: Fix accidental edit in previous commit --- ext/reflection/php_reflection.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'ext/reflection/php_reflection.c') diff --git a/ext/reflection/php_reflection.c b/ext/reflection/php_reflection.c index 5040de5e19..95b780d3f0 100644 --- a/ext/reflection/php_reflection.c +++ b/ext/reflection/php_reflection.c @@ -5670,7 +5670,7 @@ static const zend_function_entry reflection_exception_functions[] = { PHP_FE_END }; -ZEND_BEGIN_ARG_INF(arginfo_reflection__void, 0) +ZEND_BEGIN_ARG_INFO(arginfo_reflection__void, 0) ZEND_END_ARG_INFO() -- cgit v1.2.1