-
-
Notifications
You must be signed in to change notification settings - Fork 567
Throw SerializationError
over client safe Error
when failing to serialize leaf types
#903
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…erialize scalars Resolves #570
Codecov Report
@@ Coverage Diff @@
## master #903 +/- ##
==========================================
- Coverage 94.11% 94.10% -0.01%
==========================================
Files 117 117
Lines 9679 9675 -4
==========================================
- Hits 9109 9105 -4
Misses 570 570
Continue to review full report at Codecov.
|
SerializationError
over client safe Error
when failing to serialize scalarsSerializationError
over client safe Error
when failing to serialize leaf values
SerializationError
over client safe Error
when failing to serialize leaf valuesSerializationError
over client safe Error
when failing to serialize leaf types
I let the
|
'String cannot represent value: ' . Utils::printSafe($value) | ||
); | ||
} | ||
|
||
return (string) $value; | ||
} | ||
|
||
/** | ||
* @param mixed $value |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd keep those mixed so they can be converted to (mixed $value)
on php 8 automatically.
With this change we wouldn't be able to distinguish intentional mixed versus forgotten type. Also, consumers can @inheritDoc
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The parent method still has the explicit mixed
annotation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But the thing with php is to specify types even in implementations but that's related to previous discussion on disabling missing type checks.
We can have @inheritdoc here so it explicitly says we want mixed
here.
With this change it's ambiguous: is it forgotten or inherited? What if parent type narrows, should it be narrowed here as well?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good tooling I use assumes the parent PHPDoc is inherited, unless specifically overwritten. Perhaps we can document and reify that assumption as part of the contribution guidelines?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do as you think is the best but personally I don't like trading automated checks for a piece of text few people read 🤷🏾♀️
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am fairly confident we will keep this project moving towards stronger types without duplicating code.
# Conflicts: # CHANGELOG.md # src/Type/Definition/BooleanType.php # src/Type/Definition/FloatType.php # src/Type/Definition/IDType.php # src/Type/Definition/IntType.php # src/Type/Definition/StringType.php # tests/Executor/TestClasses/ComplexScalar.php
Resolves #570