Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PHP 8.1 implictly converting from float to int loses precision in StringUtil.php #366

Open
Ian-Robinson1 opened this issue Sep 2, 2024 · 3 comments

Comments

@Ian-Robinson1
Copy link

Ian-Robinson1 commented Sep 2, 2024

SDK you're using (please complete the following information):

  • Version 2.32 (But the erronious line is present in the latest version as well)

Describe the bug
In PHP 8.1, it issues a warning when implicitly converting the $seconds variable to int in line 80 in StringUtil.php.

To Reproduce
Execute any code that enters the convertStringToDateTime function and enters the else statement

Additional Context
This can be fixed by changing line 80 in String Util.php from:

$datetime->setTimestamp($seconds);

To:

$datetime->setTimestamp((int)$seconds);

Copy link

github-actions bot commented Sep 2, 2024

PETOSS-564

Copy link

github-actions bot commented Sep 2, 2024

Thanks for raising an issue, a ticket has been created to track your request

@sarahk
Copy link

sarahk commented Oct 1, 2024

I'm getting this when I am working with payment dates.

example: 'updated_date_utc' => $row->getUpdatedDateUtcAsDate()->format('Y-m-d H:i:s'),

Deprecated: Implicit conversion from float 1507667758.76 to int loses precision in [...]/vendor/xeroapi/xero-php-oauth2/lib/StringUtil.php on line 80

but not on this 'date' => $row->getDateAsDate()->format('Y-m-d H:i:s'),

I'm guessing it's because the "date" is rounded up, and the updated_date_utc isn't.

date: /Date(1507593600000+0000)/
updated_date_utc: /Date(1507667758760+0000)/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants