Skip to content

Commit 186cd30

Browse files
committed
resolve conflict
2 parents 3e6b70a + dfea6d1 commit 186cd30

34 files changed

+260
-145
lines changed

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
/.directory
2+
/.DS_Store
3+
/*.kate-swp
4+
/var

.pre-commit-config.yaml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
repos:
2+
- repo: https://github.com/pre-commit/pre-commit-hooks
3+
rev: v4.0.1
4+
hooks:
5+
- id: end-of-file-fixer
6+
- id: mixed-line-ending
7+
args: ['--fix=lf']
8+
- id: trailing-whitespace
9+
- id: check-xml
10+
- id: check-yaml
11+
- id: check-json
12+
- id: pretty-format-json
13+
args: ["--indent=4", "--autofix", "--no-sort-keys"]
14+
- repo: https://github.com/eriocnemis/git.magento_pre_commit_hooks
15+
rev: 1.0.10
16+
hooks:
17+
- id: magento-xml
18+
- id: magento-phpcs
19+
args: ["--autofix"]
20+
- id: magento-phpmd
21+
- id: magento-phpcpd
22+
- id: magento-phpstan

Block/Adminhtml/Catalog/Edit/Tab/Conditions.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ class Conditions extends Generic implements TabInterface
5959
* @param RuleConditions $conditions
6060
* @param Fieldset $rendererFieldset
6161
* @param RuleFactory $ruleFactory
62-
* @param array $data
62+
* @param mixed[] $data
6363
*/
6464
public function __construct(
6565
Context $context,
@@ -233,7 +233,7 @@ protected function addTabToForm($model, $fieldsetId = 'conditions_fieldset', $fo
233233
*/
234234
protected function setConditionFormName(AbstractCondition $conditions, $formName)
235235
{
236-
$conditions->setFormName($formName);
236+
$conditions->setData('form_name', $formName);
237237
$conditions->setJsFormObject($formName);
238238
if ($conditions->getConditions() && is_array($conditions->getConditions())) {
239239
foreach ($conditions->getConditions() as $condition) {

Block/Adminhtml/Rule/Chooser/Sku.php

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ class Sku extends AbstractGrid
6666
* @param SetCollectionFactory $setCollectionFactory
6767
* @param ProductCollectionFactory $productCollectionFactory
6868
* @param ProductType $productType
69-
* @param array $data
69+
* @param mixed[] $data
7070
*/
7171
public function __construct(
7272
Context $context,
@@ -96,12 +96,12 @@ protected function _construct()
9696
{
9797
parent::_construct();
9898

99+
$id = 'skuChooserGrid_' . $this->getId();
99100
if ($this->getRequest()->getParam('current_grid_id')) {
100-
$this->setId($this->getRequest()->getParam('current_grid_id'));
101-
} else {
102-
$this->setId('skuChooserGrid_' . $this->getId());
101+
$id = $this->getRequest()->getParam('current_grid_id');
103102
}
104103

104+
$this->setId($id);
105105
$form = $this->getJsFormObject();
106106

107107
$this->setRowClickCallback("{$form}.chooserGridRowClick.bind({$form})");
@@ -129,15 +129,17 @@ protected function _addColumnFilterToCollection($column)
129129
if (empty($selected)) {
130130
$selected = '';
131131
}
132-
if ($column->getFilter()->getValue()) {
133-
$this->getCollection()->addFieldToFilter('sku', ['in' => $selected]);
134-
} else {
135-
$this->getCollection()->addFieldToFilter('sku', ['nin' => $selected]);
132+
133+
if (false !== $column->getFilter()) {
134+
$value = $column->getFilter()->getData('value')
135+
? ['in' => $selected]
136+
: ['nin' => $selected];
137+
138+
$this->getCollection()->addFieldToFilter('sku', $value);
136139
}
137-
} else {
138-
parent::_addColumnFilterToCollection($column);
140+
return $this;
139141
}
140-
return $this;
142+
return parent::_addColumnFilterToCollection($column);
141143
}
142144

143145
/**
@@ -149,9 +151,10 @@ protected function _prepareCollection()
149151
{
150152
$collection = $this->getProductCollection()
151153
->setStoreId(0)
152-
->addAttributeToSelect('name', 'type_id', 'attribute_set_id');
154+
->addAttributeToSelect(['name', 'type_id', 'attribute_set_id']);
153155

154156
$this->setCollection($collection);
157+
155158
return parent::_prepareCollection();
156159
}
157160

COPYING.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
Each Magento source file included in this distribution is licensed under OSL 3.0
22

33
http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
4-
Please see LICENSE.txt for the full text of the OSL 3.0 license.
4+
Please see LICENSE.txt for the full text of the OSL 3.0 license.

Controller/Adminhtml/Rule/Chooser.php

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -33,17 +33,16 @@ public function execute()
3333
break;
3434
case 'category_ids':
3535
$ids = $request->getParam('selected', []);
36-
if (is_array($ids)) {
37-
foreach ($ids as $key => &$id) {
38-
$id = (int)$id;
39-
if ($id <= 0) {
40-
unset($ids[$key]);
41-
}
36+
$ids = is_array($ids) ? $ids : [];
37+
38+
foreach ($ids as $key => &$id) {
39+
$id = (int)$id;
40+
if ($id <= 0) {
41+
unset($ids[$key]);
4242
}
43-
$ids = array_unique($ids);
44-
} else {
45-
$ids = [];
4643
}
44+
45+
$ids = array_unique($ids);
4746
$block = $this->_view->getLayout()->createBlock(
4847
Tree::class,
4948
'smartcategory_chooser_category_ids',
@@ -56,9 +55,6 @@ public function execute()
5655
$block = false;
5756
break;
5857
}
59-
60-
if ($block) {
61-
$this->getResponse()->setBody($block->toHtml());
62-
}
58+
return $this->getResponse()->setBody($block ? $block->toHtml() : '');
6359
}
6460
}

Controller/Adminhtml/Rule/NewConditionHtml.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ public function execute()
2727
$formName = $request->getParam('form_namespace');
2828
$typeArr = explode('|', str_replace('-', '/', $request->getParam('type')));
2929
$type = $typeArr[0];
30+
$html = '';
3031

3132
$model = $this->_objectManager->create($type)
3233
->setId($id)
@@ -40,11 +41,9 @@ public function execute()
4041

4142
if ($model instanceof AbstractCondition) {
4243
$model->setJsFormObject($request->getParam('form'));
43-
$model->setFormName($formName);
44+
$model->setData('form_name', $formName);
4445
$html = $model->asHtmlRecursive();
45-
} else {
46-
$html = '';
4746
}
48-
$this->getResponse()->setBody($html);
47+
return $this->getResponse()->setBody($html);
4948
}
5049
}

LICENSE.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ Licensed under the Open Software License version 3.0
1515

1616
4. to perform the Original Work publicly; and
1717

18-
5. to display the Original Work publicly.
18+
5. to display the Original Work publicly.
1919

2020
2. Grant of Patent License. Licensor grants You a worldwide, royalty-free, non-exclusive, sublicensable license, under patent claims owned or controlled by the Licensor that are embodied in the Original Work as furnished by the Licensor, for the duration of the patents, to make, use, sell, offer for sale, have made, and import the Original Work and Derivative Works.
2121

@@ -45,4 +45,4 @@ Licensed under the Open Software License version 3.0
4545

4646
15. Right to Use. You may use the Original Work in all ways not otherwise restricted or conditioned by this License or by law, and Licensor promises not to interfere with or be responsible for such uses by You.
4747

48-
16. Modification of This License. This License is Copyright (C) 2005 Lawrence Rosen. Permission is granted to copy, distribute, or communicate this License without modification. Nothing in this License permits You to modify this License as applied to the Original Work or to Derivative Works. However, You may modify the text of this License and copy, distribute or communicate your modified version (the "Modified License") and apply it to other original works of authorship subject to the following conditions: (i) You may not indicate in any way that your Modified License is the "Open Software License" or "OSL" and you may not use those names in the name of your Modified License; (ii) You must replace the notice specified in the first paragraph above with the notice "Licensed under <insert your license name here>" or with a notice of your own that is not confusingly similar to the notice in this License; and (iii) You may not claim that your original works are open source software unless your Modified License has been approved by Open Source Initiative (OSI) and You comply with its license review and certification process.
48+
16. Modification of This License. This License is Copyright (C) 2005 Lawrence Rosen. Permission is granted to copy, distribute, or communicate this License without modification. Nothing in this License permits You to modify this License as applied to the Original Work or to Derivative Works. However, You may modify the text of this License and copy, distribute or communicate your modified version (the "Modified License") and apply it to other original works of authorship subject to the following conditions: (i) You may not indicate in any way that your Modified License is the "Open Software License" or "OSL" and you may not use those names in the name of your Modified License; (ii) You must replace the notice specified in the first paragraph above with the notice "Licensed under <insert your license name here>" or with a notice of your own that is not confusingly similar to the notice in this License; and (iii) You may not claim that your original works are open source software unless your Modified License has been approved by Open Source Initiative (OSI) and You comply with its license review and certification process.

Model/Indexer/AbstractIndexer.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ public function executeFull()
9191
/**
9292
* Retrieve affected cache tags
9393
*
94-
* @return array
94+
* @return string[]
9595
* @codeCoverageIgnore
9696
*/
9797
public function getIdentities()
@@ -180,8 +180,7 @@ protected function getCacheContext()
180180
{
181181
if (!($this->cacheContext instanceof CacheContext)) {
182182
return ObjectManager::getInstance()->get(CacheContext::class);
183-
} else {
184-
return $this->cacheContext;
185183
}
184+
return $this->cacheContext;
186185
}
187186
}

Model/Indexer/IndexBuilder.php

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,12 @@
1515
use Psr\Log\LoggerInterface;
1616
use Faonni\SmartCategory\Model\ResourceModel\Rule\CollectionFactory as RuleCollectionFactory;
1717
use Faonni\SmartCategory\Model\Rule;
18+
use Zend_Db_Expr;
1819

1920
/**
20-
* Index builder
21+
* Rule index builder
22+
*
23+
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
2124
*/
2225
class IndexBuilder
2326
{
@@ -52,7 +55,7 @@ class IndexBuilder
5255
/**
5356
* Loaded products
5457
*
55-
* @var array
58+
* @var mixed[]
5659
*/
5760
protected $loadedProducts;
5861

@@ -109,7 +112,7 @@ public function reindexById($id)
109112
/**
110113
* Reindex by ids
111114
*
112-
* @param array $ids
115+
* @param int[] $ids
113116
* @throws LocalizedException
114117
* @return void
115118
* @api
@@ -129,7 +132,7 @@ public function reindexByIds(array $ids)
129132
/**
130133
* Reindex by ids
131134
*
132-
* @param array $ids
135+
* @param int[] $ids
133136
* @return void
134137
*/
135138
protected function doReindexByIds($ids)
@@ -200,7 +203,7 @@ protected function doReindexFull()
200203
* Clean by product ids
201204
*
202205
* @param integer $categoryId
203-
* @param array $productIds
206+
* @param mixed[] $productIds
204207
* @return void
205208
*/
206209
protected function cleanByIds($categoryId, $productIds)
@@ -215,7 +218,7 @@ protected function cleanByIds($categoryId, $productIds)
215218
* Insert products
216219
*
217220
* @param integer $categoryId
218-
* @param array $productIds
221+
* @param mixed[] $productIds
219222
* @return void
220223
*/
221224
protected function insertMultiple($categoryId, $productIds)
@@ -278,7 +281,7 @@ protected function checkPostedProduct($categoryId, $productId)
278281
{
279282
$select = $this->connection
280283
->select()
281-
->from($this->getTable('catalog_category_product'), [new \Zend_Db_Expr('COUNT(*)')])
284+
->from($this->getTable('catalog_category_product'), [new Zend_Db_Expr('COUNT(*)')])
282285
->where('category_id = ?', $categoryId)
283286
->where('product_id = ?', $productId);
284287

@@ -289,7 +292,7 @@ protected function checkPostedProduct($categoryId, $productId)
289292
* Retrieve posted products
290293
*
291294
* @param string $categoryId
292-
* @return array
295+
* @return mixed[]
293296
*/
294297
protected function getPostedProductData($categoryId)
295298
{

0 commit comments

Comments
 (0)