The IniReader checks whether an integer will overflow by using:
return (string) ($value + 0) === $value;
However, that will not work when the value has leading zeroes or a leading plus sign or any other characters that would be silently ignored by PHP.
In addition, the decode() method converts from string to int by simply adding zero to the string. This is effectively equivalent to using an (int) cast, which doesn't account for a leading radix indicator, such as 0t, 0x, 0b, and 0o (or just a leading 0).
Lastly, the methods that accomplish the above are all private which makes them impossible to override in PHP. I had to modify the private methods to be protected, so that a derived class could fix this deficiency.
I'm happy to package up my changes as a PR, if you wish.
The IniReader checks whether an integer will overflow by using:
However, that will not work when the value has leading zeroes or a leading plus sign or any other characters that would be silently ignored by PHP.
In addition, the
decode()method converts from string to int by simply adding zero to the string. This is effectively equivalent to using an (int) cast, which doesn't account for a leading radix indicator, such as0t,0x,0b, and0o(or just a leading0).Lastly, the methods that accomplish the above are all
privatewhich makes them impossible to override in PHP. I had to modify the private methods to be protected, so that a derived class could fix this deficiency.I'm happy to package up my changes as a PR, if you wish.