Skip to content

Commit

Permalink
Fix issue #115 with unknown properties (#116)
Browse files Browse the repository at this point in the history
Co-authored-by: Nathan Salter <[email protected]>
  • Loading branch information
nathansalter and Nathan Salter authored Sep 26, 2024
1 parent 15227e9 commit 22abbea
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/BaseModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
1 change: 1 addition & 0 deletions tests/Unit/order.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"@type":"OrderItem",
"@id":"https://fencing-book/item/12345",
"orderItemStatus":"https://openactive.io/OrderItemConfirmed",
"foo:unknown-property": "Rawr!",
"unitTaxSpecification":[
{
"@type":"TaxChargeSpecification",
Expand Down

0 comments on commit 22abbea

Please sign in to comment.