-
-
Notifications
You must be signed in to change notification settings - Fork 37
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
Implement the ability for user-defined type casting #941
base: master
Are you sure you want to change the base?
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #941 +/- ##
=========================================
Coverage 99.23% 99.23%
- Complexity 1534 1540 +6
=========================================
Files 98 98
Lines 3804 3812 +8
=========================================
+ Hits 3775 3783 +8
Misses 29 29 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Co-authored-by: Alexander Makarov <[email protected]>
/** | ||
* `JsonSerializable` interface is implemented to convert the object to a database representation. | ||
*/ | ||
public function jsonSerialize(): array |
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.
May be to add another example with dbTypecast()
. This allow to keep DTO clear, without infrastructure things.
{ | ||
return match ($type) { | ||
/** @psalm-var class-string<ColumnInterface> */ | ||
return $this->mapType($this->columnClassMap, $type, $info) ?? match ($type) { |
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.
Extract match ($type) { ...
to separate method. This allow to prevent duplicate $this->mapType(...)
in yiisoft/db-*
packages.
Related PRs