Skip to content

Commit 00554c6

Browse files
committed
Fix reading and writing non-public virtual properties
1 parent 5a0705d commit 00554c6

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

ChangeLog.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@ XP Reflection ChangeLog
33

44
## ?.?.? / ????-??-??
55

6+
### 2.13.2 / 2023-06-04
7+
8+
* Fixed reading and writing non-public virtual properties - @thekid
9+
610
## 2.13.1 / 2023-06-04
711

812
* Fixed parsing arrow functions inside arrays - @thekid

src/main/php/lang/reflection/Property.class.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ public function get($instance, $context= null) {
5454

5555
// Only allow reading non-public properties when given a compatible context
5656
if (!$this->reflect->isPublic()) {
57-
if ($context && Reflection::of($context)->is($this->reflect->class)) {
57+
if ($context && Reflection::of($context)->is($this->reflect->getDeclaringClass()->name)) {
5858
$this->reflect->setAccessible(true);
5959
} else {
6060
throw new CannotAccess($this, new ReflectionException('Trying to read non-public property'));
@@ -82,7 +82,7 @@ public function set($instance, $value, $context= null) {
8282

8383
// Only allow reading non-public properties when given a compatible context
8484
if (!$this->reflect->isPublic()) {
85-
if ($context && Reflection::of($context)->is($this->reflect->class)) {
85+
if ($context && Reflection::of($context)->is($this->reflect->getDeclaringClass()->name)) {
8686
$this->reflect->setAccessible(true);
8787
} else {
8888
throw new CannotAccess($this, new ReflectionException('Trying to write non-public property'));

0 commit comments

Comments
 (0)