Skip to content
This repository was archived by the owner on Apr 29, 2019. It is now read-only.

Commit 78e9fbe

Browse files
author
Joan He
authored
Merge pull request #97 from magento-engcom/fix-calls-count
Fix Calls to count()
2 parents 43b0a5f + d036fc8 commit 78e9fbe

File tree

34 files changed

+236
-307
lines changed

34 files changed

+236
-307
lines changed

app/code/Magento/Backend/Block/Menu.php

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,7 @@ protected function _addSubMenu($menuItem, $level, $limit, $id = null)
352352
return $output;
353353
}
354354
$output .= '<div class="submenu"' . ($level == 0 && isset($id) ? ' aria-labelledby="' . $id . '"' : '') . '>';
355-
$colStops = null;
355+
$colStops = [];
356356
if ($level == 0 && $limit) {
357357
$colStops = $this->_columnBrake($menuItem->getChildren(), $limit);
358358
$output .= '<strong class="submenu-title">' . $this->_getAnchorLabel($menuItem) . '</strong>';
@@ -387,7 +387,11 @@ public function renderNavigation($menu, $level = 0, $limit = 0, $colBrakes = [])
387387
$itemName = substr($menuId, strrpos($menuId, '::') + 2);
388388
$itemClass = str_replace('_', '-', strtolower($itemName));
389389

390-
if (count($colBrakes) && $colBrakes[$itemPosition]['colbrake'] && $itemPosition != 1) {
390+
if (is_array($colBrakes)
391+
&& count($colBrakes)
392+
&& $colBrakes[$itemPosition]['colbrake']
393+
&& $itemPosition != 1
394+
) {
391395
$output .= '</ul></li><li class="column"><ul role="menu">';
392396
}
393397

@@ -401,7 +405,7 @@ public function renderNavigation($menu, $level = 0, $limit = 0, $colBrakes = [])
401405
$itemPosition++;
402406
}
403407

404-
if (count($colBrakes) && $limit) {
408+
if (is_array($colBrakes) && count($colBrakes) && $limit) {
405409
$output = '<li class="column"><ul role="menu">' . $output . '</ul></li>';
406410
}
407411

app/code/Magento/Backend/view/adminhtml/templates/widget/grid.phtml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
*
2020
*/
2121
/* @var $block \Magento\Backend\Block\Widget\Grid */
22-
$numColumns = sizeof($block->getColumns());
22+
$numColumns = !is_null($block->getColumns()) ? sizeof($block->getColumns()) : 0;
2323
?>
2424
<?php if ($block->getCollection()): ?>
2525

app/code/Magento/Catalog/Test/Unit/Model/ProductTest.php

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -330,9 +330,9 @@ protected function setUp()
330330

331331
$this->mediaGalleryEntryFactoryMock =
332332
$this->getMockBuilder(\Magento\Catalog\Api\Data\ProductAttributeMediaGalleryEntryInterfaceFactory::class)
333-
->setMethods(['create'])
334-
->disableOriginalConstructor()
335-
->getMock();
333+
->setMethods(['create'])
334+
->disableOriginalConstructor()
335+
->getMock();
336336

337337
$this->metadataServiceMock = $this->createMock(\Magento\Catalog\Api\ProductAttributeRepositoryInterface::class);
338338
$this->attributeValueFactory = $this->getMockBuilder(\Magento\Framework\Api\AttributeValueFactory::class)
@@ -1171,19 +1171,19 @@ public function testSetMediaGalleryEntries()
11711171
];
11721172

11731173
$entryMock = $this->getMockBuilder(\Magento\Catalog\Api\Data\ProductAttributeMediaGalleryEntryInterface::class)
1174-
->setMethods(
1175-
[
1176-
'getId',
1177-
'getFile',
1178-
'getLabel',
1179-
'getPosition',
1180-
'isDisabled',
1181-
'types',
1182-
'getContent',
1183-
'getMediaType'
1184-
]
1185-
)
1186-
->getMockForAbstractClass();
1174+
->setMethods(
1175+
[
1176+
'getId',
1177+
'getFile',
1178+
'getLabel',
1179+
'getPosition',
1180+
'isDisabled',
1181+
'types',
1182+
'getContent',
1183+
'getMediaType'
1184+
]
1185+
)
1186+
->getMockForAbstractClass();
11871187

11881188
$result = [
11891189
'value_id' => 1,

app/code/Magento/Developer/Console/Command/GeneratePatchCommand.php

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -53,33 +53,33 @@ public function __construct(ComponentRegistrar $componentRegistrar)
5353
protected function configure()
5454
{
5555
$this->setName(self::COMMAND_NAME)
56-
->setDescription('Generate patch and put it in specific folder.')
57-
->setDefinition([
58-
new InputArgument(
59-
self::MODULE_NAME,
60-
InputArgument::REQUIRED,
61-
'Module name'
62-
),
63-
new InputArgument(
64-
self::INPUT_KEY_PATCH_NAME,
65-
InputArgument::REQUIRED,
66-
'Patch name'
67-
),
68-
new InputOption(
69-
self::INPUT_KEY_IS_REVERTABLE,
70-
null,
71-
InputOption::VALUE_OPTIONAL,
72-
'Check whether patch is revertable or not.',
73-
false
74-
),
75-
new InputOption(
76-
self::INPUT_KEY_PATCH_TYPE,
77-
null,
78-
InputOption::VALUE_OPTIONAL,
79-
'Find out what type of patch should be generated.',
80-
'data'
81-
),
82-
]);
56+
->setDescription('Generate patch and put it in specific folder.')
57+
->setDefinition([
58+
new InputArgument(
59+
self::MODULE_NAME,
60+
InputArgument::REQUIRED,
61+
'Module name'
62+
),
63+
new InputArgument(
64+
self::INPUT_KEY_PATCH_NAME,
65+
InputArgument::REQUIRED,
66+
'Patch name'
67+
),
68+
new InputOption(
69+
self::INPUT_KEY_IS_REVERTABLE,
70+
null,
71+
InputOption::VALUE_OPTIONAL,
72+
'Check whether patch is revertable or not.',
73+
false
74+
),
75+
new InputOption(
76+
self::INPUT_KEY_PATCH_TYPE,
77+
null,
78+
InputOption::VALUE_OPTIONAL,
79+
'Find out what type of patch should be generated.',
80+
'data'
81+
),
82+
]);
8383

8484
parent::configure();
8585
}

app/code/Magento/NewRelicReporting/Console/Command/DeployMarker.php

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -48,21 +48,21 @@ protected function configure()
4848
{
4949
$this->setName("newrelic:create:deploy-marker");
5050
$this->setDescription("Check the deploy queue for entries and create an appropriate deploy marker.")
51-
->addArgument(
52-
'message',
53-
InputArgument::REQUIRED,
54-
'Deploy Message?'
55-
)
56-
->addArgument(
57-
'change_log',
58-
InputArgument::REQUIRED,
59-
'Change Log?'
60-
)
61-
->addArgument(
62-
'user',
63-
InputArgument::OPTIONAL,
64-
'Deployment User'
65-
);
51+
->addArgument(
52+
'message',
53+
InputArgument::REQUIRED,
54+
'Deploy Message?'
55+
)
56+
->addArgument(
57+
'change_log',
58+
InputArgument::REQUIRED,
59+
'Change Log?'
60+
)
61+
->addArgument(
62+
'user',
63+
InputArgument::OPTIONAL,
64+
'Deployment User'
65+
);
6666
parent::configure();
6767
}
6868

app/code/Magento/Tax/Test/Unit/Observer/UpdateProductOptionsObserverTest.php

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -64,18 +64,18 @@ public function testUpdateProductOptions(
6464
->method('getEvent')
6565
->will($this->returnValue($eventObject));
6666

67-
$objectManager = new ObjectManager($this);
68-
$taxObserverObject = $objectManager->getObject(
69-
\Magento\Tax\Observer\UpdateProductOptionsObserver::class,
70-
[
71-
'taxData' => $taxData,
72-
'registry' => $registry,
73-
]
74-
);
75-
76-
$taxObserverObject->execute($observerObject);
77-
78-
$this->assertEquals($expected, $frameworkObject->getAdditionalOptions());
67+
$objectManager = new ObjectManager($this);
68+
$taxObserverObject = $objectManager->getObject(
69+
\Magento\Tax\Observer\UpdateProductOptionsObserver::class,
70+
[
71+
'taxData' => $taxData,
72+
'registry' => $registry,
73+
]
74+
);
75+
76+
$taxObserverObject->execute($observerObject);
77+
78+
$this->assertEquals($expected, $frameworkObject->getAdditionalOptions());
7979
}
8080

8181
/**

app/code/Magento/Theme/Block/Html/Topmenu.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ protected function _addSubMenu($child, $childLevel, $childrenWrapClass, $limit)
177177
return $html;
178178
}
179179

180-
$colStops = null;
180+
$colStops = [];
181181
if ($childLevel == 0 && $limit) {
182182
$colStops = $this->_columnBrake($child->getChildren(), $limit);
183183
}
@@ -205,7 +205,7 @@ protected function _getHtml(
205205
\Magento\Framework\Data\Tree\Node $menuTree,
206206
$childrenWrapClass,
207207
$limit,
208-
$colBrakes = []
208+
array $colBrakes = []
209209
) {
210210
$html = '';
211211

@@ -244,7 +244,7 @@ protected function _getHtml(
244244
}
245245
}
246246

247-
if (count($colBrakes) && $colBrakes[$counter]['colbrake']) {
247+
if (is_array($colBrakes) && count($colBrakes) && $colBrakes[$counter]['colbrake']) {
248248
$html .= '</ul></li><li class="column"><ul>';
249249
}
250250

@@ -261,7 +261,7 @@ protected function _getHtml(
261261
$counter++;
262262
}
263263

264-
if (count($colBrakes) && $limit) {
264+
if (is_array($colBrakes) && count($colBrakes) && $limit) {
265265
$html = '<li class="column"><ul>' . $html . '</ul></li>';
266266
}
267267

app/code/Magento/Theme/Model/Design/Backend/File.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,9 +89,9 @@ public function beforeSave()
8989
$values = $this->getValue();
9090
$value = reset($values) ?: [];
9191
if (!isset($value['file'])) {
92-
throw new LocalizedException(
93-
__('%1 does not contain field \'file\'', $this->getData('field_config/field'))
94-
);
92+
throw new LocalizedException(
93+
__('%1 does not contain field \'file\'', $this->getData('field_config/field'))
94+
);
9595
}
9696
if (isset($value['exists'])) {
9797
$this->setValue($value['file']);

app/code/Magento/Ui/DataProvider/AbstractDataProvider.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
* @api
1313
* @since 100.0.2
1414
*/
15-
abstract class AbstractDataProvider implements DataProviderInterface
15+
abstract class AbstractDataProvider implements DataProviderInterface, \Countable
1616
{
1717
/**
1818
* Data Provider name

0 commit comments

Comments
 (0)