We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent d955c6c commit a31ae60Copy full SHA for a31ae60
1 file changed
src/Element/ElementHolder.php
@@ -45,6 +45,26 @@ public function get($key, $default = null)
45
return parent::get($key, $default);
46
}
47
48
+ /**
49
+ * __get dynamically retrieves the value of an attribute, a safe object
50
+ * is returned for missing keys to avoid indirect modification errors.
51
+ * @param string $key
52
+ * @return mixed
53
+ */
54
+ public function __get($key)
55
+ {
56
+ $result = $this->get($key);
57
+
58
+ if ($result === null) {
59
+ return new class {
60
+ public function __get($k) { return $this; }
61
+ public function __set($k, $v) {}
62
+ };
63
+ }
64
65
+ return $result;
66
67
68
/**
69
* getIterator for the elements.
70
*/
0 commit comments