-
Notifications
You must be signed in to change notification settings - Fork 456
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
Custom object formatters #766
Custom object formatters #766
Conversation
1579bdd
to
273fd27
Compare
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.
Looks great!
@MartinMystikJonas hey, thanks for the PR! Can you fix the conflicts and update the PR based on @davedevelopment's and mine requests? Thank you! |
273fd27
to
41ea62e
Compare
Finally had time to finish this. Sorry about three years gap but after our daughter was born I had only little time for open source :-) |
41ea62e
to
24dc095
Compare
24dc095
to
c5088d1
Compare
Let me know if you want to merge it I will squash commits |
d46d566
to
8030081
Compare
Friendly ping, is there anything we can do to merge this? |
|
||
$array = array( | ||
'class' => $class, | ||
'identity' => '#' . md5(spl_object_hash($object)) |
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.
why?
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.
It is often useful to be able to compare object identities not only their class + some optional custom info from formatter. Should I remove it?
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 mean why the md5. Just use spl_object_id
.
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.
Besause spl_object_id is hard to compare visually becaue usually two instances have most characters of spl_object_hash identical. Using of md5 of spl_object_hash is quite common practice i saw in many libraries.
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.
For example I just used it on two objects and I got:
000000002f73941b000000004f808351 and 000000002ffa4e380000000026e9a821
If you use md5 it becomes different at the first sight:
69850868ab17d5cd4d7effccd55ba63c and 43147e68957af1fcbd045979c3c3fda3
Possibility to set custom objet formatters for specific classes or interfaces. If formatter is set it's used instead of default formatter outputing public properties.