Skip to content

Commit

Permalink
https://github.com/mage2pro/core/issues/325
Browse files Browse the repository at this point in the history
  • Loading branch information
dmitrii-fediuk committed Aug 6, 2023
1 parent 791c217 commit 868564b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
16 changes: 12 additions & 4 deletions Plugin/Directory/Model/Currency.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
use Dfe\CurrencyFormat\O;
use Dfe\CurrencyFormat\Settings;
use Magento\Directory\Model\Currency as Sb;
use Magento\Framework\Pricing\PriceCurrencyInterface as IPriceCurrency;
class Currency {
/**
* 2016-08-03
Expand Down Expand Up @@ -44,15 +45,22 @@ function aroundFormat(
* @see \Magento\Directory\Model\Currency::formatPrecision()
* https://github.com/magento/magento2/blob/2.0.0/app/code/Magento/Directory/Model/Currency.php#L267-L294
* 2023-07-19 Magento 2.4.7-beta1 can pass `null` as $price: @see self::aroundFormat()
* 2023-08-06
* «Dfe\CurrencyFormat\Plugin\Directory\Model\Currency::aroundFormatPrecision():
* Argument #4 ($precision) must be of type int, null given»: https://github.com/mage2pro/currency-format/issues/14
* @param int|null $precision
* @param float|null $price
* @param array(string => string|int) $options [optional]
*/
function aroundFormatPrecision(
Sb $sb, \Closure $f, $price, $precision, array $options = [], bool $container = true, bool $brackets = false
Sb $sb, \Closure $f, $price
/**
* 2023-08-06
* 1) "Declare optional argument values for intercepted methods": https://github.com/mage2pro/core/issues/325
* 2) "Magento does not pass the values of missed optional arguments of intercepted methods to plugins":
* https://mage2.pro/t/6378
* 3) «Dfe\CurrencyFormat\Plugin\Directory\Model\Currency::aroundFormatPrecision():
* Argument #4 ($precision) must be of type int, null given»: https://github.com/mage2pro/currency-format/issues/14
*/
,int $precision = IPriceCurrency::DEFAULT_PRECISION
,array $options = [], bool $container = true, bool $brackets = false
):string {
if (Settings::ignorePrecision()) {
$s = Settings::s()->get($sb->getCode()); /** @var O $s */
Expand Down
3 changes: 1 addition & 2 deletions Plugin/Framework/Pricing/Render/Amount.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ function __construct() {}
* метод @see \Magento\Framework\Pricing\Render\Amount::formatCurrency()
* подставляет значение по умолчанию,
* и мы не знаем: опустил ли программист параметр или нет.
* @param int|null $precision [optional]
*/
function beforeFormatCurrency(
Sb $sb, float $a, bool $includeContainer = true
Expand All @@ -56,7 +55,7 @@ function beforeFormatCurrency(
* https://mage2.pro/t/6378
* 3) @see \Magento\Framework\Pricing\Render\Amount::formatCurrency()
*/
,$precision = IPriceCurrency::DEFAULT_PRECISION
,int $precision = IPriceCurrency::DEFAULT_PRECISION
):array {
/**
# 2015-12-31
Expand Down

0 comments on commit 868564b

Please sign in to comment.