-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
DoctrineDataCollector: taught sanitizeParam to support classes with __toString implemented. #20680
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
I think we need to dump the class name all the time. At least this is what Monolog does in this case: |
Monolog in that source does both. It uses class name as a key, and __toString() call result as a value. |
@FractalizeR that's what I meant :) And I think that's wise. |
@@ -159,7 +159,9 @@ private function sanitizeQuery($connectionName, $query) | |||
private function sanitizeParam($var) | |||
{ | |||
if (is_object($var)) { | |||
return array(sprintf('Object(%s)', get_class($var)), false); | |||
return method_exists($var, '__toString') ? | |||
array($var->__toString(), false) : |
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 agree that the class name should be dumped here as well. The way it is implemented will cause confusing results.
What's the status of this PR? |
@FractalizeR Any news? Are still interested in finishing this PR? |
Yeah, sure. But I am at lost who makes a decision about how this PR should really look like. I'm ready to make desired modifications, but someone responsible needs to tell me what needs to be adjusted. |
I think we all agree that we need to keep the class name, even when there is a string representation. |
Can we, then, use the following representation for objects, implementing
? |
@FractalizeR I think that makes sense. |
14e2631
to
d3f9d16
Compare
Done. Some tests fail, but this is not due my PR, but several other components. Looks like some PR was merged without ensuring tests pass. |
|
||
public function __toString() | ||
{ | ||
return $this->representation; |
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.
Can we simplify this class by removing the representation
property and hardcode the text here directly?
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.
see 26c54c7
Thank you @FractalizeR. |
This PR teaches \Symfony\Bridge\Doctrine\DataCollector\DoctrineDataCollector::sanitizeParam support objects, which implement __toString and therefore can be represented as a string with more sense, than "(object) ClassName". It also includes test for the feature.