]> granicus.if.org Git - php/commitdiff
Revert "Add ReflectionReference::getRefcount()"
authorNikita Popov <nikita.ppv@gmail.com>
Mon, 22 Jul 2019 14:49:08 +0000 (16:49 +0200)
committerNikita Popov <nikita.ppv@gmail.com>
Mon, 22 Jul 2019 14:49:08 +0000 (16:49 +0200)
This reverts commit 428cfdd1810b17f0064b7691276f0eb92dc963b6.

ext/reflection/php_reflection.c
ext/reflection/tests/ReflectionReference.phpt

index eafe62344b2ba8962a8276846a6e2700c0724227..dcb98b0653b6d6f7248ba2fbf06b8711d521dcfe 100644 (file)
@@ -6170,7 +6170,7 @@ ZEND_METHOD(reflection_reference, fromArrayElement)
        }
 
        /* Treat singleton reference as non-reference. */
-       if (Z_TYPE_P(item) != IS_REFERENCE) {
+       if (Z_TYPE_P(item) != IS_REFERENCE || Z_REFCOUNT_P(item) == 1) {
                RETURN_NULL();
        }
 
@@ -6218,30 +6218,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
@@ -6730,7 +6706,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)
index ff933063befaeaa16cf69ee1adf025c90e7c1d4e..2963c3023284d5edf7b3b08d8de810fb4577b069 100644 (file)
@@ -13,20 +13,12 @@ echo "fromArrayElement():\n";
 $r0 = ReflectionReference::fromArrayElement($ary, 0);
 var_dump($r0 === null);
 $r1 = ReflectionReference::fromArrayElement($ary, 1);
-var_dump($r1 instanceof ReflectionReference);
+var_dump($r1 === null);
 $r2 = ReflectionReference::fromArrayElement($ary, 2);
 var_dump($r2 instanceof ReflectionReference);
 $r3 = ReflectionReference::fromArrayElement($ary, 3);
 var_dump($r2 instanceof ReflectionReference);
 
-echo "getRefcount():\n";
-var_dump($r1->getRefcount());
-var_dump($r2->getRefcount());
-var_dump($r3->getRefcount());
-
-unset($ary[1]);
-var_dump($r1->getRefcount());
-
 echo "getId() #1:\n";
 var_dump($r2->getId() === $r2->getId());
 var_dump($r3->getId() === $r3->getId());
@@ -55,11 +47,6 @@ bool(true)
 bool(true)
 bool(true)
 bool(true)
-getRefcount():
-int(2)
-int(3)
-int(3)
-int(1)
 getId() #1:
 bool(true)
 bool(true)