summaryrefslogtreecommitdiff
path: root/ext/reflection/php_reflection.c
diff options
context:
space:
mode:
authorNikita Popov <nikita.ppv@gmail.com>2019-07-08 16:54:22 +0200
committerNikita Popov <nikita.ppv@gmail.com>2019-07-08 16:54:22 +0200
commit1fe478d30cad8f6d3683eedd82a46119dd090503 (patch)
tree67e92dc8008ec34b3f4676ccad3701c38d2f9aa3 /ext/reflection/php_reflection.c
parente278517b662858ecb0b08821176290278944f3ae (diff)
parent428cfdd1810b17f0064b7691276f0eb92dc963b6 (diff)
downloadphp-git-1fe478d30cad8f6d3683eedd82a46119dd090503.tar.gz
Merge branch 'PHP-7.4'
Diffstat (limited to 'ext/reflection/php_reflection.c')
-rw-r--r--ext/reflection/php_reflection.c27
1 files changed, 26 insertions, 1 deletions
diff --git a/ext/reflection/php_reflection.c b/ext/reflection/php_reflection.c
index c91d1e199e..3e21e415dc 100644
--- a/ext/reflection/php_reflection.c
+++ b/ext/reflection/php_reflection.c
@@ -6182,7 +6182,7 @@ ZEND_METHOD(reflection_reference, fromArrayElement)
}
/* Treat singleton reference as non-reference. */
- if (Z_TYPE_P(item) != IS_REFERENCE || Z_REFCOUNT_P(item) == 1) {
+ if (Z_TYPE_P(item) != IS_REFERENCE) {
RETURN_NULL();
}
@@ -6230,6 +6230,30 @@ 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
@@ -6719,6 +6743,7 @@ 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)