Skip to content

Commit b47b440

Browse files
authored
rector: CountArrayToEmptyArrayComparisonRector (OpenMage#4998)
* rector: `CountArrayToEmptyArrayComparisonRector` * phpStan
1 parent 1aa898b commit b47b440

File tree

54 files changed

+71
-68
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+71
-68
lines changed

.phpstan.dist.baseline.neon

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4902,6 +4902,12 @@ parameters:
49024902
count: 1
49034903
path: app/code/core/Mage/Tax/Model/Resource/Calculation/Rate/Title/Collection.php
49044904

4905+
-
4906+
rawMessage: 'Strict comparison using === between non-empty-list and array{} will always evaluate to false.'
4907+
identifier: identical.alwaysFalse
4908+
count: 1
4909+
path: app/code/core/Mage/Tax/Model/Resource/Setup.php
4910+
49054911
-
49064912
rawMessage: 'Parameter #2 $rate of method Mage_Tax_Model_Sales_Total_Quote_Shipping::_round() expects string, float given.'
49074913
identifier: argument.type

.rector.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,6 @@
7979
CodingStyle\Encapsed\EncapsedStringsToSprintfRector::class, # todo: TMP
8080
CodingStyle\Encapsed\WrapEncapsedVariableInCurlyBracesRector::class, # todo: TMP
8181
CodingStyle\FuncCall\CallUserFuncArrayToVariadicRector::class, # todo: TMP
82-
CodingStyle\FuncCall\CountArrayToEmptyArrayComparisonRector::class, # todo: TMP
8382
CodingStyle\FuncCall\StrictArraySearchRector::class, # todo: TMP
8483
CodingStyle\If_\NullableCompareToNullRector::class, # todo: TMP
8584
CodingStyle\PostInc\PostIncDecToPreIncDecRector::class, # todo: TMP

app/code/core/Mage/Admin/Model/Resource/Block.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ protected function _generateCache()
5757
$collection->addFieldToFilter('is_allowed', ['eq' => 1]);
5858

5959
$disallowedBlockNames = $this->getDisallowedBlockNames();
60-
if (is_array($disallowedBlockNames) && count($disallowedBlockNames) > 0) {
60+
if (is_array($disallowedBlockNames) && $disallowedBlockNames !== []) {
6161
$collection->addFieldToFilter('block_name', ['nin' => $disallowedBlockNames]);
6262
}
6363

app/code/core/Mage/Admin/Model/User.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ public function deleteFromRole()
259259
public function roleUserExists()
260260
{
261261
$result = $this->_getResource()->roleUserExists($this);
262-
return is_array($result) && count($result) > 0;
262+
return is_array($result) && $result !== [];
263263
}
264264

265265
/**
@@ -281,7 +281,7 @@ public function add()
281281
public function userExists()
282282
{
283283
$result = $this->_getResource()->userExists($this);
284-
return is_array($result) && count($result) > 0;
284+
return is_array($result) && $result !== [];
285285
}
286286

287287
/**

app/code/core/Mage/Adminhtml/Block/Sales/Order/Create/Billing/Method/Form.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ public function hasSsCardType()
8080
{
8181
$availableTypes = explode(',', $this->getQuote()->getPayment()->getMethod()->getConfigData('cctypes'));
8282
$ssPresenations = array_intersect(['SS', 'SM', 'SO'], $availableTypes);
83-
if ($availableTypes && count($ssPresenations) > 0) {
83+
if ($availableTypes && $ssPresenations !== []) {
8484
return true;
8585
}
8686

app/code/core/Mage/Adminhtml/Block/Sales/Order/Create/Giftmessage.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ public function getItems()
5555
}
5656
}
5757

58-
if (count($items)) {
58+
if ($items !== []) {
5959
return $items;
6060
}
6161

app/code/core/Mage/Adminhtml/controllers/Newsletter/ProblemController.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public function gridAction()
4949
{
5050
if ($this->getRequest()->getParam('_unsubscribe')) {
5151
$problems = (array) $this->getRequest()->getParam('problem', []);
52-
if (count($problems) > 0) {
52+
if ($problems !== []) {
5353
$collection = Mage::getResourceModel('newsletter/problem_collection');
5454
$collection
5555
->addSubscriberInfo()
@@ -68,7 +68,7 @@ public function gridAction()
6868

6969
if ($this->getRequest()->getParam('_delete')) {
7070
$problems = (array) $this->getRequest()->getParam('problem', []);
71-
if (count($problems) > 0) {
71+
if ($problems !== []) {
7272
$collection = Mage::getResourceModel('newsletter/problem_collection');
7373
$collection
7474
->addFieldToFilter(

app/code/core/Mage/Adminhtml/controllers/Tax/RuleController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ protected function _isValidRuleRequest($ruleModel)
149149
$existingRules = array_diff($existingRules, [$ruleModel->getOrigData('code')]);
150150

151151
//Verify if a Rule already exists. If not throw an error
152-
if (count($existingRules) > 0) {
152+
if ($existingRules !== []) {
153153
$ruleCodes = implode(',', $existingRules);
154154
$session->addError(
155155
$this->_getHelperModel('tax')->__('Rules (%s) already exist for the specified Tax Rate, Customer Tax Class and Product Tax Class combinations', $ruleCodes),

app/code/core/Mage/Api/Helper/Data.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ public function associativeArrayUnpack(&$mixed)
130130
}
131131
}
132132

133-
if (count($tmpArr)) {
133+
if ($tmpArr !== []) {
134134
$mixed = $tmpArr;
135135
}
136136
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ public function deleteFromRole()
156156
public function roleUserExists()
157157
{
158158
$result = $this->_getResource()->roleUserExists($this);
159-
return is_array($result) && count($result) > 0;
159+
return is_array($result) && $result !== [];
160160
}
161161

162162
/**
@@ -178,7 +178,7 @@ public function add()
178178
public function userExists()
179179
{
180180
$result = $this->_getResource()->userExists($this);
181-
return is_array($result) && count($result) > 0;
181+
return is_array($result) && $result !== [];
182182
}
183183

184184
/**

0 commit comments

Comments
 (0)