com php-src: Fix #77673 ReflectionClass::getDefaultProperties returns spooky array: Zend/tests/type_declarations/typed_properties _105.phpt
ext/reflection/php_reflection.c
| From: | Joe Watkins | Date: | Wed, 27 Feb 2019 08:17:09 +0000 |
| Subject: | com php-src: Fix #77673 ReflectionClass::getDefaultProperties returns spooky array: Zend/tests/type_declarations/typed_properties _105.phpt ext/reflection/php_reflection.c |
||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-104869@lists.php.net to get a copy of this message | ||
Commit: 1ca9d818b8405159ef96cb974a21714881e1146c
Author: Joe Watkins <krakjoe@php.net> Wed, 27 Feb 2019 09:17:09 +0100
Parents: d303225c3a463cb0a7dabb51234adf684de13fa5
Branches: PHP-7.4
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=1ca9d818b8405159ef96cb974a21714881e1146c
Log:
Fix #77673 ReflectionClass::getDefaultProperties returns spooky array
Bugs:
https://bugs.php.net/77673
Changed paths:
A Zend/tests/type_declarations/typed_properties_105.phpt
M ext/reflection/php_reflection.c
Diff:
diff --git a/Zend/tests/type_declarations/typed_properties_105.phpt
b/Zend/tests/type_declarations/typed_properties_105.phpt
new file mode 100644
index 0000000..747ff9f
--- /dev/null
+++ b/Zend/tests/type_declarations/typed_properties_105.phpt
@@ -0,0 +1,20 @@
+--TEST--
+Bug #77673 ReflectionClass::getDefaultProperties returns spooky array
+--FILE--
+<?php
+class A {
+ public B $c;
+}
+
+$class = new ReflectionClass(A::class);
+
+$defaults = $class->getDefaultProperties();
+
+var_dump($defaults);
+var_dump(array_key_exists('c', $defaults));
+?>
+--EXPECT--
+array(0) {
+}
+bool(false)
+
diff --git a/ext/reflection/php_reflection.c b/ext/reflection/php_reflection.c
index bfbe88f..20c23f1 100644
--- a/ext/reflection/php_reflection.c
+++ b/ext/reflection/php_reflection.c
@@ -3761,7 +3761,7 @@ static void add_class_vars(zend_class_entry *ce, int statics, zval
*return_value
} else if (!statics && (prop_info->flags & ZEND_ACC_STATIC) == 0) {
prop = &ce->default_properties_table[OBJ_PROP_TO_NUM(prop_info->offset)];
}
- if (!prop) {
+ if (!prop || (prop_info->type && Z_ISUNDEF_P(prop))) {
continue;
}