Skip to content

Commit 19588a8

Browse files
committed
Revert "Add ReflectionReference::getRefcount()"
This reverts commit 428cfdd.
1 parent 31d85b8 commit 19588a8

File tree

2 files changed

+2
-40
lines changed

2 files changed

+2
-40
lines changed

ext/reflection/php_reflection.c

Lines changed: 1 addition & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -6170,7 +6170,7 @@ ZEND_METHOD(reflection_reference, fromArrayElement)
61706170
}
61716171

61726172
/* Treat singleton reference as non-reference. */
6173-
if (Z_TYPE_P(item) != IS_REFERENCE) {
6173+
if (Z_TYPE_P(item) != IS_REFERENCE || Z_REFCOUNT_P(item) == 1) {
61746174
RETURN_NULL();
61756175
}
61766176

@@ -6218,30 +6218,6 @@ ZEND_METHOD(reflection_reference, getId)
62186218
}
62196219
/* }}} */
62206220

6221-
/* {{{ proto public int ReflectionReference::getRefcount()
6222-
* Returns reference count of the held reference.
6223-
* ReflectionReference itself increases the refcount, as such:
6224-
* * Refcount 1 indicates that the reference is only held by this ReflectionReference.
6225-
* * Refcount 2 indicates that it is a singleton reference (often not treated as a reference).
6226-
* * Refcount 3 or higher is an ordinary shared reference. */
6227-
ZEND_METHOD(reflection_reference, getRefcount)
6228-
{
6229-
reflection_object *intern;
6230-
6231-
if (zend_parse_parameters_none() == FAILURE) {
6232-
return;
6233-
}
6234-
6235-
intern = Z_REFLECTION_P(getThis());
6236-
if (Z_TYPE(intern->obj) != IS_REFERENCE) {
6237-
_DO_THROW("Corrupted ReflectionReference object");
6238-
return;
6239-
}
6240-
6241-
RETURN_LONG(Z_REFCOUNT(intern->obj));
6242-
}
6243-
/* }}} */
6244-
62456221
/* {{{ method tables */
62466222
static const zend_function_entry reflection_exception_functions[] = {
62476223
PHP_FE_END
@@ -6730,7 +6706,6 @@ ZEND_END_ARG_INFO()
67306706
static const zend_function_entry reflection_reference_functions[] = {
67316707
ZEND_ME(reflection_reference, fromArrayElement, arginfo_reflection_reference_fromArrayElement, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC)
67326708
ZEND_ME(reflection_reference, getId, arginfo_reflection__void, ZEND_ACC_PUBLIC)
6733-
ZEND_ME(reflection_reference, getRefcount, arginfo_reflection__void, ZEND_ACC_PUBLIC)
67346709

67356710
/* Always throwing dummy methods */
67366711
ZEND_ME(reflection, __clone, arginfo_reflection__void, ZEND_ACC_PRIVATE)

ext/reflection/tests/ReflectionReference.phpt

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -13,20 +13,12 @@ echo "fromArrayElement():\n";
1313
$r0 = ReflectionReference::fromArrayElement($ary, 0);
1414
var_dump($r0 === null);
1515
$r1 = ReflectionReference::fromArrayElement($ary, 1);
16-
var_dump($r1 instanceof ReflectionReference);
16+
var_dump($r1 === null);
1717
$r2 = ReflectionReference::fromArrayElement($ary, 2);
1818
var_dump($r2 instanceof ReflectionReference);
1919
$r3 = ReflectionReference::fromArrayElement($ary, 3);
2020
var_dump($r2 instanceof ReflectionReference);
2121

22-
echo "getRefcount():\n";
23-
var_dump($r1->getRefcount());
24-
var_dump($r2->getRefcount());
25-
var_dump($r3->getRefcount());
26-
27-
unset($ary[1]);
28-
var_dump($r1->getRefcount());
29-
3022
echo "getId() #1:\n";
3123
var_dump($r2->getId() === $r2->getId());
3224
var_dump($r3->getId() === $r3->getId());
@@ -55,11 +47,6 @@ bool(true)
5547
bool(true)
5648
bool(true)
5749
bool(true)
58-
getRefcount():
59-
int(2)
60-
int(3)
61-
int(3)
62-
int(1)
6350
getId() #1:
6451
bool(true)
6552
bool(true)

0 commit comments

Comments
 (0)