From a5a2032e75be8160c4e68c24181dfdbc66e67f82 Mon Sep 17 00:00:00 2001 From: Diogo Peralta Cordeiro Date: Sun, 2 May 2021 00:14:24 +0100 Subject: [PATCH] [ENTITY] Fix entity->has to access private properties with closure bindTo --- src/Core/Entity.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/Core/Entity.php b/src/Core/Entity.php index 9d829aa533..3516843c72 100644 --- a/src/Core/Entity.php +++ b/src/Core/Entity.php @@ -35,7 +35,10 @@ abstract class Entity { if (Formatting::startsWith($name, 'has')) { $prop = Formatting::camelCaseToSnakeCase(Formatting::removePrefix($name, 'has')); - return isset($this->{$prop}); + // https://wiki.php.net/rfc/closure_apply#proposal + $private_property_accessor = function($prop) { return isset($this->{$prop}); }; + $private_property_accessor = $private_property_accessor->bindTo($this, get_called_class()); + return $private_property_accessor($prop); } throw new \Exception("Entity::{$name} called with bogus arguments: " . print_r($arguments, true)); }