diff --git a/src/BaseModel.php b/src/BaseModel.php index 25ec4f04..23f1b8cb 100644 --- a/src/BaseModel.php +++ b/src/BaseModel.php @@ -72,6 +72,10 @@ public function defineProperty($key, $value) // Build setter name $setterName = "set" . Str::pascal($key); + if (!method_exists($this, $setterName)) { + // Don't attempt to set new properties which haven't been defined upstream yet + return; + } // Calling the setter will type-enforce the values diff --git a/tests/Unit/order.json b/tests/Unit/order.json index 53c8aef8..913d06da 100644 --- a/tests/Unit/order.json +++ b/tests/Unit/order.json @@ -7,6 +7,7 @@ "@type":"OrderItem", "@id":"https://fencing-book/item/12345", "orderItemStatus":"https://openactive.io/OrderItemConfirmed", + "foo:unknown-property": "Rawr!", "unitTaxSpecification":[ { "@type":"TaxChargeSpecification",