Skip to content

Commit

Permalink
[PSR-2 Compliance] The Great @codingStandardsIgnoreFile Massacre
Browse files Browse the repository at this point in the history
- apply automatic PHPCBF fixes to make PHPCS happy
- Step 0. Install phpcs globally: composer global require squizlabs/php_codesniffer:2.8.0
- Step 1. Execute tool to fix PSR-2 violations in PHP files: ~/.composer/vendor/squizlabs/php_codesniffer/scripts/phpcbf --standard=PSR2 --extensions=php --ignore=generated/*,vendor/*,var/* .
  • Loading branch information
orlangur committed Apr 23, 2017
1 parent 4dc56e0 commit c619404
Show file tree
Hide file tree
Showing 247 changed files with 1,808 additions and 1,114 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ public function testGetLatestUnreadNotifications()

// 1. Create mocks
$notificationList = $this->getMockBuilder(
\Magento\AdminNotification\Model\ResourceModel\Inbox\Collection\Unread::class)
\Magento\AdminNotification\Model\ResourceModel\Inbox\Collection\Unread::class
)
->disableOriginalConstructor()
->getMock();

Expand Down
6 changes: 3 additions & 3 deletions app/code/Magento/Backend/Block/Menu.php
Original file line number Diff line number Diff line change
Expand Up @@ -147,9 +147,9 @@ protected function _renderItemCssClass($menuItem, $level)
$isLast = 0 == $level && (bool)$this->getMenuModel()->isLast($menuItem) ? 'last' : '';
$output = ($this->menuItemChecker->isItemActive(
$this->getActiveItemModel(),
$menuItem,
$level
) ? '_current _active' : '') .
$menuItem,
$level
) ? '_current _active' : '') .
' ' .
($menuItem->hasChildren() ? 'parent' : '') .
' ' .
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ protected function _construct()
public function getRobotsDefaultCustomInstructions()
{
return trim((string)$this->_scopeConfig->getValue(
self::XML_PATH_ROBOTS_DEFAULT_CUSTOM_INSTRUCTIONS, ScopeConfigInterface::SCOPE_TYPE_DEFAULT
self::XML_PATH_ROBOTS_DEFAULT_CUSTOM_INSTRUCTIONS,
ScopeConfigInterface::SCOPE_TYPE_DEFAULT
));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ protected function _prepareForm()
]
);
$renderer = $this->getLayout()->createBlock(
\Magento\Backend\Block\Store\Switcher\Form\Renderer\Fieldset\Element::class
\Magento\Backend\Block\Store\Switcher\Form\Renderer\Fieldset\Element::class
);
$field->setRenderer($renderer);
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,8 @@ public function testGetTotals()
);

$this->assertEquals(
new \Magento\Framework\DataObject(['test1' => '3', 'test2' => '2']), $this->_block->getTotals()
new \Magento\Framework\DataObject(['test1' => '3', 'test2' => '2']),
$this->_block->getTotals()
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,7 @@ public function testExecute()

$messageManager->expects($this->once())
->method('addSuccess')
->with('The JavaScript/CSS cache has been cleaned.'
);
->with('The JavaScript/CSS cache has been cleaned.');

$valueMap = [
[\Magento\Framework\View\Asset\MergeService::class, $mergeService],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,31 @@ protected function assertExecute($controllerName, $blockName)
$outPut = "data";
$resultRawMock = $this->getMock(
\Magento\Framework\Controller\Result\Raw::class,
['setContents'], [], '', false);
['setContents'],
[],
'',
false
);
$resultRawFactoryMock = $this->getMock(
\Magento\Framework\Controller\Result\RawFactory::class,
['create'], [], '', false
['create'],
[],
'',
false
);
$layoutFactoryMock = $this->getMock(
\Magento\Framework\View\LayoutFactory::class,
['create'], [], '', false
['create'],
[],
'',
false
);
$layoutMock = $this->getMock(
\Magento\Framework\View\Layout::class,
['createBlock', 'toHtml'], [], '', false
['createBlock', 'toHtml'],
[],
'',
false
);
$layoutFactoryMock->expects($this->once())->method('create')->will($this->returnValue($layoutMock));
$layoutMock->expects($this->once())->method('createBlock')->with($blockName)->will($this->returnSelf());
Expand Down
3 changes: 2 additions & 1 deletion app/code/Magento/Backend/Test/Unit/Model/UrlTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,8 @@ protected function setUp()
\Magento\Framework\Data\Form\FormKey::class,
['getFormKey'],
[],
'', false
'',
false
);
$this->_formKey->expects($this->any())->method('getFormKey')->will($this->returnValue('salt'));

Expand Down
3 changes: 1 addition & 2 deletions app/code/Magento/Bundle/Model/Product/Type.php
Original file line number Diff line number Diff line change
Expand Up @@ -840,8 +840,7 @@ public function getOptionsByIds($optionIds, $product)
$usedOptions = $product->getData($this->_keyUsedOptions);
$usedOptionsIds = $product->getData($this->_keyUsedOptionsIds);

if (
!$usedOptions
if (!$usedOptions
|| $this->serializer->serialize($usedOptionsIds) != $this->serializer->serialize($optionIds)
) {
$usedOptions = $this->_bundleOption
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ public function testSetOption()
$this->product->expects($this->atLeastOnce())
->method('getPreconfiguredValues')
->will($this->returnValue(
new \Magento\Framework\DataObject(['bundle_option' => [15 => 315, 16 => 316]]))
);
new \Magento\Framework\DataObject(['bundle_option' => [15 => 315, 16 => 316]])
));

$option = $this->getMock(\Magento\Bundle\Model\Option::class, [], [], '', false);
$option->expects($this->any())->method('getId')->will($this->returnValue(15));
Expand Down
39 changes: 32 additions & 7 deletions app/code/Magento/Bundle/Test/Unit/Model/LinkManagementTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,8 @@ protected function setUp()
->disableOriginalConstructor()
->getMock();
$this->selectionCollection = $this->getMockBuilder(
\Magento\Bundle\Model\ResourceModel\Selection\Collection::class)
\Magento\Bundle\Model\ResourceModel\Selection\Collection::class
)
->disableOriginalConstructor()
->getMock();
$this->product = $this->getMockBuilder(\Magento\Catalog\Model\Product::class)
Expand All @@ -149,13 +150,25 @@ protected function setUp()
->disableOriginalConstructor()
->getMock();
$this->bundleSelectionMock = $this->getMock(
\Magento\Bundle\Model\SelectionFactory::class, ['create'], [], '', false
\Magento\Bundle\Model\SelectionFactory::class,
['create'],
[],
'',
false
);
$this->bundleFactoryMock = $this->getMock(
\Magento\Bundle\Model\ResourceModel\BundleFactory::class, ['create'], [], '', false
\Magento\Bundle\Model\ResourceModel\BundleFactory::class,
['create'],
[],
'',
false
);
$this->optionCollectionFactoryMock = $this->getMock(
\Magento\Bundle\Model\ResourceModel\Option\CollectionFactory::class, ['create'], [], '', false
\Magento\Bundle\Model\ResourceModel\Option\CollectionFactory::class,
['create'],
[],
'',
false
);
$this->storeManagerMock = $this->getMock(\Magento\Store\Model\StoreManagerInterface::class, [], [], '', false);
$this->metadataPoolMock = $this->getMockBuilder(\Magento\Framework\EntityManager\MetadataPool::class)
Expand Down Expand Up @@ -321,7 +334,11 @@ public function testAddChildNonExistingOption()
->will($this->returnValue(null));

$optionsCollectionMock = $this->getMock(
\Magento\Bundle\Model\ResourceModel\Option\Collection::class, [], [], '', false
\Magento\Bundle\Model\ResourceModel\Option\Collection::class,
[],
[],
'',
false
);
$optionsCollectionMock->expects($this->once())
->method('setIdFilter')
Expand Down Expand Up @@ -505,7 +522,11 @@ public function testAddChildCouldNotSave()
$option->expects($this->once())->method('getId')->will($this->returnValue(1));

$optionsCollectionMock = $this->getMock(
\Magento\Bundle\Model\ResourceModel\Option\Collection::class, [], [], '', false
\Magento\Bundle\Model\ResourceModel\Option\Collection::class,
[],
[],
'',
false
);
$optionsCollectionMock->expects($this->once())
->method('setIdFilter')
Expand Down Expand Up @@ -576,7 +597,11 @@ public function testAddChild()
$option->expects($this->once())->method('getId')->will($this->returnValue(1));

$optionsCollectionMock = $this->getMock(
\Magento\Bundle\Model\ResourceModel\Option\Collection::class, [], [], '', false
\Magento\Bundle\Model\ResourceModel\Option\Collection::class,
[],
[],
'',
false
);
$optionsCollectionMock->expects($this->once())
->method('setIdFilter')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,8 @@ function ($type) {
\Magento\Bundle\Pricing\Adjustment\SelectionPriceListProviderInterface::class
)->getMock();

$this->model = (new ObjectManager($this))->getObject(\Magento\Bundle\Pricing\Adjustment\Calculator::class,
$this->model = (new ObjectManager($this))->getObject(
\Magento\Bundle\Pricing\Adjustment\Calculator::class,
[
'calculator' => $this->baseCalculator,
'amountFactory' => $this->amountFactory,
Expand Down Expand Up @@ -586,7 +587,8 @@ public function testGetOptionsAmount($searchMin, $useRegularPrice)

$result = $calculatorMock->getOptionsAmount(
$this->saleableItem,
$exclude, $searchMin,
$exclude,
$searchMin,
$amount,
$useRegularPrice
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,7 @@ public function testCalculateDiscountWithDefaultAmount()
$this->getPriceMock(20),
$this->getPriceMock(40),
]
)
);
));
$this->assertEquals(20, $this->calculator->calculateDiscount($this->productMock));
}

Expand All @@ -122,13 +121,12 @@ public function testCalculateDiscountWithCustomAmount()
$this->priceInfoMock->expects($this->once())
->method('getPrices')
->will($this->returnValue(
[
[
$this->getPriceMock(30),
$this->getPriceMock(20),
$this->getPriceMock(40),
]
)
);
));
$this->assertEquals(10, $this->calculator->calculateDiscount($this->productMock, 50));
}
}
6 changes: 4 additions & 2 deletions app/code/Magento/Catalog/Block/Adminhtml/Category/Tree.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,8 @@ protected function _prepareLayout()
$addUrl = $this->getUrl("*/*/add", ['_current' => false, 'id' => null, '_query' => false]);
if ($this->getStore()->getId() == Store::DEFAULT_STORE_ID) {
$this->addChild(
'add_sub_button', \Magento\Backend\Block\Widget\Button::class,
'add_sub_button',
\Magento\Backend\Block\Widget\Button::class,
[
'label' => __('Add Subcategory'),
'onclick' => "addNew('" . $addUrl . "', false)",
Expand All @@ -97,7 +98,8 @@ protected function _prepareLayout()

if ($this->canAddRootCategory()) {
$this->addChild(
'add_root_button', \Magento\Backend\Block\Widget\Button::class,
'add_root_button',
\Magento\Backend\Block\Widget\Button::class,
[
'label' => __('Add Root Category'),
'onclick' => "addNew('" . $addUrl . "', true)",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ class Alerts extends \Magento\Backend\Block\Widget\Tab
protected function _prepareLayout()
{
$accordion = $this->getLayout()->createBlock(
\Magento\Backend\Block\Widget\Accordion::class)->setId('productAlerts');
\Magento\Backend\Block\Widget\Accordion::class
)->setId('productAlerts');
/* @var $accordion \Magento\Backend\Block\Widget\Accordion */

$alertPriceAllow = $this->_scopeConfig->getValue('catalog/productalert/allow_price', \Magento\Store\Model\ScopeInterface::SCOPE_STORE);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,8 @@ public function getOptionValues()
$value['checkboxScopeTitle'] = $this->getCheckboxScopeHtml(
$option->getOptionId(),
'title',
$option->getStoreTitle() === null);
$option->getStoreTitle() === null
);
$value['scopeTitleDisabled'] = $option->getStoreTitle() === null ? 'disabled' : null;
}

Expand Down Expand Up @@ -372,7 +373,8 @@ public function getOptionValues()
$value['checkboxScopePrice'] = $this->getCheckboxScopeHtml(
$option->getOptionId(),
'price',
$option->getStorePrice() === null);
$option->getStorePrice() === null
);
$value['scopePriceDisabled'] = $option->getStorePrice() === null ? 'disabled' : null;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,16 +124,16 @@ public function getAfterElementHtml()
$newCategoryCaption = __('New Category');

$button = $this->_layout->createBlock(
\Magento\Backend\Block\Widget\Button::class
\Magento\Backend\Block\Widget\Button::class
)->setData(
[
[
'id' => 'add_category_button',
'label' => $newCategoryCaption,
'title' => $newCategoryCaption,
'onclick' => 'jQuery("#new-category").modal("openModal")',
'disabled' => $this->getDisabled(),
]
);
);
$return = <<<HTML
<input id="{$htmlId}-suggest" placeholder="$suggestPlaceholder" />
<script>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ protected function _validateProducts()
if (!is_array($productIds)) {
$error = __('Please select products for attributes update.');
} elseif (!$this->_objectManager->create(
\Magento\Catalog\Model\Product::class)->isProductsHasSku($productIds)) {
\Magento\Catalog\Model\Product::class
)->isProductsHasSku($productIds)) {
$error = __('Please make sure to define SKU values for all processed products.');
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ protected function setUp()
);

$this->requestMock = $this->getMockBuilder(
\Magento\Framework\App\RequestInterface::class)
\Magento\Framework\App\RequestInterface::class
)
->disableOriginalConstructor()
->getMock();

Expand All @@ -65,12 +66,14 @@ protected function setUp()
->will($this->returnValue($this->requestMock));

$this->urlBuilderMock = $this->getMockBuilder(
\Magento\Framework\UrlInterface::class)
\Magento\Framework\UrlInterface::class
)
->disableOriginalConstructor()
->getMock();

$this->storeManagerMock = $this->getMockBuilder(
\Magento\Store\Model\StoreManagerInterface::class)
\Magento\Store\Model\StoreManagerInterface::class
)
->disableOriginalConstructor()
->getMock();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,9 @@ public function testGetProductPriceHtml()
->will($this->returnValue($expectedPriceHtml));

$this->assertEquals($expectedPriceHtml, $this->block->getProductPriceHtml(
$product, 'price_code', 'zone_code'
$product,
'price_code',
'zone_code'
));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,7 @@ public function testGetIdentities()
['product', $product],
['current_category', $category],
]
)
);
));
$this->assertEquals(['cat_p_1', 'cat_c_1'], $this->view->getIdentities());
}
}
Loading

0 comments on commit c619404

Please sign in to comment.