Skip to content

Commit aea718b

Browse files
author
Stanislav Idolov
authored
ENGCOM-3250: Replace intval() function by using direct type casting to (int) #18764
2 parents d15defc + 4161400 commit aea718b

File tree

10 files changed

+28
-28
lines changed

10 files changed

+28
-28
lines changed

dev/tests/api-functional/testsuite/Magento/Quote/Api/CartTotalRepositoryTest.php

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -162,22 +162,22 @@ protected function getQuoteItemTotalsData(\Magento\Quote\Model\Quote $quote)
162162
$item = array_shift($items);
163163
return [
164164
ItemTotals::KEY_ITEM_ID => $item->getItemId(),
165-
ItemTotals::KEY_PRICE => intval($item->getPrice()),
166-
ItemTotals::KEY_BASE_PRICE => intval($item->getBasePrice()),
165+
ItemTotals::KEY_PRICE => (int)$item->getPrice(),
166+
ItemTotals::KEY_BASE_PRICE => (int)$item->getBasePrice(),
167167
ItemTotals::KEY_QTY => $item->getQty(),
168-
ItemTotals::KEY_ROW_TOTAL => intval($item->getRowTotal()),
169-
ItemTotals::KEY_BASE_ROW_TOTAL => intval($item->getBaseRowTotal()),
170-
ItemTotals::KEY_ROW_TOTAL_WITH_DISCOUNT => intval($item->getRowTotalWithDiscount()),
171-
ItemTotals::KEY_TAX_AMOUNT => intval($item->getTaxAmount()),
172-
ItemTotals::KEY_BASE_TAX_AMOUNT => intval($item->getBaseTaxAmount()),
173-
ItemTotals::KEY_TAX_PERCENT => intval($item->getTaxPercent()),
174-
ItemTotals::KEY_DISCOUNT_AMOUNT => intval($item->getDiscountAmount()),
175-
ItemTotals::KEY_BASE_DISCOUNT_AMOUNT => intval($item->getBaseDiscountAmount()),
176-
ItemTotals::KEY_DISCOUNT_PERCENT => intval($item->getDiscountPercent()),
177-
ItemTotals::KEY_PRICE_INCL_TAX => intval($item->getPriceInclTax()),
178-
ItemTotals::KEY_BASE_PRICE_INCL_TAX => intval($item->getBasePriceInclTax()),
179-
ItemTotals::KEY_ROW_TOTAL_INCL_TAX => intval($item->getRowTotalInclTax()),
180-
ItemTotals::KEY_BASE_ROW_TOTAL_INCL_TAX => intval($item->getBaseRowTotalInclTax()),
168+
ItemTotals::KEY_ROW_TOTAL => (int)$item->getRowTotal(),
169+
ItemTotals::KEY_BASE_ROW_TOTAL => (int)$item->getBaseRowTotal(),
170+
ItemTotals::KEY_ROW_TOTAL_WITH_DISCOUNT => (int)$item->getRowTotalWithDiscount(),
171+
ItemTotals::KEY_TAX_AMOUNT => (int)$item->getTaxAmount(),
172+
ItemTotals::KEY_BASE_TAX_AMOUNT => (int)$item->getBaseTaxAmount(),
173+
ItemTotals::KEY_TAX_PERCENT => (int)$item->getTaxPercent(),
174+
ItemTotals::KEY_DISCOUNT_AMOUNT => (int)$item->getDiscountAmount(),
175+
ItemTotals::KEY_BASE_DISCOUNT_AMOUNT => (int)$item->getBaseDiscountAmount(),
176+
ItemTotals::KEY_DISCOUNT_PERCENT => (int)$item->getDiscountPercent(),
177+
ItemTotals::KEY_PRICE_INCL_TAX => (int)$item->getPriceInclTax(),
178+
ItemTotals::KEY_BASE_PRICE_INCL_TAX => (int)$item->getBasePriceInclTax(),
179+
ItemTotals::KEY_ROW_TOTAL_INCL_TAX => (int)$item->getRowTotalInclTax(),
180+
ItemTotals::KEY_BASE_ROW_TOTAL_INCL_TAX => (int)$item->getBaseRowTotalInclTax(),
181181
ItemTotals::KEY_WEEE_TAX_APPLIED_AMOUNT => $item->getWeeeTaxAppliedAmount(),
182182
ItemTotals::KEY_WEEE_TAX_APPLIED => $item->getWeeeTaxApplied(),
183183
ItemTotals::KEY_NAME => $item->getName(),

dev/tests/functional/lib/Magento/Mtf/Util/Generate/Fixture/SchemaXml.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ protected function generateFixtureXml(array $config)
145145
foreach ($fields as $fieldName => $fieldValue) {
146146
$field = $this->dom->createElement('field');
147147
$field->setAttribute('name', $fieldName);
148-
$field->setAttribute('is_required', intval($fieldValue['is_required']));
148+
$field->setAttribute('is_required', (int)$fieldValue['is_required']);
149149
$fixture->appendChild($field);
150150
}
151151

dev/tests/functional/tests/app/Magento/Catalog/Test/Constraint/AssertProductDuplicateForm.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ function (&$item, $key, $formattingOptions) {
116116
protected function prepareUrlKey($urlKey)
117117
{
118118
preg_match("~\d+$~", $urlKey, $matches);
119-
$key = intval($matches[0]) + 1;
119+
$key = (int)$matches[0] + 1;
120120
return str_replace($matches[0], $key, $urlKey);
121121
}
122122

dev/tests/functional/tests/app/Magento/Catalog/Test/Handler/CatalogProductSimple/Curl.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -411,7 +411,7 @@ protected function prepareQuantityAndStockStatus()
411411
: ['is_in_stock' => 'In Stock'];
412412

413413
if (!isset($quantityAndStockStatus['is_in_stock'])) {
414-
$qty = isset($quantityAndStockStatus['qty']) ? intval($quantityAndStockStatus['qty']) : null;
414+
$qty = isset($quantityAndStockStatus['qty']) ? (int)$quantityAndStockStatus['qty'] : null;
415415
$quantityAndStockStatus['is_in_stock'] = 0 === $qty ? 'Out of Stock' : 'In Stock';
416416
}
417417

dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Constraint/AssertConfigurableProductDuplicateForm.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ protected function prepareFixtureData(array $data, array $sortFields = [])
7070
protected function prepareUrlKey($urlKey)
7171
{
7272
preg_match("~\d+$~", $urlKey, $matches);
73-
$key = intval($matches[0]) + 1;
73+
$key = (int)$matches[0] + 1;
7474
return str_replace($matches[0], $key, $urlKey);
7575
}
7676

dev/tests/functional/tests/app/Magento/Store/Test/Handler/StoreGroup/Curl.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ protected function getStoreGroupIdByGroupName($storeName)
6565
throw new \Exception('Cannot find store group id');
6666
}
6767

68-
return intval($matches[1]);
68+
return (int)$matches[1];
6969
}
7070

7171
/**

dev/tests/functional/tests/app/Magento/Store/Test/Handler/Website/Curl.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ protected function getWebSiteIdByWebsiteName($websiteName)
119119
throw new \Exception('Cannot find website id.');
120120
}
121121

122-
return intval($matches[1]);
122+
return (int)$matches[1];
123123
}
124124

125125
/**

dev/tests/integration/testsuite/Magento/Customer/Block/Adminhtml/Edit/Tab/View/PersonalInfoTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,9 +110,9 @@ public function testGetCustomer()
110110
\Magento\Customer\Api\Data\CustomerInterface::class
111111
);
112112
foreach ($expectedCustomerData as $property => $value) {
113-
$expectedValue = is_numeric($value) ? intval($value) : $value;
113+
$expectedValue = is_numeric($value) ? (int)$value : $value;
114114
$actualValue = isset($actualCustomerData[$property]) ? $actualCustomerData[$property] : null;
115-
$actualValue = is_numeric($actualValue) ? intval($actualValue) : $actualValue;
115+
$actualValue = is_numeric($actualValue) ? (int)$actualValue : $actualValue;
116116
$this->assertEquals($expectedValue, $actualValue);
117117
}
118118
}

pub/errors/processor.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -478,7 +478,7 @@ protected function _setReportData($reportData)
478478
public function saveReport($reportData)
479479
{
480480
$this->reportData = $reportData;
481-
$this->reportId = abs(intval(microtime(true) * random_int(100, 1000)));
481+
$this->reportId = abs((int)(microtime(true) * random_int(100, 1000)));
482482
$this->_reportFile = $this->_reportDir . '/' . $this->reportId;
483483
$this->_setReportData($reportData);
484484

setup/src/Magento/Setup/Model/PhpReadinessCheck.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ public function checkMemoryLimit()
192192

193193
$currentMemoryLimit = ini_get('memory_limit');
194194

195-
$currentMemoryInteger = intval($currentMemoryLimit);
195+
$currentMemoryInteger = (int)$currentMemoryLimit;
196196

197197
if ($currentMemoryInteger > 0
198198
&& $this->dataSize->convertSizeToBytes($currentMemoryLimit)
@@ -244,7 +244,7 @@ private function checkXDebugNestedLevel()
244244

245245
$currentExtensions = $this->phpInformation->getCurrent();
246246
if (in_array('xdebug', $currentExtensions)) {
247-
$currentXDebugNestingLevel = intval(ini_get('xdebug.max_nesting_level'));
247+
$currentXDebugNestingLevel = (int)ini_get('xdebug.max_nesting_level');
248248
$minimumRequiredXDebugNestedLevel = $this->phpInformation->getRequiredMinimumXDebugNestedLevel();
249249

250250
if ($minimumRequiredXDebugNestedLevel > $currentXDebugNestingLevel) {
@@ -286,7 +286,7 @@ private function checkPopulateRawPostSetting()
286286

287287
$data = [];
288288
$error = false;
289-
$iniSetting = intval(ini_get('always_populate_raw_post_data'));
289+
$iniSetting = (int)ini_get('always_populate_raw_post_data');
290290

291291
$checkVersionConstraint = $this->versionParser->parseConstraints('~5.6.0');
292292
$normalizedPhpVersion = $this->getNormalizedCurrentPhpVersion(PHP_VERSION);
@@ -302,7 +302,7 @@ private function checkPopulateRawPostSetting()
302302
Please open your php.ini file and set always_populate_raw_post_data to -1.
303303
If you need more help please call your hosting provider.',
304304
PHP_VERSION,
305-
intval(ini_get('always_populate_raw_post_data'))
305+
(int)ini_get('always_populate_raw_post_data')
306306
);
307307

308308
$data['always_populate_raw_post_data'] = [

0 commit comments

Comments
 (0)