Skip to content

Commit 8d7c2fb

Browse files
author
Valeriy Naida
authored
ENGCOM-2853: [Forwardport] Replace floatval() function by using direct type casting to (float) #17733
2 parents e56badf + 487b7f9 commit 8d7c2fb

File tree

19 files changed

+27
-27
lines changed

19 files changed

+27
-27
lines changed

app/code/Magento/Backend/Block/Widget/Grid/Column/Renderer/Currency.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ public function render(\Magento\Framework\DataObject $row)
8282
{
8383
if ($data = (string)$this->_getValue($row)) {
8484
$currency_code = $this->_getCurrencyCode($row);
85-
$data = floatval($data) * $this->_getRate($row);
85+
$data = (float)$data * $this->_getRate($row);
8686
$sign = (bool)(int)$this->getColumn()->getShowNumberSign() && $data > 0 ? '+' : '';
8787
$data = sprintf("%f", $data);
8888
$data = $this->_localeCurrency->getCurrency($currency_code)->toCurrency($data);
@@ -118,10 +118,10 @@ protected function _getCurrencyCode($row)
118118
protected function _getRate($row)
119119
{
120120
if ($rate = $this->getColumn()->getRate()) {
121-
return floatval($rate);
121+
return (float)$rate;
122122
}
123123
if ($rate = $row->getData($this->getColumn()->getRateField())) {
124-
return floatval($rate);
124+
return (float)$rate;
125125
}
126126
return $this->_defaultBaseCurrency->getRate($this->_getCurrencyCode($row));
127127
}

app/code/Magento/Backend/Block/Widget/Grid/Column/Renderer/Price.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public function render(\Magento\Framework\DataObject $row)
6060
return $data;
6161
}
6262

63-
$data = floatval($data) * $this->_getRate($row);
63+
$data = (float)$data * $this->_getRate($row);
6464
$data = sprintf("%f", $data);
6565
$data = $this->_localeCurrency->getCurrency($currencyCode)->toCurrency($data);
6666
return $data;
@@ -94,10 +94,10 @@ protected function _getCurrencyCode($row)
9494
protected function _getRate($row)
9595
{
9696
if ($rate = $this->getColumn()->getRate()) {
97-
return floatval($rate);
97+
return (float)$rate;
9898
}
9999
if ($rate = $row->getData($this->getColumn()->getRateField())) {
100-
return floatval($rate);
100+
return (float)$rate;
101101
}
102102
return 1;
103103
}

app/code/Magento/Bundle/Pricing/Price/BundleSelectionFactory.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ public function create(
5454
) {
5555
$arguments['bundleProduct'] = $bundleProduct;
5656
$arguments['saleableItem'] = $selection;
57-
$arguments['quantity'] = $quantity ? floatval($quantity) : 1.;
57+
$arguments['quantity'] = $quantity ? (float)$quantity : 1.;
5858

5959
return $this->objectManager->create(self::SELECTION_CLASS_DEFAULT, $arguments);
6060
}

app/code/Magento/Catalog/Model/Product/Type/AbstractType.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -935,7 +935,7 @@ public function getForceChildItemQtyChanges($product)
935935
*/
936936
public function prepareQuoteItemQty($qty, $product)
937937
{
938-
return floatval($qty);
938+
return (float)$qty;
939939
}
940940

941941
/**

app/code/Magento/Catalog/Model/ResourceModel/Layer/Filter/Price.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ public function getCount($range)
112112
/**
113113
* Check and set correct variable values to prevent SQL-injections
114114
*/
115-
$range = floatval($range);
115+
$range = (float)$range;
116116
if ($range == 0) {
117117
$range = 1;
118118
}

app/code/Magento/Catalog/Pricing/Price/RegularPrice.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public function getValue()
2929
if ($this->value === null) {
3030
$price = $this->product->getPrice();
3131
$priceInCurrentCurrency = $this->priceCurrency->convertAndRound($price);
32-
$this->value = $priceInCurrentCurrency ? floatval($priceInCurrentCurrency) : 0;
32+
$this->value = $priceInCurrentCurrency ? (float)$priceInCurrentCurrency : 0;
3333
}
3434
return $this->value;
3535
}

app/code/Magento/Catalog/Pricing/Price/TierPrice.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ public function __construct(
8080
GroupManagementInterface $groupManagement,
8181
CustomerGroupRetrieverInterface $customerGroupRetriever = null
8282
) {
83-
$quantity = floatval($quantity) ? $quantity : 1;
83+
$quantity = (float)$quantity ? $quantity : 1;
8484
parent::__construct($saleableItem, $quantity, $calculator, $priceCurrency);
8585
$this->customerSession = $customerSession;
8686
$this->groupManagement = $groupManagement;

app/code/Magento/Catalog/Test/Unit/Model/Layer/Filter/DataProvider/PriceTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ public function testGetMaxPrice()
152152
$this->productCollection->expects($this->once())
153153
->method('getMaxPrice')
154154
->will($this->returnValue($maxPrice));
155-
$this->assertSame(floatval($maxPrice), $this->target->getMaxPrice());
155+
$this->assertSame((float)$maxPrice, $this->target->getMaxPrice());
156156
}
157157

158158
/**

app/code/Magento/CatalogInventory/Model/Stock/Item.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ public function getStockStatusChangedAuto()
206206
*/
207207
public function getQty()
208208
{
209-
return null === $this->_getData(static::QTY) ? null : floatval($this->_getData(static::QTY));
209+
return null === $this->_getData(static::QTY) ? null : (float)$this->_getData(static::QTY);
210210
}
211211

212212
/**

app/code/Magento/CatalogRule/Pricing/Price/CatalogRulePrice.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ public function getValue()
8989
{
9090
if (null === $this->value) {
9191
if ($this->product->hasData(self::PRICE_CODE)) {
92-
$this->value = floatval($this->product->getData(self::PRICE_CODE)) ?: false;
92+
$this->value = (float)$this->product->getData(self::PRICE_CODE) ?: false;
9393
} else {
9494
$this->value = $this->getRuleResource()
9595
->getRulePrice(
@@ -98,7 +98,7 @@ public function getValue()
9898
$this->customerSession->getCustomerGroupId(),
9999
$this->product->getId()
100100
);
101-
$this->value = $this->value ? floatval($this->value) : false;
101+
$this->value = $this->value ? (float)$this->value : false;
102102
}
103103
if ($this->value) {
104104
$this->value = $this->priceCurrency->convertAndRound($this->value);

0 commit comments

Comments
 (0)