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

Fix Calls to count() #97

Merged
merged 20 commits into from
Mar 27, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
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
10 changes: 7 additions & 3 deletions app/code/Magento/Backend/Block/Menu.php
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@ protected function _addSubMenu($menuItem, $level, $limit, $id = null)
return $output;
}
$output .= '<div class="submenu"' . ($level == 0 && isset($id) ? ' aria-labelledby="' . $id . '"' : '') . '>';
$colStops = null;
$colStops = [];
if ($level == 0 && $limit) {
$colStops = $this->_columnBrake($menuItem->getChildren(), $limit);
$output .= '<strong class="submenu-title">' . $this->_getAnchorLabel($menuItem) . '</strong>';
Expand Down Expand Up @@ -387,7 +387,11 @@ public function renderNavigation($menu, $level = 0, $limit = 0, $colBrakes = [])
$itemName = substr($menuId, strrpos($menuId, '::') + 2);
$itemClass = str_replace('_', '-', strtolower($itemName));

if (count($colBrakes) && $colBrakes[$itemPosition]['colbrake'] && $itemPosition != 1) {
if (is_array($colBrakes)
&& count($colBrakes)
&& $colBrakes[$itemPosition]['colbrake']
&& $itemPosition != 1
) {
$output .= '</ul></li><li class="column"><ul role="menu">';
}

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

if (count($colBrakes) && $limit) {
if (is_array($colBrakes) && count($colBrakes) && $limit) {
$output = '<li class="column"><ul role="menu">' . $output . '</ul></li>';
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
*
*/
/* @var $block \Magento\Backend\Block\Widget\Grid */
$numColumns = sizeof($block->getColumns());
$numColumns = !is_null($block->getColumns()) ? sizeof($block->getColumns()) : 0;
?>
<?php if ($block->getCollection()): ?>

Expand Down
32 changes: 16 additions & 16 deletions app/code/Magento/Catalog/Test/Unit/Model/ProductTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -330,9 +330,9 @@ protected function setUp()

$this->mediaGalleryEntryFactoryMock =
$this->getMockBuilder(\Magento\Catalog\Api\Data\ProductAttributeMediaGalleryEntryInterfaceFactory::class)
->setMethods(['create'])
->disableOriginalConstructor()
->getMock();
->setMethods(['create'])
->disableOriginalConstructor()
->getMock();

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

$entryMock = $this->getMockBuilder(\Magento\Catalog\Api\Data\ProductAttributeMediaGalleryEntryInterface::class)
->setMethods(
[
'getId',
'getFile',
'getLabel',
'getPosition',
'isDisabled',
'types',
'getContent',
'getMediaType'
]
)
->getMockForAbstractClass();
->setMethods(
[
'getId',
'getFile',
'getLabel',
'getPosition',
'isDisabled',
'types',
'getContent',
'getMediaType'
]
)
->getMockForAbstractClass();

$result = [
'value_id' => 1,
Expand Down
54 changes: 27 additions & 27 deletions app/code/Magento/Developer/Console/Command/GeneratePatchCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,33 +53,33 @@ public function __construct(ComponentRegistrar $componentRegistrar)
protected function configure()
{
$this->setName(self::COMMAND_NAME)
->setDescription('Generate patch and put it in specific folder.')
->setDefinition([
new InputArgument(
self::MODULE_NAME,
InputArgument::REQUIRED,
'Module name'
),
new InputArgument(
self::INPUT_KEY_PATCH_NAME,
InputArgument::REQUIRED,
'Patch name'
),
new InputOption(
self::INPUT_KEY_IS_REVERTABLE,
null,
InputOption::VALUE_OPTIONAL,
'Check whether patch is revertable or not.',
false
),
new InputOption(
self::INPUT_KEY_PATCH_TYPE,
null,
InputOption::VALUE_OPTIONAL,
'Find out what type of patch should be generated.',
'data'
),
]);
->setDescription('Generate patch and put it in specific folder.')
->setDefinition([
new InputArgument(
self::MODULE_NAME,
InputArgument::REQUIRED,
'Module name'
),
new InputArgument(
self::INPUT_KEY_PATCH_NAME,
InputArgument::REQUIRED,
'Patch name'
),
new InputOption(
self::INPUT_KEY_IS_REVERTABLE,
null,
InputOption::VALUE_OPTIONAL,
'Check whether patch is revertable or not.',
false
),
new InputOption(
self::INPUT_KEY_PATCH_TYPE,
null,
InputOption::VALUE_OPTIONAL,
'Find out what type of patch should be generated.',
'data'
),
]);

parent::configure();
}
Expand Down
30 changes: 15 additions & 15 deletions app/code/Magento/NewRelicReporting/Console/Command/DeployMarker.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,21 +48,21 @@ protected function configure()
{
$this->setName("newrelic:create:deploy-marker");
$this->setDescription("Check the deploy queue for entries and create an appropriate deploy marker.")
->addArgument(
'message',
InputArgument::REQUIRED,
'Deploy Message?'
)
->addArgument(
'change_log',
InputArgument::REQUIRED,
'Change Log?'
)
->addArgument(
'user',
InputArgument::OPTIONAL,
'Deployment User'
);
->addArgument(
'message',
InputArgument::REQUIRED,
'Deploy Message?'
)
->addArgument(
'change_log',
InputArgument::REQUIRED,
'Change Log?'
)
->addArgument(
'user',
InputArgument::OPTIONAL,
'Deployment User'
);
parent::configure();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,18 +64,18 @@ public function testUpdateProductOptions(
->method('getEvent')
->will($this->returnValue($eventObject));

$objectManager = new ObjectManager($this);
$taxObserverObject = $objectManager->getObject(
\Magento\Tax\Observer\UpdateProductOptionsObserver::class,
[
'taxData' => $taxData,
'registry' => $registry,
]
);

$taxObserverObject->execute($observerObject);

$this->assertEquals($expected, $frameworkObject->getAdditionalOptions());
$objectManager = new ObjectManager($this);
$taxObserverObject = $objectManager->getObject(
\Magento\Tax\Observer\UpdateProductOptionsObserver::class,
[
'taxData' => $taxData,
'registry' => $registry,
]
);

$taxObserverObject->execute($observerObject);

$this->assertEquals($expected, $frameworkObject->getAdditionalOptions());
}

/**
Expand Down
8 changes: 4 additions & 4 deletions app/code/Magento/Theme/Block/Html/Topmenu.php
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ protected function _addSubMenu($child, $childLevel, $childrenWrapClass, $limit)
return $html;
}

$colStops = null;
$colStops = [];
if ($childLevel == 0 && $limit) {
$colStops = $this->_columnBrake($child->getChildren(), $limit);
}
Expand Down Expand Up @@ -205,7 +205,7 @@ protected function _getHtml(
\Magento\Framework\Data\Tree\Node $menuTree,
$childrenWrapClass,
$limit,
$colBrakes = []
array $colBrakes = []
) {
$html = '';

Expand Down Expand Up @@ -244,7 +244,7 @@ protected function _getHtml(
}
}

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

Expand All @@ -261,7 +261,7 @@ protected function _getHtml(
$counter++;
}

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

Expand Down
6 changes: 3 additions & 3 deletions app/code/Magento/Theme/Model/Design/Backend/File.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,9 @@ public function beforeSave()
$values = $this->getValue();
$value = reset($values) ?: [];
if (!isset($value['file'])) {
throw new LocalizedException(
__('%1 does not contain field \'file\'', $this->getData('field_config/field'))
);
throw new LocalizedException(
__('%1 does not contain field \'file\'', $this->getData('field_config/field'))
);
}
if (isset($value['exists'])) {
$this->setValue($value['file']);
Expand Down
2 changes: 1 addition & 1 deletion app/code/Magento/Ui/DataProvider/AbstractDataProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
* @api
* @since 100.0.2
*/
abstract class AbstractDataProvider implements DataProviderInterface
abstract class AbstractDataProvider implements DataProviderInterface, \Countable
{
/**
* Data Provider name
Expand Down
Loading