summaryrefslogtreecommitdiff
path: root/ext/reflection
diff options
context:
space:
mode:
authorXinchen Hui <laruence@gmail.com>2016-08-15 23:22:55 +0800
committerXinchen Hui <laruence@gmail.com>2016-08-15 23:22:55 +0800
commit60de74ebdae5cf8b14f85d6e60f519c9e8b966f9 (patch)
tree801865f5f072c2b3707eddcf1672bd55ca59e2fc /ext/reflection
parentd6b46901b281a3c9d48b65f5f69bae9c7805b118 (diff)
downloadphp-git-60de74ebdae5cf8b14f85d6e60f519c9e8b966f9.tar.gz
Fixed bug #72846 (getConstant for a array constant with constant values returns NULL/NFC/UKNOWN)
Diffstat (limited to 'ext/reflection')
-rw-r--r--ext/reflection/php_reflection.c2
-rw-r--r--ext/reflection/tests/bug72846.phpt48
2 files changed, 50 insertions, 0 deletions
diff --git a/ext/reflection/php_reflection.c b/ext/reflection/php_reflection.c
index 964e7a9e57..08acc7e5d2 100644
--- a/ext/reflection/php_reflection.c
+++ b/ext/reflection/php_reflection.c
@@ -4407,6 +4407,7 @@ ZEND_METHOD(reflection_class, getConstants)
GET_REFLECTION_OBJECT_PTR(ce);
array_init(return_value);
ZEND_HASH_FOREACH_VAL(&ce->constants_table, val) {
+ ZVAL_DEREF(val);
if (UNEXPECTED(zval_update_constant_ex(val, 1, ce) != SUCCESS)) {
return;
}
@@ -4431,6 +4432,7 @@ ZEND_METHOD(reflection_class, getConstant)
GET_REFLECTION_OBJECT_PTR(ce);
ZEND_HASH_FOREACH_VAL(&ce->constants_table, value) {
+ ZVAL_DEREF(value);
if (UNEXPECTED(zval_update_constant_ex(value, 1, ce) != SUCCESS)) {
return;
}
diff --git a/ext/reflection/tests/bug72846.phpt b/ext/reflection/tests/bug72846.phpt
new file mode 100644
index 0000000000..ab8b6cac79
--- /dev/null
+++ b/ext/reflection/tests/bug72846.phpt
@@ -0,0 +1,48 @@
+--TEST--
+Bug #72846 (getConstant for a array constant with constant values returns NULL/NFC/UKNOWN)
+--FILE--
+<?php
+
+namespace Some {
+
+ abstract class A
+ {
+ const ONE = '1';
+ const TWO = '2';
+
+ const CONST_NUMBERS = [
+ self::ONE,
+ self::TWO,
+ ];
+
+ const NUMBERS = [
+ '1',
+ '2',
+ ];
+ }
+
+ class B extends A
+ {
+ }
+
+ $ref = new \ReflectionClass('Some\B');
+
+ var_dump($ref->getConstant('ONE'));
+ var_dump($ref->getConstant('CONST_NUMBERS'));
+ var_dump($ref->getConstant('NUMBERS'));
+}
+?>
+--EXPECT--
+string(1) "1"
+array(2) {
+ [0]=>
+ string(1) "1"
+ [1]=>
+ string(1) "2"
+}
+array(2) {
+ [0]=>
+ string(1) "1"
+ [1]=>
+ string(1) "2"
+}