-
-
Notifications
You must be signed in to change notification settings - Fork 140
Use int as the PHP representation of long fields in generated code #1471
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
Just a quick note about this: if portability on x86 is desired, int is a much smaller range. It allows only 2^31 integers, while float allows 2^53, and can handle even more if loss of accuracy is acceptable. |
This is a huge breaking change, also. |
In terms of the comment about loss of precision, this is already an issue in the code integer fields in the JSON get approximated, then cast to a string. This PR casts them back to an int. That is, unless AWS is encoding those as strings on their side already (like they do with 128-bit integers in dynamodb). |
The behavior used here is the same than in the official SDK: https://github.com/aws/aws-sdk-php/blob/1d3e7ae37f31dfe1d4e9d9e361fd8e6702074fbe/src/Api/Parser/AbstractRestParser.php#L109-L110 when looking at the diff, the places using
|
@GrahamCampbell regarding the BC break, this actually help fixing issues too. Receiving a count as a string would force you to cast it to do something useful with it anyway (or to rely on PHP type coercion to do it for you, which would then not break when we return an integer directly). |
People have the option to use bigint implementations on 32 bit systems to do something useful with the string without losing data. |
Given that the JSON contains a number, they will not get a string with the value from AWS. They will currently get a string cast of the numeric value decoded from JSON. On 32 bit systems, that would already lose information. |
We should work around that using the |
👍 for merging this for consistency with the SDK. They cast to But it's a BC break for end users we should add an entry in the changelog and I will release a major version for these components. And we should probably release an intermediate version with a deprecation notice 🤔 |
@jderusse a deprecation notice won't be possible. There is no way to opt-in a different PHP return type. |
That's a BC break for people using strict type... I agree, it's easy to fix, and they are already in trouble if they send alpha char in the string. But if they use it properly, this PR will break code like this one.
I'm still 👍 for merging it, but we should at least add an entry in the changelog and release a major version. |
Now that long fields are always defined as integer, we don't need such hacks anymore
@jderusse I added all the relevant changelog entries. |
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.
thanks 🙏
No description provided.