Commit ac9a9cd6016 for php
commit ac9a9cd60164019759076dd6613cc09f3be00c13
Author: ndossche <nora.dossche@ugent.be>
Date: Mon Nov 9 15:57:04 2026 +0100
Reflection: Fix ReflectionProperty::isReadable() not working for indirect slots
Closes GH-25341.
diff --git a/NEWS b/NEWS
index 5324e665a76..9af867c2c1b 100644
--- a/NEWS
+++ b/NEWS
@@ -78,6 +78,8 @@ PHP NEWS
(Lazizbek Ergashev)
. Fix trampoline leak when object construction fails for lazy object.
(ndossche)
+ . Fix ReflectionProperty::isReadable() not working for indirect slots.
+ (ndossche)
- Streams:
. Fixed in-place URL decoding of interned strings in the HTTP and FTP
diff --git a/ext/reflection/php_reflection.c b/ext/reflection/php_reflection.c
index 66fe0ec52f0..ee93160d5a5 100644
--- a/ext/reflection/php_reflection.c
+++ b/ext/reflection/php_reflection.c
@@ -6770,6 +6770,7 @@ retry_declared:;
zend_class_init_statics(ce);
}
zval *prop_val = CE_STATIC_MEMBERS(ce) + prop->offset;
+ ZVAL_DEINDIRECT(prop_val);
RETURN_BOOL(!Z_ISUNDEF_P(prop_val));
}
diff --git a/ext/reflection/tests/ReflectionProperty_isReadable_indirect.phpt b/ext/reflection/tests/ReflectionProperty_isReadable_indirect.phpt
new file mode 100644
index 00000000000..78f2eb8c33f
--- /dev/null
+++ b/ext/reflection/tests/ReflectionProperty_isReadable_indirect.phpt
@@ -0,0 +1,25 @@
+--TEST--
+Test ReflectionProperty::isReadable() indirect
+--FILE--
+<?php
+
+class ParentClass {
+ public static int $prop;
+}
+
+class ChildClass extends ParentClass {}
+
+var_dump((new ReflectionProperty('ParentClass', 'prop'))->isReadable(null));
+var_dump((new ReflectionProperty('ChildClass', 'prop'))->isReadable(null));
+
+ChildClass::$prop = 1;
+
+var_dump((new ReflectionProperty('ParentClass', 'prop'))->isReadable(null));
+var_dump((new ReflectionProperty('ChildClass', 'prop'))->isReadable(null));
+
+?>
+--EXPECT--
+bool(false)
+bool(false)
+bool(true)
+bool(true)