Skip to content

Commit 4682ad5

Browse files
author
Oleksii Korshenko
authored
MAGETWO-67616: Fixed coding standard violations in the Framework\Data namespace #9330
2 parents 0d4269a + 35cb908 commit 4682ad5

File tree

6 files changed

+147
-94
lines changed

6 files changed

+147
-94
lines changed

lib/internal/Magento/Framework/Data/Form/Element/Editor.php

Lines changed: 23 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44
* See COPYING.txt for license details.
55
*/
66

7-
// @codingStandardsIgnoreFile
8-
97
namespace Magento\Framework\Data\Form\Element;
108

119
use Magento\Framework\Escaper;
@@ -123,7 +121,15 @@ public function getElementHtml()
123121
'
124122
<script type="text/javascript">
125123
//<![CDATA[
126-
window.tinyMCE_GZ = window.tinyMCE_GZ || {}; window.tinyMCE_GZ.loaded = true;require(["jquery", "mage/translate", "mage/adminhtml/events", "mage/adminhtml/wysiwyg/tiny_mce/setup", "mage/adminhtml/wysiwyg/widget"], function(jQuery){' .
124+
window.tinyMCE_GZ = window.tinyMCE_GZ || {};
125+
window.tinyMCE_GZ.loaded = true;
126+
require([
127+
"jquery",
128+
"mage/translate",
129+
"mage/adminhtml/events",
130+
"mage/adminhtml/wysiwyg/tiny_mce/setup",
131+
"mage/adminhtml/wysiwyg/widget"
132+
], function(jQuery){' .
127133
"\n" .
128134
' (function($) {$.mage.translate.add(' .
129135
\Zend_Json::encode(
@@ -254,9 +260,9 @@ protected function _getPluginButtonsHtml($visible = true)
254260
$buttonsHtml .= $this->_getButtonHtml(
255261
[
256262
'title' => $this->translate('Insert Widget...'),
257-
'onclick' => "widgetTools.openDialog('" . $this->getConfig(
258-
'widget_window_url'
259-
) . "widget_target_id/" . $this->getHtmlId() . "')",
263+
'onclick' => "widgetTools.openDialog('"
264+
. $this->getConfig('widget_window_url')
265+
. "widget_target_id/" . $this->getHtmlId() . "')",
260266
'class' => 'action-add-widget plugin',
261267
'style' => $visible ? '' : 'display:none',
262268
]
@@ -268,13 +274,12 @@ protected function _getPluginButtonsHtml($visible = true)
268274
$buttonsHtml .= $this->_getButtonHtml(
269275
[
270276
'title' => $this->translate('Insert Image...'),
271-
'onclick' => "MediabrowserUtility.openDialog('" . $this->getConfig(
272-
'files_browser_window_url'
273-
) . "target_element_id/" . $this->getHtmlId() . "/" . (null !== $this->getConfig(
274-
'store_id'
275-
) ? 'store/' . $this->getConfig(
276-
'store_id'
277-
) . '/' : '') . "')",
277+
'onclick' => "MediabrowserUtility.openDialog('"
278+
. $this->getConfig('files_browser_window_url')
279+
. "target_element_id/" . $this->getHtmlId() . "/"
280+
. (null !== $this->getConfig('store_id') ? 'store/'
281+
. $this->getConfig('store_id') . '/' : '')
282+
. "')",
278283
'class' => 'action-add-image plugin',
279284
'style' => $visible ? '' : 'display:none',
280285
]
@@ -389,13 +394,11 @@ protected function _wrapIntoContainer($html)
389394
return '<div class="admin__control-wysiwig">' .$html . '</div>';
390395
}
391396

392-
$html = '<div id="editor' . $this->getHtmlId() . '"' . ($this->getConfig(
393-
'no_display'
394-
) ? ' style="display:none;"' : '') . ($this->getConfig(
395-
'container_class'
396-
) ? ' class="admin__control-wysiwig ' . $this->getConfig(
397-
'container_class'
398-
) . '"' : '') . '>' . $html . '</div>';
397+
$html = '<div id="editor' . $this->getHtmlId() . '"'
398+
. ($this->getConfig('no_display') ? ' style="display:none;"' : '')
399+
. ($this->getConfig('container_class') ? ' class="admin__control-wysiwig '
400+
. $this->getConfig('container_class') . '"' : '')
401+
. '>' . $html . '</div>';
399402

400403
return $html;
401404
}

lib/internal/Magento/Framework/Data/Form/Element/Gallery.php

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44
* See COPYING.txt for license details.
55
*/
66

7-
// @codingStandardsIgnoreFile
8-
97
/**
108
* Category form input image element
119
*
@@ -43,10 +41,18 @@ public function getElementHtml()
4341
$gallery = $this->getValue();
4442

4543
$html = '<table id="gallery" class="gallery" border="0" cellspacing="3" cellpadding="0">';
46-
$html .= '<thead id="gallery_thead" class="gallery"><tr class="gallery"><td class="gallery" valign="middle" align="center">Big Image</td><td class="gallery" valign="middle" align="center">Thumbnail</td><td class="gallery" valign="middle" align="center">Small Thumb</td><td class="gallery" valign="middle" align="center">Sort Order</td><td class="gallery" valign="middle" align="center">Delete</td></tr></thead>';
44+
$html .= '<thead id="gallery_thead" class="gallery">' .
45+
'<tr class="gallery">' .
46+
'<td class="gallery" valign="middle" align="center">Big Image</td>' .
47+
'<td class="gallery" valign="middle" align="center">Thumbnail</td>' .
48+
'<td class="gallery" valign="middle" align="center">Small Thumb</td>' .
49+
'<td class="gallery" valign="middle" align="center">Sort Order</td>' .
50+
'<td class="gallery" valign="middle" align="center">Delete</td>' .
51+
'</tr>'.
52+
'</thead>';
4753
$widgetButton = $this->getForm()->getParent()->getLayout();
4854
$buttonHtml = $widgetButton->createBlock(
49-
\Magento\Backend\Block\Widget\Button::class
55+
\Magento\Backend\Block\Widget\Button::class
5056
)->setData(
5157
['label' => 'Add New Image', 'onclick' => 'addNewImg()', 'class' => 'add']
5258
)->toHtml();
@@ -60,7 +66,7 @@ public function getElementHtml()
6066
$html .= '<tbody class="gallery">';
6167

6268
$i = 0;
63-
if (!is_null($this->getValue())) {
69+
if ($this->getValue() !== null) {
6470
foreach ($this->getValue() as $image) {
6571
$i++;
6672
$html .= '<tr class="gallery">';
@@ -102,7 +108,8 @@ public function getElementHtml()
102108
'file'
103109
) . ' ></td>';
104110
}
105-
$html .= '<td class="gallery" align="center" style="vertical-align:bottom;"><input type="input" name="' .
111+
$html .= '<td class="gallery" align="center" style="vertical-align:bottom;">' .
112+
'<input type="input" name="' .
106113
parent::getName() .
107114
'[position][' .
108115
$image->getValueId() .
@@ -116,7 +123,8 @@ public function getElementHtml()
116123
$this->_getUiId(
117124
'position-' . $image->getValueId()
118125
) . '/></td>';
119-
$html .= '<td class="gallery" align="center" style="vertical-align:bottom;"><input type="checkbox" name="' .
126+
$html .= '<td class="gallery" align="center" style="vertical-align:bottom;">' .
127+
'<input type="checkbox" name="' .
120128
parent::getName() .
121129
'[delete][' .
122130
$image->getValueId() .
@@ -134,7 +142,9 @@ public function getElementHtml()
134142
}
135143
}
136144
if ($i == 0) {
137-
$html .= '<script type="text/javascript">document.getElementById("gallery_thead").style.visibility="hidden";</script>';
145+
$html .= '<script type="text/javascript">' .
146+
'document.getElementById("gallery_thead").style.visibility="hidden";' .
147+
'</script>';
138148
}
139149

140150
$html .= '</tbody></table>';

lib/internal/Magento/Framework/Data/Form/Element/Time.php

Lines changed: 18 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44
* See COPYING.txt for license details.
55
*/
66

7-
// @codingStandardsIgnoreFile
8-
97
/**
108
* Form time element
119
*
@@ -54,52 +52,46 @@ public function getElementHtml()
5452
{
5553
$this->addClass('select admin__control-select');
5654

57-
$value_hrs = 0;
58-
$value_min = 0;
59-
$value_sec = 0;
55+
$valueHrs = 0;
56+
$valueMin = 0;
57+
$valueSec = 0;
6058

6159
if ($value = $this->getValue()) {
6260
$values = explode(',', $value);
6361
if (is_array($values) && count($values) == 3) {
64-
$value_hrs = $values[0];
65-
$value_min = $values[1];
66-
$value_sec = $values[2];
62+
$valueHrs = $values[0];
63+
$valueMin = $values[1];
64+
$valueSec = $values[2];
6765
}
6866
}
6967

7068
$html = '<input type="hidden" id="' . $this->getHtmlId() . '" ' . $this->_getUiId() . '/>';
71-
$html .= '<select name="' . $this->getName() . '" style="width:80px" ' . $this->serialize(
72-
$this->getHtmlAttributes()
73-
) . $this->_getUiId(
74-
'hour'
75-
) . '>' . "\n";
69+
$html .= '<select name="' . $this->getName() . '" style="width:80px" '
70+
. $this->serialize($this->getHtmlAttributes())
71+
. $this->_getUiId('hour') . '>' . "\n";
7672
for ($i = 0; $i < 24; $i++) {
7773
$hour = str_pad($i, 2, '0', STR_PAD_LEFT);
78-
$html .= '<option value="' . $hour . '" ' . ($value_hrs ==
74+
$html .= '<option value="' . $hour . '" ' . ($valueHrs ==
7975
$i ? 'selected="selected"' : '') . '>' . $hour . '</option>';
8076
}
8177
$html .= '</select>' . "\n";
8278

83-
$html .= ':&nbsp;<select name="' . $this->getName() . '" style="width:80px" ' . $this->serialize(
84-
$this->getHtmlAttributes()
85-
) . $this->_getUiId(
86-
'minute'
87-
) . '>' . "\n";
79+
$html .= ':&nbsp;<select name="' . $this->getName() . '" style="width:80px" '
80+
. $this->serialize($this->getHtmlAttributes())
81+
. $this->_getUiId('minute') . '>' . "\n";
8882
for ($i = 0; $i < 60; $i++) {
8983
$hour = str_pad($i, 2, '0', STR_PAD_LEFT);
90-
$html .= '<option value="' . $hour . '" ' . ($value_min ==
84+
$html .= '<option value="' . $hour . '" ' . ($valueMin ==
9185
$i ? 'selected="selected"' : '') . '>' . $hour . '</option>';
9286
}
9387
$html .= '</select>' . "\n";
9488

95-
$html .= ':&nbsp;<select name="' . $this->getName() . '" style="width:80px" ' . $this->serialize(
96-
$this->getHtmlAttributes()
97-
) . $this->_getUiId(
98-
'second'
99-
) . '>' . "\n";
89+
$html .= ':&nbsp;<select name="' . $this->getName() . '" style="width:80px" '
90+
. $this->serialize($this->getHtmlAttributes())
91+
. $this->_getUiId('second') . '>' . "\n";
10092
for ($i = 0; $i < 60; $i++) {
10193
$hour = str_pad($i, 2, '0', STR_PAD_LEFT);
102-
$html .= '<option value="' . $hour . '" ' . ($value_sec ==
94+
$html .= '<option value="' . $hour . '" ' . ($valueSec ==
10395
$i ? 'selected="selected"' : '') . '>' . $hour . '</option>';
10496
}
10597
$html .= '</select>' . "\n";

lib/internal/Magento/Framework/Data/FormFactory.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44
* See COPYING.txt for license details.
55
*/
66

7-
// @codingStandardsIgnoreFile
8-
97
namespace Magento\Framework\Data;
108

119
/**
@@ -54,7 +52,10 @@ public function create(array $data = [])
5452
$form = $this->_objectManager->create($this->_instanceName, $data);
5553
if (!$form instanceof \Magento\Framework\Data\Form) {
5654
throw new \Magento\Framework\Exception\LocalizedException(
57-
new \Magento\Framework\Phrase('%1 doesn\'t extend \Magento\Framework\Data\Form', [$this->_instanceName])
55+
new \Magento\Framework\Phrase(
56+
'%1 doesn\'t extend \Magento\Framework\Data\Form',
57+
[$this->_instanceName]
58+
)
5859
);
5960
}
6061
return $form;

lib/internal/Magento/Framework/Data/Test/Unit/Collection/DbTest.php

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44
* See COPYING.txt for license details.
55
*/
66

7-
// @codingStandardsIgnoreFile
8-
97
namespace Magento\Framework\Data\Test\Unit\Collection;
108

119
/**
@@ -44,10 +42,18 @@ protected function setUp()
4442
{
4543
$this->objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
4644
$this->fetchStrategyMock = $this->getMock(
47-
\Magento\Framework\Data\Collection\Db\FetchStrategy\Query::class, ['fetchAll'], [], '', false
45+
\Magento\Framework\Data\Collection\Db\FetchStrategy\Query::class,
46+
['fetchAll'],
47+
[],
48+
'',
49+
false
4850
);
4951
$this->entityFactoryMock = $this->getMock(
50-
\Magento\Framework\Data\Collection\EntityFactory::class, ['create'], [], '', false
52+
\Magento\Framework\Data\Collection\EntityFactory::class,
53+
['create'],
54+
[],
55+
'',
56+
false
5157
);
5258
$this->loggerMock = $this->getMock(\Psr\Log\LoggerInterface::class);
5359
$this->collection = new \Magento\Framework\Data\Test\Unit\Collection\DbCollection(
@@ -375,7 +381,11 @@ public function testFetchItem()
375381

376382
$adapterMock = $this->getMock(
377383
\Magento\Framework\DB\Adapter\Pdo\Mysql::class,
378-
['select', 'query'], [], '', false);
384+
['select', 'query'],
385+
[],
386+
'',
387+
false
388+
);
379389
$selectMock = $this->getMock(
380390
\Magento\Framework\DB\Select::class,
381391
[],
@@ -430,9 +440,9 @@ public function testGetSize()
430440
$adapterMock->expects($this->exactly(2))
431441
->method('quoteInto')
432442
->will($this->returnValueMap([
433-
['testField1=?', 'testValue1', null, null, 'testField1=testValue1'],
434-
['testField4=?', 'testValue4', null, null, 'testField4=testValue4'],
435-
]));
443+
['testField1=?', 'testValue1', null, null, 'testField1=testValue1'],
444+
['testField4=?', 'testValue4', null, null, 'testField4=testValue4'],
445+
]));
436446
$selectMock->expects($this->once())
437447
->method('orWhere')
438448
->with('testField1=testValue1');
@@ -558,7 +568,11 @@ public function testToOptionHash()
558568
$data = [10 => 'test'];
559569
$adapterMock = $this->getMock(
560570
\Magento\Framework\DB\Adapter\Pdo\Mysql::class,
561-
['select', 'query'], [], '', false);
571+
['select', 'query'],
572+
[],
573+
'',
574+
false
575+
);
562576
$selectMock = $this->getMock(
563577
\Magento\Framework\DB\Select::class,
564578
[],

0 commit comments

Comments
 (0)