Skip to content

[2.3] changed intval($val) to (int) $val, since (int) $val is faster. #17946

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions app/code/Magento/Backend/Block/Widget/Button/ButtonList.php
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,8 @@ public function getItems()
*/
public function sortButtons(Item $itemA, Item $itemB)
{
$sortOrderA = intval($itemA->getSortOrder());
$sortOrderB = intval($itemB->getSortOrder());
$sortOrderA = (int) $itemA->getSortOrder();
$sortOrderB = (int) $itemB->getSortOrder();

if ($sortOrderA == $sortOrderB) {
return 0;
Expand Down
2 changes: 1 addition & 1 deletion app/code/Magento/Backend/Model/Menu.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public function add(Item $item, $parentId = null, $index = null)
}
$parentItem->getChildren()->add($item, null, $index);
} else {
$index = intval($index);
$index = (int) $index;
if (!isset($this[$index])) {
$this->offsetSet($index, $item);
$this->_logger->info(
Expand Down
4 changes: 2 additions & 2 deletions app/code/Magento/Backup/Model/Config/Backend/Cron.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@ public function afterSave()

if ($enabled) {
$cronExprArray = [
intval($time[1]), # Minute
intval($time[0]), # Hour
(int) $time[1], # Minute
(int) $time[0], # Hour
$frequency == $frequencyMonthly ? '1' : '*', # Day of the Month
'*', # Month of the Year
$frequency == $frequencyWeekly ? '1' : '*', # Day of the Week
Expand Down
2 changes: 1 addition & 1 deletion app/code/Magento/Bundle/Model/Product/Type.php
Original file line number Diff line number Diff line change
Expand Up @@ -556,7 +556,7 @@ public function updateQtyOption($options, \Magento\Framework\DataObject $option,
*/
public function prepareQuoteItemQty($qty, $product)
{
return intval($qty);
return (int) $qty;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public function getFieldSuffix()
public function getStoreId()
{
$storeId = $this->getRequest()->getParam('store');
return intval($storeId);
return (int) $storeId;
}

/**
Expand Down
9 changes: 4 additions & 5 deletions app/code/Magento/Catalog/Block/Product/ProductList/Upsell.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
namespace Magento\Catalog\Block\Product\ProductList;

use Magento\Catalog\Model\ResourceModel\Product\Collection;
use Magento\Framework\View\Element\AbstractBlock;

/**
* Catalog product upsell items block
Expand Down Expand Up @@ -170,8 +169,8 @@ public function getRowCount()
*/
public function setColumnCount($columns)
{
if (intval($columns) > 0) {
$this->_columnCount = intval($columns);
if ((int) $columns > 0) {
$this->_columnCount = (int) $columns;
}
return $this;
}
Expand Down Expand Up @@ -213,8 +212,8 @@ public function getIterableItem()
*/
public function setItemLimit($type, $limit)
{
if (intval($limit) > 0) {
$this->_itemLimits[$type] = intval($limit);
if ((int) $limit > 0) {
$this->_itemLimits[$type] = (int) $limit;
}
return $this;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
namespace Magento\Catalog\Model\Indexer\Category\Flat;

use Magento\Framework\App\ResourceConnection;
use Magento\Framework\EntityManager\MetadataPool;

class AbstractAction
{
Expand Down Expand Up @@ -111,7 +110,7 @@ public function getColumns()
public function getMainStoreTable($storeId = \Magento\Store\Model\Store::DEFAULT_STORE_ID)
{
if (is_string($storeId)) {
$storeId = intval($storeId);
$storeId = (int) $storeId;
}

$suffix = sprintf('store_%d', $storeId);
Expand Down
2 changes: 1 addition & 1 deletion app/code/Magento/Catalog/Model/Product/Image.php
Original file line number Diff line number Diff line change
Expand Up @@ -494,7 +494,7 @@ public function resize()
*/
public function rotate($angle)
{
$angle = intval($angle);
$angle = (int) $angle;
$this->getImageProcessor()->rotate($angle);
return $this;
}
Expand Down