Skip to content

Commit 899fcea

Browse files
committed
Fix reflection of static vars
1 parent ea2c169 commit 899fcea

File tree

8 files changed

+28
-14
lines changed

8 files changed

+28
-14
lines changed

ext/reflection/php_reflection.c

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1939,7 +1939,6 @@ ZEND_METHOD(ReflectionFunctionAbstract, getStaticVariables)
19391939
{
19401940
reflection_object *intern;
19411941
zend_function *fptr;
1942-
zval *val;
19431942

19441943
if (zend_parse_parameters_none() == FAILURE) {
19451944
RETURN_THROWS();
@@ -1956,12 +1955,7 @@ ZEND_METHOD(ReflectionFunctionAbstract, getStaticVariables)
19561955
ht = zend_array_dup(fptr->op_array.static_variables);
19571956
ZEND_MAP_PTR_SET(fptr->op_array.static_variables_ptr, ht);
19581957
}
1959-
zend_string *static_var_name;
1960-
ZEND_HASH_MAP_FOREACH_STR_KEY_VAL(ht, static_var_name, val) {
1961-
if (Z_TYPE_EXTRA_P(val) != IS_TYPE_UNINITIALIZED) {
1962-
zend_hash_add(Z_ARR_P(return_value), static_var_name, val);
1963-
}
1964-
} ZEND_HASH_FOREACH_END();
1958+
zend_hash_copy(Z_ARRVAL_P(return_value), ht, zval_add_ref);
19651959
} else {
19661960
RETURN_EMPTY_ARRAY();
19671961
}

ext/reflection/tests/009.phpt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,9 @@ string(%d) "/**
7979
hoho
8080
*/"
8181
--getStaticVariables--
82-
array(0) {
82+
array(1) {
83+
["var"]=>
84+
NULL
8385
}
8486
array(1) {
8587
["var"]=>

ext/reflection/tests/025.phpt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,9 @@ string(%d) "/**
7979
hoho
8080
*/"
8181
--getStaticVariables--
82-
array(0) {
82+
array(1) {
83+
["var"]=>
84+
NULL
8385
}
8486
array(1) {
8587
["var"]=>

ext/reflection/tests/ReflectionFunction_001.phpt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,13 @@ bool(false)
4545
bool(true)
4646
int(6)
4747
int(11)
48-
array(1) {
48+
array(3) {
4949
["c"]=>
5050
NULL
51+
["a"]=>
52+
NULL
53+
["b"]=>
54+
NULL
5155
}
5256
string(3) "foo"
5357
bool(false)

ext/reflection/tests/ReflectionMethod_getStaticVariables_basic.phpt

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,13 @@ var_dump($methodInfo->getStaticVariables());
4545
?>
4646
--EXPECT--
4747
Public method:
48-
array(1) {
48+
array(3) {
4949
["c"]=>
5050
NULL
51+
["a"]=>
52+
NULL
53+
["b"]=>
54+
NULL
5155
}
5256
array(3) {
5357
["c"]=>
@@ -59,7 +63,9 @@ array(3) {
5963
}
6064

6165
Private method:
62-
array(0) {
66+
array(1) {
67+
["a"]=>
68+
NULL
6369
}
6470
array(1) {
6571
["a"]=>

ext/reflection/tests/bug32981.phpt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,9 @@ foreach ($class->getMethods() as $method) {
2828
?>
2929
--EXPECT--
3030
string(4) "test"
31-
array(0) {
31+
array(1) {
32+
["enabled"]=>
33+
NULL
3234
}
3335
string(4) "test"
3436
array(1) {

ext/reflection/tests/bug63614.phpt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ print_r($reflect->getStaticVariables());
3030
--EXPECT--
3131
Array
3232
(
33+
[a] =>
3334
)
3435
Array
3536
(
@@ -40,6 +41,7 @@ Array
4041
)
4142
Array
4243
(
44+
[a] =>
4345
)
4446
Array
4547
(

ext/reflection/tests/new_in_constexpr.phpt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,9 @@ var_dump($rp->getDefaultValue() !== test2());
2626

2727
?>
2828
--EXPECT--
29-
array(0) {
29+
array(1) {
30+
["x"]=>
31+
NULL
3032
}
3133
bool(true)
3234
bool(true)

0 commit comments

Comments
 (0)