Skip to content

Get rid of 'money_format' function in lib/internal/Magento/Framework/Filter/Money.php #33870

@karyna-t

Description

@karyna-t

lib/internal/Magento/Framework/Filter/Money.php class contains 1 public function that uses php function money_format , which is deprecated in PHP 7.4 and removed in PHP 8.0.

According to the documentation, we should use NumberFormatter::formatCurrency() instead.

However, in our case, Money.php accepts 'format' property in the constructor. Later it's used as an argument for money_format function.
Looks like NumberFormatter doesn't have an ability to recognize a format, e.g. something like ' Test - %.2n' , which in theory can be passed. Thus we can't create a complete replacement of the method.

I haven't found any use of this class in Magento codebase, and it seems to be very old. So maybe it's OK to eliminate it.
On the other hand, this class is not deprecated and can be used outside.

A possible option is to replace implementation to the suggested NumberFormatter, and deprecate format property.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions