Closed zlodes closed 5 months ago
PHP doesn't support uint64
:
PHP does not support unsigned ints. int size can be determined using the constant PHP_INT_SIZE, maximum value using the constant PHP_INT_MAX, and minimum value using the constant PHP_INT_MIN.
In that case, what is your suggestion to fix that? The only way to return '18446744073709551615'
is using string, which will have a performance penalty and you should use bcmath
library to manipulate it anyway. Returning strings and numbers, mixed, will break any ===
.
It's possible a duplicate of https://github.com/protocolbuffers/protobuf/issues/5216
@inkeliz
The only way to return '18446744073709551615' is using string
Yes. And it would be correct.
And then the developer may use bcmath
or another way to operate with big number.
Now it looks like that method will return int|string
(original PHPDoc reference) and method was written to return int
if the number fits to int
and string
otherwise. But there is a mistake and it doesn't work properly.
And now to fix this mistake I should to remove GPBUtil::checkUint64($var);
from generated code to make it works.
This is a known issue that we are working to prioritize
Is there an update on this issue? I am also running into it.
Just opened PR to fix that. I've waited for more than a year and decided to fix it by myself 😄
Does setValueUnwrapped()
resolve this ticket?
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 inactive
because the last activity was over 90 days ago.
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 inactive
label was added.
Hi!
Generated setters for fixed64 or uint64 are using
intval($var)
in case ofPHP_INT_SIZE == 8
(any 64x system).But max value of uint64 is greater than PHP_INT_MAX:
2^64-1
vs.2^63-1
.I have written tests: https://github.com/zlodes/protobuf-bugs-demo There are results: https://github.com/zlodes/protobuf-bugs-demo/runs/5235953996?check_suite_focus=true
Code fragment from tests:
... and from generated class:
More you can find here: https://github.com/zlodes/protobuf-bugs-demo
Environment:
PHP:
Protoc
google/protobuf package