Skip to content

Commit 9578313

Browse files
committed
use get_object_vars & isset
1 parent be979b1 commit 9578313

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

src/Render/RenderContext.php

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -210,17 +210,21 @@ public function internalContextLookup(mixed $scope, int|string $key): mixed
210210

211211
protected function objectHasProperty(object $object, string $property): bool
212212
{
213-
if (property_exists($object, $property) || method_exists($object, '__get')) {
214-
try {
215-
$value = $object->{$property};
213+
try {
214+
// Check if the property is a public property
215+
if (array_key_exists($property, get_object_vars($object))) {
216+
return true;
217+
}
216218

219+
// Check if the property is accessible via __get() and __isset()
220+
if (isset($object->{$property})) {
217221
return true;
218-
} catch (Throwable) {
219-
return false;
220222
}
221-
}
222223

223-
return false;
224+
return false;
225+
} catch (Throwable) {
226+
return false;
227+
}
224228
}
225229

226230
public function normalizeValue(mixed $value): mixed

0 commit comments

Comments
 (0)