summaryrefslogtreecommitdiff
path: root/ext/reflection/php_reflection.c
diff options
context:
space:
mode:
authorNikita Popov <nikita.ppv@gmail.com>2019-07-22 17:00:17 +0200
committerNikita Popov <nikita.ppv@gmail.com>2019-07-22 17:00:17 +0200
commit7a1540fa2872a67080f2161faff226c1effebf76 (patch)
treeb07337009935b9b47d15fc6bc0edd9c7e02e66f6 /ext/reflection/php_reflection.c
parent92d6720dcfe984131cbf168c11e1ef0049e13d62 (diff)
parentc817b8020c8a835946681ca94b9257e78e64dad3 (diff)
downloadphp-git-7a1540fa2872a67080f2161faff226c1effebf76.tar.gz
Merge branch 'PHP-7.4'
Diffstat (limited to 'ext/reflection/php_reflection.c')
-rw-r--r--ext/reflection/php_reflection.c38
1 files changed, 11 insertions, 27 deletions
diff --git a/ext/reflection/php_reflection.c b/ext/reflection/php_reflection.c
index a6751a9660..d6977a8a34 100644
--- a/ext/reflection/php_reflection.c
+++ b/ext/reflection/php_reflection.c
@@ -6135,6 +6135,16 @@ ZEND_METHOD(reflection_reference, __construct)
}
/* }}} */
+static zend_bool is_ignorable_reference(HashTable *ht, zval *ref) {
+ if (Z_REFCOUNT_P(ref) != 1) {
+ return 0;
+ }
+
+ /* Directly self-referential arrays are treated as proper references
+ * in zend_array_dup() despite rc=1. */
+ return Z_TYPE_P(Z_REFVAL_P(ref)) != IS_ARRAY || Z_ARRVAL_P(Z_REFVAL_P(ref)) != ht;
+}
+
/* {{{ proto public ReflectionReference|null ReflectionReference::fromArrayElement(array array, mixed key)
* Create ReflectionReference for array item. Returns null if not a reference. */
ZEND_METHOD(reflection_reference, fromArrayElement)
@@ -6161,8 +6171,7 @@ ZEND_METHOD(reflection_reference, fromArrayElement)
return;
}
- /* Treat singleton reference as non-reference. */
- if (Z_TYPE_P(item) != IS_REFERENCE) {
+ if (Z_TYPE_P(item) != IS_REFERENCE || is_ignorable_reference(ht, item)) {
RETURN_NULL();
}
@@ -6210,30 +6219,6 @@ ZEND_METHOD(reflection_reference, getId)
}
/* }}} */
-/* {{{ proto public int ReflectionReference::getRefcount()
- * Returns reference count of the held reference.
- * ReflectionReference itself increases the refcount, as such:
- * * Refcount 1 indicates that the reference is only held by this ReflectionReference.
- * * Refcount 2 indicates that it is a singleton reference (often not treated as a reference).
- * * Refcount 3 or higher is an ordinary shared reference. */
-ZEND_METHOD(reflection_reference, getRefcount)
-{
- reflection_object *intern;
-
- if (zend_parse_parameters_none() == FAILURE) {
- return;
- }
-
- intern = Z_REFLECTION_P(getThis());
- if (Z_TYPE(intern->obj) != IS_REFERENCE) {
- _DO_THROW("Corrupted ReflectionReference object");
- return;
- }
-
- RETURN_LONG(Z_REFCOUNT(intern->obj));
-}
-/* }}} */
-
/* {{{ method tables */
static const zend_function_entry reflection_exception_functions[] = {
PHP_FE_END
@@ -6722,7 +6707,6 @@ ZEND_END_ARG_INFO()
static const zend_function_entry reflection_reference_functions[] = {
ZEND_ME(reflection_reference, fromArrayElement, arginfo_reflection_reference_fromArrayElement, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC)
ZEND_ME(reflection_reference, getId, arginfo_reflection__void, ZEND_ACC_PUBLIC)
- ZEND_ME(reflection_reference, getRefcount, arginfo_reflection__void, ZEND_ACC_PUBLIC)
/* Always throwing dummy methods */
ZEND_ME(reflection, __clone, arginfo_reflection__void, ZEND_ACC_PRIVATE)