-
Notifications
You must be signed in to change notification settings - Fork 1
Open
Labels
help wantedExtra attention is neededExtra attention is neededquestionFurther information is requestedFurther information is requested
Description
Current Behaviour
Omitted properties, without a default, are set to null.
When we need to use null as an actual value, we have to use a Value object.
This is the case for keywords that give values that should pass the Schema.
i.e. example, examples, const, enum, default
Reasons For
We get to use isset(<keyword>) or <keyword> === null to check for omitted properties. It's fast and built in.
The Value keyword hides away messy mixed typehints:
Value|null $keywordvs.
// @var scalar|array<mixed>|null $keyword
bool|float|int|string|array|null $keywordReasons Against
- We're adding semantic meaning to
nullwhich is not part of the Domain Specific Language.- A default of
nullis not "a default of null", it means "no default" - A default of
new Value(null)is "a default of null"
- A default of
Alternate Behaviour
Omitted properties, without a default, are set to Omitted.
Reasons For
Omittedis part of the Domain Specific Language.- No
Valuewrapper required (That is not to say we can't have both) nullis null (no additional semantic meaning behind it)
Reasons Against
- We can't use
isset(<keyword>)- You'd have to check
<keyword> === Omitted
- You'd have to check
- Typehints are more verbose. eg.
string|nullvs.string|Omitted
Discuss
Both solutions have their merits. I would like to weigh them up here, to have a written record of our design choices.
Metadata
Metadata
Assignees
Labels
help wantedExtra attention is neededExtra attention is neededquestionFurther information is requestedFurther information is requested