Skip to content

Commit 63fe741

Browse files
authored
rector: FunctionFirstClassCallableRector (OpenMage#5037)
* rector: `FunctionFirstClassCallableRector` - https://getrector.com/rule-detail/function-first-class-callable-rector * fix * updated PhpStan baseline * cs
1 parent e50977a commit 63fe741

File tree

34 files changed

+61
-69
lines changed

34 files changed

+61
-69
lines changed

.phpstan.dist.baseline.neon

Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -690,20 +690,14 @@ parameters:
690690
count: 1
691691
path: app/code/core/Mage/Adminhtml/controllers/Sales/Order/ShipmentController.php
692692

693-
-
694-
rawMessage: 'Parameter #1 $order of method Mage_Sales_Model_Resource_Order_Collection_Abstract::setOrderFilter() expects int|Mage_Sales_Model_Order, array<string, mixed> given.'
695-
identifier: argument.type
696-
count: 1
697-
path: app/code/core/Mage/Adminhtml/controllers/Sales/Order/ShipmentController.php
698-
699693
-
700694
rawMessage: 'Parameter #1 $prefix of function uniqid expects string, int<0, max> given.'
701695
identifier: argument.type
702696
count: 1
703697
path: app/code/core/Mage/Adminhtml/controllers/Sales/Order/ShipmentController.php
704698

705699
-
706-
rawMessage: 'Parameter #2 $callback of function array_filter expects (callable(mixed): bool)|null, ''\\intval'' given.'
700+
rawMessage: 'Parameter #2 $callback of function array_filter expects (callable(mixed): bool)|null, Closure(array|bool|float|int|resource|string|null, int=): int given.'
707701
identifier: argument.type
708702
count: 2
709703
path: app/code/core/Mage/Adminhtml/controllers/Sales/Order/ShipmentController.php
@@ -1225,7 +1219,7 @@ parameters:
12251219
path: app/code/core/Mage/Bundle/Model/Product/Type.php
12261220

12271221
-
1228-
rawMessage: 'Parameter #2 $callback of function array_filter expects (callable(mixed): bool)|null, ''\\intval'' given.'
1222+
rawMessage: 'Parameter #2 $callback of function array_filter expects (callable(mixed): bool)|null, Closure(array|bool|float|int|resource|string|null, int=): int given.'
12291223
identifier: argument.type
12301224
count: 3
12311225
path: app/code/core/Mage/Bundle/Model/Product/Type.php
@@ -1729,7 +1723,7 @@ parameters:
17291723
path: app/code/core/Mage/Catalog/Model/Product/Type/Configurable.php
17301724

17311725
-
1732-
rawMessage: 'Parameter #2 $callback of function array_filter expects (callable(mixed): bool)|null, ''\\intval'' given.'
1726+
rawMessage: 'Parameter #2 $callback of function array_filter expects (callable(mixed): bool)|null, Closure(array|bool|float|int|resource|string|null, int=): int given.'
17331727
identifier: argument.type
17341728
count: 1
17351729
path: app/code/core/Mage/Catalog/Model/Product/Type/Configurable.php
@@ -1747,7 +1741,7 @@ parameters:
17471741
path: app/code/core/Mage/Catalog/Model/Product/Type/Grouped.php
17481742

17491743
-
1750-
rawMessage: 'Parameter #2 $callback of function array_filter expects (callable(mixed): bool)|null, ''\\intval'' given.'
1744+
rawMessage: 'Parameter #2 $callback of function array_filter expects (callable(mixed): bool)|null, Closure(array|bool|float|int|resource|string|null, int=): int given.'
17511745
identifier: argument.type
17521746
count: 1
17531747
path: app/code/core/Mage/Catalog/Model/Product/Type/Grouped.php
@@ -2479,7 +2473,7 @@ parameters:
24792473
path: app/code/core/Mage/Core/Controller/Varien/Router/Standard.php
24802474

24812475
-
2482-
rawMessage: 'Parameter #2 $callback of function array_filter expects (callable(string): bool)|null, ''trim'' given.'
2476+
rawMessage: 'Parameter #2 $callback of function array_filter expects (callable(string): bool)|null, Closure(string, string=): string given.'
24832477
identifier: argument.type
24842478
count: 1
24852479
path: app/code/core/Mage/Core/Helper/EnvironmentConfigLoader.php
@@ -3223,7 +3217,7 @@ parameters:
32233217
path: app/code/core/Mage/Downloadable/Model/Link/Api/V2.php
32243218

32253219
-
3226-
rawMessage: 'Parameter #2 $callback of function array_filter expects (callable(mixed): bool)|null, ''\\intval'' given.'
3220+
rawMessage: 'Parameter #2 $callback of function array_filter expects (callable(mixed): bool)|null, Closure(array|bool|float|int|resource|string|null, int=): int given.'
32273221
identifier: argument.type
32283222
count: 1
32293223
path: app/code/core/Mage/Downloadable/Model/Product/Type.php
@@ -4284,12 +4278,6 @@ parameters:
42844278
count: 1
42854279
path: app/code/core/Mage/Sales/Block/Recurring/Profiles.php
42864280

4287-
-
4288-
rawMessage: 'Parameter #1 $order of method Mage_Sales_Model_Resource_Order_Collection_Abstract::setOrderFilter() expects int|Mage_Sales_Model_Order, array given.'
4289-
identifier: argument.type
4290-
count: 1
4291-
path: app/code/core/Mage/Sales/Model/Api2/Order.php
4292-
42934281
-
42944282
rawMessage: 'Parameter #2 $code of method Mage_Api2_Model_Resource::_critical() expects int|null, string given.'
42954283
identifier: argument.type

app/code/core/Mage/Adminhtml/Controller/Action.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -429,7 +429,7 @@ protected function _checkIsForcedFormKeyAction()
429429
{
430430
return in_array(
431431
strtolower($this->getRequest()->getActionName()),
432-
array_map('strtolower', $this->_forcedFormKeyActions),
432+
array_map(strtolower(...), $this->_forcedFormKeyActions),
433433
);
434434
}
435435

app/code/core/Mage/Adminhtml/Model/System/Config/Backend/Color.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ protected function _beforeSave()
2525

2626
$validate = [];
2727
if (isset($config->validate)) {
28-
$validate = array_map('trim', explode(' ', $config->validate));
28+
$validate = array_map(trim(...), explode(' ', $config->validate));
2929
}
3030

3131
if (!(string) $this->getValue() && !in_array('required-entry', $validate)) {

app/code/core/Mage/Adminhtml/controllers/Sales/Order/ShipmentController.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -579,6 +579,8 @@ public function createLabelAction()
579579

580580
/**
581581
* Print label for one specific shipment
582+
*
583+
* @return Mage_Core_Controller_Varien_Action|void
582584
*/
583585
public function printLabelAction()
584586
{
@@ -652,7 +654,7 @@ public function massPrintShippingLabelAction()
652654
switch ($request->getParam('massaction_prepare_key')) {
653655
case 'shipment_ids':
654656
$ids = $request->getParam('shipment_ids');
655-
array_filter($ids, '\intval');
657+
$ids = array_filter($ids, \intval(...));
656658
if (!empty($ids)) {
657659
$shipments = Mage::getResourceModel('sales/order_shipment_collection')
658660
->addFieldToFilter('entity_id', ['in' => $ids]);
@@ -661,7 +663,7 @@ public function massPrintShippingLabelAction()
661663
break;
662664
case 'order_ids':
663665
$ids = $request->getParam('order_ids');
664-
array_filter($ids, '\intval');
666+
$ids = array_filter($ids, \intval(...));
665667
if (!empty($ids)) {
666668
$shipments = Mage::getResourceModel('sales/order_shipment_collection')
667669
->setOrderFilter(['in' => $ids]);

app/code/core/Mage/Api/Model/Roles.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,8 +115,7 @@ protected function _buildResourcesArray(
115115
$level = -1;
116116
} else {
117117
$resourceName = $parentName;
118-
if ($resource->getName() != 'title' && $resource->getName() != 'sort_order'
119-
&& $resource->getName() != 'children'
118+
if (!in_array($resource->getName(), ['title', 'sort_order', 'children'])
120119
) {
121120
$resourceName = (is_null($parentName) ? '' : $parentName . '/') . $resource->getName();
122121

app/code/core/Mage/Api2/Model/Config.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -343,7 +343,7 @@ public function getVersions($node)
343343
}
344344

345345
$versions = explode(',', (string) $element);
346-
if (count(array_filter($versions, 'is_numeric')) != count($versions)) {
346+
if (count(array_filter($versions, is_numeric(...))) != count($versions)) {
347347
throw new Exception(sprintf('Invalid resource "%s" versions in config.', htmlspecialchars($node)));
348348
}
349349

app/code/core/Mage/Api2/Model/Request.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ public function getRequestedAttributes()
271271
$include = explode(',', $include);
272272
}
273273

274-
return array_map('trim', $include);
274+
return array_map(trim(...), $include);
275275
}
276276

277277
/**

app/code/core/Mage/Bundle/Model/Product/Type.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -531,7 +531,7 @@ protected function _prepareProduct(Varien_Object $buyRequest, $product, $process
531531

532532
$options = $buyRequest->getBundleOption();
533533
if (is_array($options)) {
534-
$options = array_filter($options, '\intval');
534+
$options = array_filter($options, \intval(...));
535535
$qtys = $buyRequest->getBundleOptionQty();
536536
foreach ($options as $_optionId => $_selections) {
537537
if (empty($_selections)) {
@@ -669,7 +669,7 @@ protected function _prepareProduct(Varien_Object $buyRequest, $product, $process
669669
}
670670

671671
$result[] = $_result[0]->setParentProductId($product->getId())
672-
->addCustomOption('bundle_option_ids', serialize(array_map('\intval', $optionIds)))
672+
->addCustomOption('bundle_option_ids', serialize(array_map(\intval(...), $optionIds)))
673673
->addCustomOption('bundle_selection_attributes', serialize($attributes));
674674

675675
if ($isStrictProcessMode) {
@@ -687,7 +687,7 @@ protected function _prepareProduct(Varien_Object $buyRequest, $product, $process
687687
$item->addCustomOption('bundle_identity', $uniqueKey);
688688
}
689689

690-
$product->addCustomOption('bundle_option_ids', serialize(array_map('\intval', $optionIds)));
690+
$product->addCustomOption('bundle_option_ids', serialize(array_map(\intval(...), $optionIds)));
691691
$product->addCustomOption('bundle_selection_ids', serialize($selectionIds));
692692

693693
return $result;
@@ -1008,8 +1008,8 @@ public function processBuyRequest($product, $buyRequest)
10081008
$option = $buyRequest->getBundleOption();
10091009
$optionQty = $buyRequest->getBundleOptionQty();
10101010

1011-
$option = (is_array($option)) ? array_filter($option, '\intval') : [];
1012-
$optionQty = (is_array($optionQty)) ? array_filter($optionQty, '\intval') : [];
1011+
$option = (is_array($option)) ? array_filter($option, \intval(...)) : [];
1012+
$optionQty = (is_array($optionQty)) ? array_filter($optionQty, \intval(...)) : [];
10131013

10141014
return [
10151015
'bundle_option' => $option,

app/code/core/Mage/Catalog/Model/Layer/Filter/Price.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -551,7 +551,7 @@ public function loadPrices($limit, $offset = null, $lowerPrice = null, $upperPri
551551
{
552552
$prices = $this->_getResource()->loadPrices($this, $limit, $offset, $lowerPrice, $upperPrice);
553553
if ($prices) {
554-
$prices = array_map('\floatval', $prices);
554+
$prices = array_map(\floatval(...), $prices);
555555
}
556556

557557
return $prices;
@@ -569,7 +569,7 @@ public function loadPreviousPrices($price, $index, $lowerPrice = null)
569569
{
570570
$prices = $this->_getResource()->loadPreviousPrices($this, $price, $index, $lowerPrice);
571571
if ($prices) {
572-
$prices = array_map('\floatval', $prices);
572+
$prices = array_map(\floatval(...), $prices);
573573
}
574574

575575
return $prices;
@@ -587,7 +587,7 @@ public function loadNextPrices($price, $rightIndex, $upperPrice = null)
587587
{
588588
$prices = $this->_getResource()->loadNextPrices($this, $price, $rightIndex, $upperPrice);
589589
if ($prices) {
590-
$prices = array_map('\floatval', $prices);
590+
$prices = array_map(\floatval(...), $prices);
591591
}
592592

593593
return $prices;

app/code/core/Mage/Catalog/Model/Product.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -594,7 +594,7 @@ public function setCategoryIds($ids)
594594
Mage::throwException(Mage::helper('catalog')->__('Invalid category IDs.'));
595595
}
596596

597-
$ids = array_filter(array_map('\intval', $ids));
597+
$ids = array_filter(array_map(\intval(...), $ids));
598598
$this->setData('category_ids', $ids);
599599
return $this;
600600
}

0 commit comments

Comments
 (0)