chargebee-php icon indicating copy to clipboard operation
chargebee-php copied to clipboard

Deprecated implicit float-to-int conversion

Open pawel-gagatek opened this issue 7 months ago • 1 comments

Description of the Bug

Hi,

I’ve encountered an issue with the from() method in the Subscription class

public static function from(array $resourceAttributes): self

Specifically, when setting the currency exchange rate (exchange_rate) for a subscription, the method appears to rely on an implicit conversion from float to int. This behavior has been deprecated in newer versions of PHP, starting from 8.1+, and will potentially trigger deprecation warnings or even fatal errors in future releases.

This deprecation is part of an official PHP RFC: 👉 https://wiki.php.net/rfc/implicit-float-int-deprecate

Why this matters:

Implicit float-to-int conversion can lead to silent data loss or unexpected results, particularly in financial calculations.

It creates compatibility issues with future versions of PHP.

It increases the risk of runtime errors in production systems using this SDK.

Steps to reproduce

I've attached the stack trace of the deprecation warning below for reference. Image

Expected Behavior

Suggested solution:

accept and handle float values properly where applicable

Code Snippets (if applicable)


Operating System

linux

Language version

PHP 8.1

Library version

v4.3

Additional context

No response

pawel-gagatek avatar May 22 '25 13:05 pawel-gagatek

Hi @pawel-gagatek, thanks for reporting this. We've fixed it in v4.4.0—please give it a try and let us know if you still run into any issues.

cb-alish avatar May 26 '25 10:05 cb-alish

Hi @pawel-gagatek, thanks for reporting this. We've fixed it in v4.4.0—please give it a try and let us know if you still run into any issues.

works good to me :) i am closing this issue then

pawel-gagatek avatar Jun 16 '25 07:06 pawel-gagatek