From dd55fb1980a6b75a6ac2e4684a6e6e6d59fcb614 Mon Sep 17 00:00:00 2001 From: Nigel Cunningham Date: Sat, 10 Aug 2024 21:15:34 +1000 Subject: [PATCH] Provide a way to set and unset a dynamic property. (Previously, the set test checked for existence, giving you no way of creating the property dynamically). Signed-off-by: Nigel Cunningham --- src/Ratchet/Traits/DynamicPropertiesTrait.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/Ratchet/Traits/DynamicPropertiesTrait.php b/src/Ratchet/Traits/DynamicPropertiesTrait.php index 5ebeac47..e470c93c 100644 --- a/src/Ratchet/Traits/DynamicPropertiesTrait.php +++ b/src/Ratchet/Traits/DynamicPropertiesTrait.php @@ -20,9 +20,7 @@ trait DynamicPropertiesTrait * @return void */ public function __set($key, $value) { - if (property_exists($this, $key)) { - $this->_dynamic_properties[$key] = $value; - } + $this->_dynamic_properties[$key] = $value; } /** @@ -46,4 +44,8 @@ public function __get($key) { public function __isset($key) { return isset($this->_dynamic_properties[$key]); } + + public function __unset($key) { + unset($this->_dynamic_properties[$key]); + } }