Skip to content

Commit

Permalink
Provide a way to set and unset a dynamic property.
Browse files Browse the repository at this point in the history
(Previously, the set test checked for existence, giving you no way
of creating the property dynamically).

Signed-off-by: Nigel Cunningham <nigel@nigelcunningham.com.au>
  • Loading branch information
NigelCunningham committed Aug 10, 2024
1 parent 4982587 commit dd55fb1
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/Ratchet/Traits/DynamicPropertiesTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

/**
Expand All @@ -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]);
}
}

0 comments on commit dd55fb1

Please sign in to comment.