We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
DateTimeInterface
I want to serialize date objects (DateTimeInterface to be concrete).
They are used by nearly every PHP application. Serializing them is actually very simple, and sending them doesn't cause much overhead.
This is how this would look like in Sentry:
Compare it to how these are currently displayed:
In AbstractSerializer::serializeRecursively() we could add the following:
AbstractSerializer::serializeRecursively()
if (\is_object($value)) { foreach ($classSerializers as $classSerializer) { ... } if ($value instanceof \DateTimeInterface) { return $this->serializeDate($value); }
protected function serializeDate(\DateTimeInterface $date): string { $hasMicroseconds = $date->format("u") !== "000000"; $formatted = $hasMicroseconds ? $date->format("Y-m-d H:i:s.u") : $date->format("Y-m-d H:i:s"); $className = get_class($date); if ($date->getTimezone()) { // Also add timezone information } return "$className($formatted)"; }
The text was updated successfully, but these errors were encountered:
Would you be willing to open a PR?
Sorry, something went wrong.
Successfully merging a pull request may close this issue.
Problem Statement
I want to serialize date objects (
DateTimeInterface
to be concrete).They are used by nearly every PHP application. Serializing them is actually very simple, and sending them doesn't cause much overhead.
This is how this would look like in Sentry:
![Image](https://private-user-images.githubusercontent.com/1061218/406129324-485c1cd6-2648-4a3b-b901-28151122ca8c.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Mzg5NjYwNzYsIm5iZiI6MTczODk2NTc3NiwicGF0aCI6Ii8xMDYxMjE4LzQwNjEyOTMyNC00ODVjMWNkNi0yNjQ4LTRhM2ItYjkwMS0yODE1MTEyMmNhOGMucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI1MDIwNyUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNTAyMDdUMjIwMjU2WiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9NDAwYzQxNTAwZDVmY2RmYjgzYTJkMTNiMTI1NWE2NmQ1MDFiYzRhNTM3MzVjMjAzZjUwZjc0ZWI1NGViNjEzNyZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QifQ.zS1T06RyBvxHSHErLHEG1GRGCAc_RVHglvxh4KCDK7w)
Compare it to how these are currently displayed:
![Image](https://private-user-images.githubusercontent.com/1061218/406129475-23d52c85-a7a7-449d-af77-67169f7330bc.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Mzg5NjYwNzYsIm5iZiI6MTczODk2NTc3NiwicGF0aCI6Ii8xMDYxMjE4LzQwNjEyOTQ3NS0yM2Q1MmM4NS1hN2E3LTQ0OWQtYWY3Ny02NzE2OWY3MzMwYmMucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI1MDIwNyUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNTAyMDdUMjIwMjU2WiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9NjkyYjEyOTg2ZDRlYzdmYTUwMDczZWQwZWE2ZTQ5YjI3ODUzMmFlNmRjNDljZDA0MDAxZDY5MTVmNjgwODllNiZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QifQ.WKbUPe-_9WJVSD2n9xuKvYdwDLfTulZSf2eePPvxq9c)
Solution Brainstorm
In
AbstractSerializer::serializeRecursively()
we could add the following:The text was updated successfully, but these errors were encountered: