Skip to content

Commit

Permalink
Ensure the default value is one of the type we're expecting to find
Browse files Browse the repository at this point in the history
  • Loading branch information
tvdijen committed Jan 16, 2025
1 parent 94db95a commit a73db7e
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/AbstractElement.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,8 @@ public static function getOptionalAttribute(
string $type = StringValue::class,
?ValueTypeInterface $default = null,
): ?ValueTypeInterface {
Assert::nullOrIsInstanceOf($default, $type);

if (!$xml->hasAttribute($name)) {
return $default;
}
Expand Down

0 comments on commit a73db7e

Please sign in to comment.