Skip to content

Commit

Permalink
1.2.1: #11
Browse files Browse the repository at this point in the history
  • Loading branch information
dmitrii-fediuk committed Jul 19, 2023
1 parent f2f1ec3 commit c6698b5
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 4 deletions.
26 changes: 23 additions & 3 deletions Plugin/Directory/Model/Currency.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,26 @@ class Currency {
* https://mage2.pro/t/1929
* @see \Magento\Directory\Model\Currency::format()
* https://github.com/magento/magento2/blob/2.0.0/app/code/Magento/Directory/Model/Currency.php#L253-L265
* 2023-07-19
* 1) «TypeError: Dfe\CurrencyFormat\Plugin\Directory\Model\Currency::aroundFormat():
* Argument #3 ($price) must be of type float, null given»: https://github.com/mage2pro/currency-format/issues/11
* 2) Magento 2.4.7-beta1 can pass `null` as $price:
* The call stack:
* 2.1) @see \Magento\Backend\Block\Dashboard\Totals::_prepareLayout():
* $this->addTotal(__('Revenue'), $totals->getRevenue());
* $totals->getRevenue() can be `null` there.
* https://github.com/magento/magento2/blob/2.4.7-beta1/app/code/Magento/Backend/Block/Dashboard/Totals.php#L108-L108
* 2.2) @see \Magento\Backend\Block\Dashboard\Bar::addTotal():
* $value = $this->format($value);
* https://github.com/magento/magento2/blob/2.4.7-beta1/app/code/Magento/Backend/Block/Dashboard/Bar.php#L54-L54
* 2.3) @see \Magento\Backend\Block\Dashboard\Bar::format():
* return $this->getCurrency()->format($price);
* https://github.com/magento/magento2/blob/2.4.7-beta1/app/code/Magento/Backend/Block/Dashboard/Bar.php#L70-L70
* @param float|null $price
* @param array(string => string|int) $opt [optional]
*/
function aroundFormat(
Sb $sb, \Closure $f, float $price, array $opt = [], bool $container = true, bool $brackets = false
Sb $sb, \Closure $f, $price, array $opt = [], bool $container = true, bool $brackets = false
):string {
$s = Settings::s()->get($sb->getCode()); /** @var O $s */
return
Expand All @@ -27,10 +43,12 @@ function aroundFormat(
* https://mage2.pro/t/1929
* @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()
* @param float|null $price
* @param array(string => string|int) $options [optional]
*/
function aroundFormatPrecision(
Sb $sb, \Closure $f, float $price, int $precision, array $options = [], bool $container = true, bool $brackets = false
Sb $sb, \Closure $f, $price, int $precision, array $options = [], bool $container = true, bool $brackets = false
):string {
if (Settings::ignorePrecision()) {
$s = Settings::s()->get($sb->getCode()); /** @var O $s */
Expand All @@ -51,9 +69,11 @@ function aroundFormatPrecision(
* @see \Dfe\CurrencyFormat\Plugin\Framework\Pricing\Render\Amount::beforeFormatCurrency()
* 3) @see \Magento\Directory\Model\Currency::formatTxt()
* https://github.com/magento/magento2/blob/2.0.0/app/code/Magento/Directory/Model/Currency.php#L301-L314
* 2023-07-19 Magento 2.4.7-beta1 can pass `null` as $price: @see self::aroundFormat()
* @param float|null $price
* @param array(string => string|int) $options [optional]
*/
function aroundFormatTxt(Sb $sb, \Closure $f, float $price, array $options = []):string {
function aroundFormatTxt(Sb $sb, \Closure $f, $price, array $options = []):string {
$s = Settings::s()->get($sb->getCode()); /** @var O $s */
/**
* 2016-08-01
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "mage2pro/currency-format"
,"version": "1.2.0"
,"version": "1.2.1"
,"description": "The «Price Format» extension for Magento 2"
,"type": "magento2-module"
,"homepage": "https://mage2.pro/c/price-format"
Expand Down

0 comments on commit c6698b5

Please sign in to comment.