Skip to content

Commit 0a832c1

Browse files
authored
Changed sizeof to count (#972)
- 3k occurrences of "count" and 119 of "sizeof" - simplified "count(x) > 0" - simplified "count(x) == 0" - strict type compare to int
1 parent 6bd982b commit 0a832c1

File tree

63 files changed

+91
-93
lines changed

Some content is hidden

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

63 files changed

+91
-93
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ private function _updateRoleUsersAcl(Mage_Admin_Model_Roles $role)
169169
$users = $this->getRoleUsers($role);
170170
$rowsCount = 0;
171171

172-
if (sizeof($users) > 0) {
172+
if (count($users)) {
173173
$bind = array('reload_acl_flag' => 1);
174174
$where = array('user_id IN(?)' => $users);
175175
$rowsCount = $write->update($this->_usersTable, $bind, $where);

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,7 @@ public function add(Mage_Core_Model_Abstract $user)
327327
$dbh = $this->_getWriteAdapter();
328328

329329
$aRoles = $this->hasAssigned2Role($user);
330-
if (sizeof($aRoles) > 0) {
330+
if (count($aRoles)) {
331331
foreach ($aRoles as $idx => $data) {
332332
$conditions = array(
333333
'role_id = ?' => $data['role_id'],

app/code/core/Mage/Adminhtml/Block/Api/Role/Grid/User.php

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -53,14 +53,12 @@ protected function _addColumnFilterToCollection($column)
5353
}
5454
if ($column->getFilter()->getValue()) {
5555
$this->getCollection()->addFieldToFilter('user_id', array('in'=>$inRoleIds));
56-
}
57-
else {
58-
if($inRoleIds) {
56+
} else {
57+
if ($inRoleIds) {
5958
$this->getCollection()->addFieldToFilter('user_id', array('nin'=>$inRoleIds));
6059
}
6160
}
62-
}
63-
else {
61+
} else {
6462
parent::_addColumnFilterToCollection($column);
6563
}
6664
return $this;
@@ -154,29 +152,29 @@ public function getGridUrl()
154152
return $this->getUrl('*/*/editrolegrid', array('rid' => $roleId));
155153
}
156154

157-
protected function _getUsers($json=false)
155+
protected function _getUsers($json = false)
158156
{
159-
if ( $this->getRequest()->getParam('in_role_user') != "" ) {
157+
if ($this->getRequest()->getParam('in_role_user') != "") {
160158
return (int)$this->getRequest()->getParam('in_role_user');
161159
}
162160
$roleId = ( $this->getRequest()->getParam('rid') > 0 ) ? $this->getRequest()->getParam('rid') : Mage::registry('RID');
163161
$users = Mage::getModel('api/roles')->setId($roleId)->getRoleUsers();
164-
if (sizeof($users) > 0) {
165-
if ( $json ) {
166-
$jsonUsers = Array();
167-
foreach($users as $usrid) $jsonUsers[$usrid] = 0;
162+
if (count($users)) {
163+
if ($json) {
164+
$jsonUsers = array();
165+
foreach ($users as $usrid) {
166+
$jsonUsers[$usrid] = 0;
167+
}
168168
return Mage::helper('core')->jsonEncode((object)$jsonUsers);
169169
} else {
170170
return array_values($users);
171171
}
172172
} else {
173-
if ( $json ) {
173+
if ($json) {
174174
return '{}';
175175
} else {
176176
return array();
177177
}
178178
}
179179
}
180-
181180
}
182-

app/code/core/Mage/Adminhtml/Block/Dashboard/Graph.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@ public function getChartUrl($directUrl = true)
276276

277277
// process each string in the array, and find the max length
278278
foreach ($this->getAllSeries() as $index => $serie) {
279-
$localmaxlength[$index] = sizeof($serie);
279+
$localmaxlength[$index] = count($serie);
280280
$localmaxvalue[$index] = max($serie);
281281
$localminvalue[$index] = min($serie);
282282
}
@@ -318,7 +318,7 @@ public function getChartUrl($directUrl = true)
318318

319319
foreach ($this->getAllSeries() as $index => $serie) {
320320
$thisdataarray = $serie;
321-
for ($j = 0; $j < sizeof($thisdataarray); $j++) {
321+
for ($j = 0; $j < count($thisdataarray); $j++) {
322322
$currentvalue = $thisdataarray[$j];
323323
if (is_numeric($currentvalue)) {
324324
$ylocation = $yorigin + $currentvalue;
@@ -341,7 +341,7 @@ public function getChartUrl($directUrl = true)
341341
$valueBuffer = array();
342342
$rangeBuffer = "";
343343

344-
if (sizeof($this->_axisLabels) > 0) {
344+
if (count($this->_axisLabels)) {
345345
$params['chxt'] = implode(',', array_keys($this->_axisLabels));
346346
$indexid = 0;
347347
foreach ($this->_axisLabels as $idx=>$labels){
@@ -380,15 +380,15 @@ public function getChartUrl($directUrl = true)
380380
$tmpstring = implode('|', $this->_axisLabels[$idx]);
381381

382382
$valueBuffer[] = $indexid . ":|" . $tmpstring;
383-
if (sizeof($this->_axisLabels[$idx]) > 1) {
384-
$deltaX = 100/(sizeof($this->_axisLabels[$idx])-1);
383+
if (count($this->_axisLabels[$idx]) > 1) {
384+
$deltaX = 100/(count($this->_axisLabels[$idx])-1);
385385
} else {
386386
$deltaX = 100;
387387
}
388388
} else if ($idx == 'y') {
389389
$valueBuffer[] = $indexid . ":|" . implode('|', $yLabels);
390-
if (sizeof($yLabels)-1) {
391-
$deltaY = 100/(sizeof($yLabels)-1);
390+
if (count($yLabels)-1) {
391+
$deltaY = 100/(count($yLabels)-1);
392392
} else {
393393
$deltaY = 100;
394394
}

app/code/core/Mage/Adminhtml/Block/Permissions/Role/Grid/User.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ protected function _getUsers($json=false)
161161
}
162162
$roleId = ( $this->getRequest()->getParam('rid') > 0 ) ? $this->getRequest()->getParam('rid') : Mage::registry('RID');
163163
$users = Mage::getModel('admin/roles')->setId($roleId)->getRoleUsers();
164-
if (sizeof($users) > 0) {
164+
if (count($users)) {
165165
if ( $json ) {
166166
$jsonUsers = Array();
167167
foreach($users as $usrid) $jsonUsers[$usrid] = 0;

app/code/core/Mage/Adminhtml/Block/Report/Grid.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ protected function _prepareCollection()
128128
$this->_setFilterValues($data);
129129
} else if ($filter && is_array($filter)) {
130130
$this->_setFilterValues($filter);
131-
} else if(0 !== sizeof($this->_defaultFilter)) {
131+
} else if(count($this->_defaultFilter)) {
132132
$this->_setFilterValues($this->_defaultFilter);
133133
}
134134
/** @var $collection Mage_Reports_Model_Resource_Report_Collection */

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
@@ -68,7 +68,7 @@ public function getItems()
6868
}
6969
}
7070

71-
if(sizeof($items)) {
71+
if(count($items)) {
7272
return $items;
7373
}
7474

app/code/core/Mage/Adminhtml/Block/System/Currency/Rate/Matrix.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ protected function _prepareRates($array)
8484
foreach ($array as $key => $rate) {
8585
foreach ($rate as $code => $value) {
8686
$parts = explode('.', $value);
87-
if( sizeof($parts) == 2 ) {
87+
if( count($parts) === 2 ) {
8888
$parts[1] = str_pad(rtrim($parts[1], 0), 4, '0', STR_PAD_RIGHT);
8989
$array[$key][$code] = join('.', $parts);
9090
} elseif( $value > 0 ) {

app/code/core/Mage/Adminhtml/Block/Widget/Grid.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -536,7 +536,7 @@ protected function _prepareCollection()
536536
else if ($filter && is_array($filter)) {
537537
$this->_setFilterValues($filter);
538538
}
539-
else if(0 !== sizeof($this->_defaultFilter)) {
539+
else if(count($this->_defaultFilter)) {
540540
$this->_setFilterValues($this->_defaultFilter);
541541
}
542542

app/code/core/Mage/Adminhtml/Block/Widget/Grid/Column/Renderer/Action.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ public function render(Varien_Object $row)
4848
return '&nbsp;';
4949
}
5050

51-
if(sizeof($actions)==1 && !$this->getColumn()->getNoLink()) {
51+
if(count($actions) === 1 && !$this->getColumn()->getNoLink()) {
5252
foreach ($actions as $action) {
5353
if ( is_array($action) ) {
5454
return $this->_toLinkHtml($action, $row);

0 commit comments

Comments
 (0)