diff options
author | Gustavo André dos Santos Lopes <cataphract@php.net> | 2010-10-26 18:47:10 +0000 |
---|---|---|
committer | Gustavo André dos Santos Lopes <cataphract@php.net> | 2010-10-26 18:47:10 +0000 |
commit | be77a48a715e9cd7089334b9506eadc0a4795e9e (patch) | |
tree | f68a0d4336144bcae72ab15590fc4a91e70b0f32 | |
parent | e5c7fae82cdff7086fb14b5de78a70d55ec73955 (diff) | |
download | php-git-be77a48a715e9cd7089334b9506eadc0a4795e9e.tar.gz |
- Fixed ReflectionProperty::isDefault() giving a wrong result for properties
obtained with ReflectionClass::getProperties().
-rw-r--r-- | ext/reflection/php_reflection.c | 1 | ||||
-rw-r--r-- | ext/reflection/tests/ReflectionParameter_isDefault.phpt | 34 |
2 files changed, 35 insertions, 0 deletions
diff --git a/ext/reflection/php_reflection.c b/ext/reflection/php_reflection.c index 67fc992ead..7f66d0d7bd 100644 --- a/ext/reflection/php_reflection.c +++ b/ext/reflection/php_reflection.c @@ -3902,6 +3902,7 @@ static int _adddynproperty(zval **pptr TSRMLS_DC, int num_args, va_list args, ze ZVAL_STRINGL(&member, hash_key->arKey, hash_key->nKeyLength-1, 0); if (zend_get_property_info(ce, &member, 1 TSRMLS_CC) == &EG(std_property_info)) { MAKE_STD_ZVAL(property); + EG(std_property_info).flags = ZEND_ACC_IMPLICIT_PUBLIC; reflection_property_factory(ce, &EG(std_property_info), property TSRMLS_CC); add_next_index_zval(retval, property); } diff --git a/ext/reflection/tests/ReflectionParameter_isDefault.phpt b/ext/reflection/tests/ReflectionParameter_isDefault.phpt new file mode 100644 index 0000000000..657077093b --- /dev/null +++ b/ext/reflection/tests/ReflectionParameter_isDefault.phpt @@ -0,0 +1,34 @@ +--TEST--
+ReflectionParameter::isDefault()
+--FILE--
+<?php
+class A {
+public $defprop;
+}
+$a = new A;
+$a->myprop = null;
+
+$ro = new ReflectionObject($a);
+$props = $ro->getProperties();
+$prop1 = $props[0];
+var_dump($prop1->isDefault());
+$prop2 = $props[1];
+var_dump($prop2->isDefault());
+
+var_dump($ro->getProperty('defprop')->isDefault());
+var_dump($ro->getProperty('myprop')->isDefault());
+
+$prop1 = new ReflectionProperty($a, 'defprop');
+$prop2 = new ReflectionProperty($a, 'myprop');
+var_dump($prop1->isDefault());
+var_dump($prop2->isDefault());
+?>
+==DONE==
+--EXPECT--
+bool(true)
+bool(false)
+bool(true)
+bool(false)
+bool(true)
+bool(false)
+==DONE==
|