bunq / sdk_php

PHP SDK for bunq API
MIT License
83 stars 54 forks source link

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

Closed erkens closed 10 months ago

erkens commented 2 years ago

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

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