Skip to content

Commit adf3917

Browse files
ENGCOM-2970: Replace floatval() function by using direct type casting to (float) #18020
- Merge Pull Request #18020 from mage2pratik/magento2:forwardport-patch-16848 - Merged commits: 1. fd0e8b3
2 parents ac3ae89 + fd0e8b3 commit adf3917

File tree

9 files changed

+12
-12
lines changed

9 files changed

+12
-12
lines changed

dev/tests/functional/lib/Magento/Mtf/Constraint/AbstractAssertForm.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ protected function verifyData(array $fixtureData, array $formData, $isStrict = f
5353
}
5454
$formValue = isset($formData[$key]) ? $formData[$key] : null;
5555
if (is_numeric($formValue)) {
56-
$formValue = floatval($formValue);
56+
$formValue = (float)$formValue;
5757
}
5858

5959
if (null === $formValue) {

dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Product/View/CustomOptions.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ protected function getFieldData(SimpleElement $option)
231231
return [
232232
'options' => [
233233
[
234-
'price' => floatval($price),
234+
'price' => (float)$price,
235235
'max_characters' => $maxCharacters,
236236
],
237237
]
@@ -262,7 +262,7 @@ protected function getFileData(SimpleElement $option)
262262
return [
263263
'options' => [
264264
[
265-
'price' => floatval($price),
265+
'price' => (float)$price,
266266
'file_extension' => $this->getOptionNotice($option, 1),
267267
'image_size_x' => preg_replace('/[^0-9]/', '', $this->getOptionNotice($option, 2)),
268268
'image_size_y' => preg_replace('/[^0-9]/', '', $this->getOptionNotice($option, 3)),
@@ -344,7 +344,7 @@ protected function getDateData(SimpleElement $option)
344344
return [
345345
'options' => [
346346
[
347-
'price' => floatval($price),
347+
'price' => (float)$price,
348348
],
349349
]
350350
];

dev/tests/functional/tests/app/Magento/CatalogRule/Test/Constraint/AssertCatalogPriceRuleForm.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,10 @@ public function processAssert(
4242
$fixtureData = $catalogPriceRule->getData();
4343
//convert discount_amount to float to compare
4444
if (isset($formData['discount_amount'])) {
45-
$formData['discount_amount'] = floatval($formData['discount_amount']);
45+
$formData['discount_amount'] = (float)$formData['discount_amount'];
4646
}
4747
if (isset($fixtureData['discount_amount'])) {
48-
$fixtureData['discount_amount'] = floatval($fixtureData['discount_amount']);
48+
$fixtureData['discount_amount'] = (float)$fixtureData['discount_amount'];
4949
}
5050
$diff = $this->verifyData($formData, $fixtureData);
5151
\PHPUnit\Framework\Assert::assertTrue(

dev/tests/functional/tests/app/Magento/Downloadable/Test/Handler/DownloadableProduct/Webapi.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ protected function prepareLinkData(array $link)
148148
'title' => $link['title'],
149149
'sort_order' => isset($link['sort_order']) ? $link['sort_order'] : 0,
150150
'is_shareable' => $link['is_shareable'],
151-
'price' => floatval($link['price']),
151+
'price' => (float)$link['price'],
152152
'number_of_downloads' => isset($link['number_of_downloads']) ? $link['number_of_downloads'] : 0,
153153
'link_type' => $link['type'],
154154
'link_url' => isset($link['link_url']) ? $link['link_url'] : null,

dev/tests/functional/tests/app/Magento/Reports/Test/Constraint/AssertSalesReportIntervalResult.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ protected function prepareSalesResult($salesResult)
5252
{
5353
$data = [];
5454
foreach ($salesResult as $key => $result) {
55-
$data[$key] = floatval($result);
55+
$data[$key] = (float)$result;
5656
}
5757

5858
return $data;

dev/tests/functional/tests/app/Magento/Reports/Test/Constraint/AssertSalesReportTotalResult.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ protected function prepareSalesResult($salesResult)
5252
{
5353
$data = [];
5454
foreach ($salesResult as $key => $result) {
55-
$data[$key] = floatval($result);
55+
$data[$key] = (float)$result;
5656
}
5757

5858
return $data;

dev/tests/integration/testsuite/Magento/Catalog/Model/ProductTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -582,7 +582,7 @@ public function testGetOptions()
582582
];
583583
foreach ($options as $option) {
584584
foreach ($option->getValues() as $value) {
585-
$this->assertEquals($expectedValue[$value->getSku()], floatval($value->getPrice()));
585+
$this->assertEquals($expectedValue[$value->getSku()], (float)$value->getPrice());
586586
}
587587
}
588588
}

lib/internal/Magento/Framework/Filter/Template/Tokenizer/Variable.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,6 @@ public function getNumber()
313313
if (!$this->isNumeric()) {
314314
$this->prev();
315315
}
316-
return floatval($value);
316+
return (float)$value;
317317
}
318318
}

lib/internal/Magento/Framework/Setup/Declaration/Schema/Dto/Factories/Real.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ public function create(array $data)
6363
}
6464

6565
if (isset($data['default'])) {
66-
$data['default'] = floatval($data['default']);
66+
$data['default'] = (float)$data['default'];
6767
}
6868

6969
return $this->objectManager->create($this->className, $data);

0 commit comments

Comments
 (0)