Skip to content

Commit f03da13

Browse files
Andrei KuprienkaAndrei Kuprienka
authored andcommitted
MAGNIMEX-SPRINT2: fix code styles(phpmd, phpcs)
1 parent ce971fc commit f03da13

File tree

12 files changed

+2040
-2001
lines changed

12 files changed

+2040
-2001
lines changed

app/code/Magento/BundleImportExport/Model/Import/Product/Type/Bundle.php

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* Class Bundle
1515
* @package Magento\BundleImportExport\Model\Import\Product\Type
1616
* @SuppressWarnings(PHPMD.ExcessiveClassComplexity)
17-
*/
17+
*/
1818
class Bundle extends \Magento\CatalogImportExport\Model\Import\Product\Type\AbstractType
1919
{
2020

@@ -392,7 +392,7 @@ public function prepareAttributesWithDefaultValueForSave(array $rowData, $withDe
392392
/**
393393
* Transform dynamic/fixed values to integer.
394394
*
395-
* @param $rowData
395+
* @param array $rowData
396396
* @return array
397397
*/
398398
protected function transformBundleCustomAttributes($rowData)
@@ -450,6 +450,7 @@ protected function populateExistingOptions()
450450
*/
451451
protected function populateExistingSelections($existingOptions)
452452
{
453+
//@codingStandardsIgnoreStart
453454
$existingSelections = $this->connection->fetchAll(
454455
$this->connection->select()->from(
455456
$this->_resource->getTableName('catalog_product_bundle_selection')
@@ -460,12 +461,17 @@ protected function populateExistingSelections($existingOptions)
460461
);
461462
foreach ($existingSelections as $existingSelection) {
462463
$optionTitle = $existingOptions[$existingSelection['option_id']]['title'];
463-
foreach ($this->_cachedOptions[$existingSelection['parent_product_id']][$optionTitle]['selections'] as $selectIndex => $selection) {
464+
$cachedOptionsSelections = $this->_cachedOptions[$existingSelection['parent_product_id']][$optionTitle]['selections'];
465+
foreach ($cachedOptionsSelections as $selectIndex => $selection) {
464466
$productId = $this->_cachedSkuToProducts[$selection['sku']];
465467
if ($productId == $existingSelection['product_id']) {
466468
foreach (array_keys($existingSelection) as $origKey) {
467-
$key = isset($this->_bundleFieldMapping[$origKey]) ? $this->_bundleFieldMapping[$origKey] : $origKey;
468-
if (!isset($this->_cachedOptions[$existingSelection['parent_product_id']][$optionTitle]['selections'][$selectIndex][$key])) {
469+
$key = isset($this->_bundleFieldMapping[$origKey])
470+
? $this->_bundleFieldMapping[$origKey]
471+
: $origKey;
472+
if (
473+
!isset($this->_cachedOptions[$existingSelection['parent_product_id']][$optionTitle]['selections'][$selectIndex][$key])
474+
) {
469475
$this->_cachedOptions[$existingSelection['parent_product_id']][$optionTitle]['selections'][$selectIndex][$key] =
470476
$existingSelection[$origKey];
471477
}
@@ -474,6 +480,7 @@ protected function populateExistingSelections($existingOptions)
474480
}
475481
}
476482
}
483+
// @codingStandardsIgnoreEnd
477484
return $this;
478485
}
479486

app/code/Magento/CatalogImportExport/Model/Import/Product/Option.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1029,6 +1029,7 @@ protected function _isReadyForSaving(array &$options, array &$titles, array $typ
10291029
* @param array $rowData
10301030
*
10311031
* @return array
1032+
* @SuppressWarnings(PHPMD.NPathComplexity)
10321033
*/
10331034
protected function _getMultiRowFormat($rowData)
10341035
{
@@ -1074,6 +1075,7 @@ protected function _getMultiRowFormat($rowData)
10741075
* Import data rows
10751076
*
10761077
* @return boolean
1078+
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
10771079
*/
10781080
protected function _importData()
10791081
{

app/code/Magento/CatalogImportExport/Model/Import/Product/StoreResolver.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
class StoreResolver
99
{
1010
/**
11+
* Store manager instance.
12+
*
1113
* @var \Magento\Store\Model\StoreManagerInterface
1214
*/
1315
protected $storeManager;

app/code/Magento/CatalogImportExport/Model/Import/Product/TaxClassProcessor.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ class TaxClassProcessor
1717

1818
/**
1919
* Tax classes.
20+
*
21+
* @var array
2022
*/
2123
protected $taxClasses;
2224

@@ -68,9 +70,9 @@ protected function initTaxClasses()
6870
/**
6971
* Creates new tax class.
7072
*
71-
* @param $taxClassName
73+
* @param string $taxClassName
7274
* @param AbstractType $productTypeModel
73-
* @return mixed
75+
* @return integer
7476
*/
7577
protected function createTaxClass($taxClassName, AbstractType $productTypeModel)
7678
{
@@ -90,9 +92,9 @@ protected function createTaxClass($taxClassName, AbstractType $productTypeModel)
9092
/**
9193
* Instantiate instance of tax class.
9294
*
93-
* @param $taxClassName
95+
* @param string $taxClassName
9496
* @param AbstractType $productTypeModel
95-
* @return mixed
97+
* @return object
9698
*/
9799
public function upsertTaxClass($taxClassName, AbstractType $productTypeModel)
98100
{

app/code/Magento/CatalogImportExport/Model/Import/Uploader.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,22 @@
1616
class Uploader extends \Magento\MediaStorage\Model\File\Uploader
1717
{
1818
/**
19+
* Temp directory.
20+
*
1921
* @var string
2022
*/
2123
protected $_tmpDir = '';
2224

2325
/**
26+
* Destination directory.
27+
*
2428
* @var string
2529
*/
2630
protected $_destDir = '';
2731

2832
/**
33+
* All mime types.
34+
*
2935
* @var array
3036
*/
3137
protected $_allowedMimeTypes = [
@@ -38,11 +44,15 @@ class Uploader extends \Magento\MediaStorage\Model\File\Uploader
3844
const DEFAULT_FILE_TYPE = 'application/octet-stream';
3945

4046
/**
47+
* Image factory.
48+
*
4149
* @var \Magento\Framework\Image\AdapterFactory
4250
*/
4351
protected $_imageFactory;
4452

4553
/**
54+
* Validator.
55+
*
4656
* @var \Magento\MediaStorage\Model\File\Validator\NotProtectedExtension
4757
*/
4858
protected $_validator;

app/code/Magento/CatalogImportExport/Test/Unit/Model/Import/Product/ValidatorTest.php

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -20,29 +20,29 @@ class ValidatorTest extends \PHPUnit_Framework_TestCase
2020
protected $validators = [];
2121

2222
/** @var Validator\Media|\PHPUnit_Framework_MockObject_MockObject */
23-
protected $validator1;
23+
protected $validatorOne;
2424

2525
/** @var Validator\Website|\PHPUnit_Framework_MockObject_MockObject */
26-
protected $validator2;
26+
protected $validatorTwo;
2727

2828
protected function setUp()
2929
{
30-
$this->validator1 = $this->getMock(
30+
$this->validatorOne = $this->getMock(
3131
'Magento\CatalogImportExport\Model\Import\Product\Validator\Media',
3232
[],
3333
[],
3434
'',
3535
false
3636
);
37-
$this->validator2 = $this->getMock(
37+
$this->validatorTwo = $this->getMock(
3838
'Magento\CatalogImportExport\Model\Import\Product\Validator\Website',
3939
[],
4040
[],
4141
'',
4242
false
4343
);
4444

45-
$this->validators = [$this->validator1, $this->validator2];
45+
$this->validators = [$this->validatorOne, $this->validatorTwo];
4646
$this->objectManagerHelper = new ObjectManagerHelper($this);
4747
$this->validator = $this->objectManagerHelper->getObject(
4848
'Magento\CatalogImportExport\Model\Import\Product\Validator',
@@ -53,28 +53,28 @@ protected function setUp()
5353
public function testIsValidCorrect()
5454
{
5555
$value = 'val';
56-
$this->validator1->expects($this->once())->method('isValid')->with($value)->willReturn(true);
57-
$this->validator2->expects($this->once())->method('isValid')->with($value)->willReturn(true);
56+
$this->validatorOne->expects($this->once())->method('isValid')->with($value)->willReturn(true);
57+
$this->validatorTwo->expects($this->once())->method('isValid')->with($value)->willReturn(true);
5858
$result = $this->validator->isValid($value);
5959
$this->assertTrue($result);
6060
}
6161

6262
public function testIsValidIncorrect()
6363
{
6464
$value = 'val';
65-
$this->validator1->expects($this->once())->method('isValid')->with($value)->willReturn(true);
66-
$this->validator2->expects($this->once())->method('isValid')->with($value)->willReturn(false);
65+
$this->validatorOne->expects($this->once())->method('isValid')->with($value)->willReturn(true);
66+
$this->validatorTwo->expects($this->once())->method('isValid')->with($value)->willReturn(false);
6767
$messages = ['errorMessage'];
68-
$this->validator2->expects($this->once())->method('getMessages')->willReturn($messages);
68+
$this->validatorTwo->expects($this->once())->method('getMessages')->willReturn($messages);
6969
$result = $this->validator->isValid($value);
7070
$this->assertFalse($result);
7171
$this->assertEquals($messages, $this->validator->getMessages());
7272
}
7373

7474
public function testInit()
7575
{
76-
$this->validator1->expects($this->once())->method('init');
77-
$this->validator2->expects($this->once())->method('init');
76+
$this->validatorOne->expects($this->once())->method('init');
77+
$this->validatorTwo->expects($this->once())->method('init');
7878
$this->validator->init();
7979
}
8080
}

0 commit comments

Comments
 (0)