sdk_php
sdk_php copied to clipboard
SessionContext: "Deprecated: Implicit conversion from float to int loses precision"
Steps to reproduce:
- Use PHP 8.1 and catch all errors including deprecations
- Create a new ApiContext:
$apiContext = ApiContext::create($environmentType, $apiKey, $appName);
What should happen:
- Not giving a deprecated message
What happens:
- Getting ErrorException with "Deprecated: Implicit conversion from float 1645417887.258314 to int loses precision"
Traceback
Relevant traceback entry (from my sentry setup):
Crashed in non-app: /vendor/bunq/sdk_php/src/Context/SessionContext.php in bunq\Context\SessionContext::microTimeToDateTime
SDK version and environment
- Tested on 1.19.1
- PHP 8.1.2 (Docker setup from php:8.1-fpm-buster)
- If relevant: Symfony 5.4.4
- [ ] Sandbox
- [x] Production
Extra info:
The implicit conversion of float to int which leads to a loss in precision is deprecated since PHP 8.1.
float $microtime
is passed thru as second parameter to date()
, but that must be an int
so it is cast implicit here: https://github.com/bunq/sdk_php/blob/dbe2472580051db7ada486406450f0b30ad99221/src/Context/SessionContext.php#L134