Skip to content

Commit d9b7615

Browse files
author
Stanislav Idolov
authored
ENGCOM-3019: Replace intval() function by using direct type casting to (int) where no default value is needed #18142
2 parents 8fd89cf + 8d722a1 commit d9b7615

File tree

20 files changed

+34
-34
lines changed

20 files changed

+34
-34
lines changed

lib/internal/Magento/Framework/DB/Adapter/Pdo/Mysql.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3857,13 +3857,13 @@ protected function _parseTextSize($size)
38573857

38583858
switch ($last) {
38593859
case 'k':
3860-
$size = intval($size) * 1024;
3860+
$size = (int)$size * 1024;
38613861
break;
38623862
case 'm':
3863-
$size = intval($size) * 1024 * 1024;
3863+
$size = (int)$size * 1024 * 1024;
38643864
break;
38653865
case 'g':
3866-
$size = intval($size) * 1024 * 1024 * 1024;
3866+
$size = (int)$size * 1024 * 1024 * 1024;
38673867
break;
38683868
}
38693869

@@ -3874,7 +3874,7 @@ protected function _parseTextSize($size)
38743874
return Table::MAX_TEXT_SIZE;
38753875
}
38763876

3877-
return intval($size);
3877+
return (int)$size;
38783878
}
38793879

38803880
/**

lib/internal/Magento/Framework/DB/Helper.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,12 +153,12 @@ protected function _prepareHaving(\Magento\Framework\DB\Select $select, $autoRes
153153
protected function _assembleLimit($query, $limitCount, $limitOffset, $columnList = [])
154154
{
155155
if ($limitCount !== null) {
156-
$limitCount = intval($limitCount);
156+
$limitCount = (int)$limitCount;
157157
if ($limitCount <= 0) {
158158
//throw new \Exception("LIMIT argument count={$limitCount} is not valid");
159159
}
160160

161-
$limitOffset = intval($limitOffset);
161+
$limitOffset = (int)$limitOffset;
162162
if ($limitOffset < 0) {
163163
//throw new \Exception("LIMIT argument offset={$limitOffset} is not valid");
164164
}

lib/internal/Magento/Framework/DB/Query.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ public function getSize()
142142
$sql = $this->getSelectCountSql();
143143
$this->totalRecords = $this->getConnection()->fetchOne($sql, $this->bindParams);
144144
}
145-
return intval($this->totalRecords);
145+
return (int)$this->totalRecords;
146146
}
147147

148148
/**

lib/internal/Magento/Framework/DB/Query/BatchIterator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ private function calculateBatchSize(Select $select)
165165
);
166166
$row = $this->connection->fetchRow($wrapperSelect);
167167
$this->minValue = $row['max'];
168-
return intval($row['cnt']);
168+
return (int)$row['cnt'];
169169
}
170170

171171
/**

lib/internal/Magento/Framework/DB/Query/BatchRangeIterator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ private function initSelectObject()
201201
);
202202
$row = $this->connection->fetchRow($wrapperSelect);
203203

204-
$this->totalItemCount = intval($row['cnt']);
204+
$this->totalItemCount = (int)$row['cnt'];
205205
}
206206

207207
$rangeField = is_array($this->rangeField) ? $this->rangeField : [$this->rangeField];

lib/internal/Magento/Framework/DB/Sql/LimitExpression.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,14 +46,14 @@ public function __construct(
4646
public function __toString()
4747
{
4848
$sql = $this->sql;
49-
$count = intval($this->count);
49+
$count = (int)$this->count;
5050
if ($count <= 0) {
5151
/** @see Zend_Db_Adapter_Exception */
5252
#require_once 'Zend/Db/Adapter/Exception.php';
5353
throw new \Zend_Db_Adapter_Exception("LIMIT argument count=$count is not valid");
5454
}
5555

56-
$offset = intval($this->offset);
56+
$offset = (int)$this->offset;
5757
if ($offset < 0) {
5858
/** @see Zend_Db_Adapter_Exception */
5959
#require_once 'Zend/Db/Adapter/Exception.php';

lib/internal/Magento/Framework/Data/Argument/Interpreter/ArrayType.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,11 +90,11 @@ private function compareItems($firstItemKey, $secondItemKey, $indexedItems)
9090
$firstValue = 0;
9191
$secondValue = 0;
9292
if (isset($firstItem['sortOrder'])) {
93-
$firstValue = intval($firstItem['sortOrder']);
93+
$firstValue = (int)$firstItem['sortOrder'];
9494
}
9595

9696
if (isset($secondItem['sortOrder'])) {
97-
$secondValue = intval($secondItem['sortOrder']);
97+
$secondValue = (int)$secondItem['sortOrder'];
9898
}
9999

100100
if ($firstValue == $secondValue) {

lib/internal/Magento/Framework/Data/Collection.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ public function getSize()
285285
if ($this->_totalRecords === null) {
286286
$this->_totalRecords = count($this->getItems());
287287
}
288-
return intval($this->_totalRecords);
288+
return (int)$this->_totalRecords;
289289
}
290290

291291
/**

lib/internal/Magento/Framework/Exception/LocalizedException.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ class LocalizedException extends \Exception
3333
public function __construct(Phrase $phrase, \Exception $cause = null, $code = 0)
3434
{
3535
$this->phrase = $phrase;
36-
parent::__construct($phrase->render(), intval($code), $cause);
36+
parent::__construct($phrase->render(), (int)$code, $cause);
3737
}
3838

3939
/**

lib/internal/Magento/Framework/HTTP/Client/Curl.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -435,7 +435,7 @@ protected function parseHeaders($ch, $data)
435435
if (count($line) != 3) {
436436
$this->doError("Invalid response line returned from server: " . $data);
437437
}
438-
$this->_responseStatus = intval($line[1]);
438+
$this->_responseStatus = (int)$line[1];
439439
} else {
440440
$name = $value = '';
441441
$out = explode(": ", trim($data), 2);

0 commit comments

Comments
 (0)