Skip to content

Commit fd2dbac

Browse files
ignore non existing attributes (limosa-io#95)
1 parent 47d8379 commit fd2dbac

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

src/Attribute/Complex.php

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,6 @@ public function patch($operation, $value, Model &$object, Path $path = null, $re
110110
*/
111111
public function replace($value, Model &$object, Path $path = null, $removeIfNotSet = false)
112112
{
113-
$match = false;
114113
$this->dirty = true;
115114

116115
if ($this->mutability == 'readOnly') {
@@ -129,7 +128,6 @@ public function replace($value, Model &$object, Path $path = null, $removeIfNotS
129128
// if path contains : it is a schema node
130129
if (strpos($key, ':') !== false) {
131130
$subNode = $this->getSubNode($key);
132-
$match = true;
133131
} else {
134132
$path = Parser::parse($key);
135133

@@ -138,11 +136,10 @@ public function replace($value, Model &$object, Path $path = null, $removeIfNotS
138136
$path = $path->shiftAttributePathAttributes();
139137
$sub = $attributeNames[0] ?? $path->getAttributePath()?->path?->schema;
140138
$subNode = $this->getSubNode($attributeNames[0] ?? $path->getAttributePath()?->path?->schema);
141-
$match = true;
142139
}
143140
}
144141

145-
if ($match) {
142+
if ($subNode != null) {
146143
$newValue = $v;
147144
if ($path->isNotEmpty()) {
148145
$newValue = [
@@ -155,7 +152,7 @@ public function replace($value, Model &$object, Path $path = null, $removeIfNotS
155152
}
156153

157154
// if this is the root, we may also check the schema nodes
158-
if (!$match && $this->parent == null) {
155+
if ($subNode == null && $this->parent == null) {
159156
foreach ($this->subAttributes as $attribute) {
160157
if ($attribute instanceof Schema) {
161158
$attribute->replace($value, $object, $path);

0 commit comments

Comments
 (0)