-
Notifications
You must be signed in to change notification settings - Fork 15.6k
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
PHP: use __debugInfo in Message to fix endless var_dump #12714
Comments
addresses #12714 by dumping more concise debug info for protobuf messages and repeated fields via the `serializeToJsonString` function. Additionally, message types which serialize into something other than an array (e.g. `Google\Protobuf\Value`, `Google\Protobuf\Timestamp`, etc) are handled in a special way to make their output consistent with other messages. ```php $m = new Google\Protobuf\DoubleValue(); $m->setValue(1.5); var_dump($m); ``` will output ``` object(Google\Protobuf\DoubleValue)#12 (1) { ["value"]=> float(1.5) } ``` Closes #12718 COPYBARA_INTEGRATE_REVIEW=#12718 from bshaffer:php-add-debuginfo c40a6f9 PiperOrigin-RevId: 574115431
We triage inactive PRs and issues in order to make it easier to find active work. If this issue should remain active or becomes active again, please add a comment. This issue is labeled |
We triage inactive PRs and issues in order to make it easier to find active work. If this issue should remain active or becomes active again, please reopen it. This issue was closed and archived because there has been no new activity in the 14 days since the |
Debugging a Protobuf Message Object
Calling
var_dump
orprint_r
on a protobuf message with the Protobuf C extension enabled results very limited, not very useful output:When using the Protobuf native library, calls to
var_dump
andprint_r
are hard to read and filled with noise:This problem is even worse when debugging instances of
RepeatedField
, as the result is never-ending.The fix for this would involve adding support for __debugInfo in the
Message
class:For better handling , we can add support for checking specific types (e.g.
Google\Protobuf\Timestamp
, which returns a string forserializeToJsonString
) and adding__debugInfo()
for specific classes such asRepeatedField
.The text was updated successfully, but these errors were encountered: