[php-src] master: Reflection: Fix ReflectionProperty::isReadable() not working for indirect slots
| From: | ndossche | Date: | Mon, 09 Nov 2026 17:45:15 +0000 |
| Subject: | [php-src] master: Reflection: Fix ReflectionProperty::isReadable() not working for indirect slots | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-143494@lists.php.net to get a copy of this message | ||
Author: ndossche (ndossche)
Date: 2026-11-09T18:44:52+01:00
Commit: https://github.com/php/php-src/commit/ac9a9cd60164019759076dd6613cc09f3be00c13
Raw diff: https://github.com/php/php-src/commit/ac9a9cd60164019759076dd6613cc09f3be00c13.diff
Reflection: Fix ReflectionProperty::isReadable() not working for indirect slots
Closes GH-25341.
Changed paths:
A ext/reflection/tests/ReflectionProperty_isReadable_indirect.phpt
M NEWS
M ext/reflection/php_reflection.c
Diff:
diff --git a/NEWS b/NEWS
index 5324e665a764..9af867c2c1b0 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 66fe0ec52f05..ee93160d5a5e 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 000000000000..78f2eb8c33f4
--- /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)