Thanks to visit codestin.com
Credit goes to github.com

Skip to content

MoneyType field and bad conversion to int #53929

Closed
@JacquesDurand

Description

@JacquesDurand

Symfony version(s) affected

7.1

Description

Hello, and thank you for your work on Symfony !
I just stumbled upon what seems to be a bug with the MoneyType form type incoming option 'model_type' => 'integer (cf symfony/symfony-docs#19359) while trying to do kind of the same thing.

It seems that when inputing large numbers (probably because of the scientific notation introduced when a conversion to float happens - in rounding maybe ?, the cast back to an integer presents some issues:

Inputing for instance 111111111111111110,00 gets cast back to 9223372036854775807. (cf my reproducer)

I realise that this is probably very niche (such large numbers for MoneyType fields), but I felt this might need to get looked at

How to reproduce

Here is a short reproducer:
https://github.com/JacquesDurand/money_type_reproducer
(see readme for description on how to reproduce)

Possible Solution

I feel I do not know enough about large number treatments and conversions in PHP, but if you feel that there is a simple fix, I'd be happy to contribute it !

Additional Context

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions