sdk_php icon indicating copy to clipboard operation
sdk_php copied to clipboard

SessionContext: "Deprecated: Implicit conversion from float to int loses precision"

Open erkens opened this issue 2 years ago • 0 comments

Steps to reproduce:

  1. Use PHP 8.1 and catch all errors including deprecations
  2. Create a new ApiContext: $apiContext = ApiContext::create($environmentType, $apiKey, $appName);

What should happen:

  1. Not giving a deprecated message

What happens:

  1. 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

erkens avatar Feb 14 '22 04:02 erkens