Skip to content

Commit 2f7131c

Browse files
committed
Fixed coding standard violations in the Framework\Data namespace, so that it will be checked bij PHP CS and no longer be ignored while doing CI checks. Made the following changes:
- Removed @codingStandardsIgnoreFile at the head of the files - Fixed indentation - Changed is_null function call to a === null compare
1 parent d5f2939 commit 2f7131c

File tree

6 files changed

+150
-88
lines changed

6 files changed

+150
-88
lines changed

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

Lines changed: 23 additions & 17 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(
@@ -255,8 +261,8 @@ protected function _getPluginButtonsHtml($visible = true)
255261
[
256262
'title' => $this->translate('Insert Widget...'),
257263
'onclick' => "widgetTools.openDialog('" . $this->getConfig(
258-
'widget_window_url'
259-
) . "widget_target_id/" . $this->getHtmlId() . "')",
264+
'widget_window_url'
265+
) . "widget_target_id/" . $this->getHtmlId() . "')",
260266
'class' => 'action-add-widget plugin',
261267
'style' => $visible ? '' : 'display:none',
262268
]
@@ -269,12 +275,12 @@ protected function _getPluginButtonsHtml($visible = true)
269275
[
270276
'title' => $this->translate('Insert Image...'),
271277
'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-
) . '/' : '') . "')",
278+
'files_browser_window_url'
279+
) . "target_element_id/" . $this->getHtmlId() . "/" . (null !== $this->getConfig(
280+
'store_id'
281+
) ? 'store/' . $this->getConfig(
282+
'store_id'
283+
) . '/' : '') . "')",
278284
'class' => 'action-add-image plugin',
279285
'style' => $visible ? '' : 'display:none',
280286
]
@@ -390,12 +396,12 @@ protected function _wrapIntoContainer($html)
390396
}
391397

392398
$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>';
399+
'no_display'
400+
) ? ' style="display:none;"' : '') . ($this->getConfig(
401+
'container_class'
402+
) ? ' class="admin__control-wysiwig ' . $this->getConfig(
403+
'container_class'
404+
) . '"' : '') . '>' . $html . '</div>';
399405

400406
return $html;
401407
}

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: 21 additions & 23 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,52 @@ 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() . '/>';
7169
$html .= '<select name="' . $this->getName() . '" style="width:80px" ' . $this->serialize(
72-
$this->getHtmlAttributes()
73-
) . $this->_getUiId(
74-
'hour'
75-
) . '>' . "\n";
70+
$this->getHtmlAttributes()
71+
) . $this->_getUiId(
72+
'hour'
73+
) . '>' . "\n";
7674
for ($i = 0; $i < 24; $i++) {
7775
$hour = str_pad($i, 2, '0', STR_PAD_LEFT);
78-
$html .= '<option value="' . $hour . '" ' . ($value_hrs ==
76+
$html .= '<option value="' . $hour . '" ' . ($valueHrs ==
7977
$i ? 'selected="selected"' : '') . '>' . $hour . '</option>';
8078
}
8179
$html .= '</select>' . "\n";
8280

8381
$html .= ':&nbsp;<select name="' . $this->getName() . '" style="width:80px" ' . $this->serialize(
84-
$this->getHtmlAttributes()
85-
) . $this->_getUiId(
86-
'minute'
87-
) . '>' . "\n";
82+
$this->getHtmlAttributes()
83+
) . $this->_getUiId(
84+
'minute'
85+
) . '>' . "\n";
8886
for ($i = 0; $i < 60; $i++) {
8987
$hour = str_pad($i, 2, '0', STR_PAD_LEFT);
90-
$html .= '<option value="' . $hour . '" ' . ($value_min ==
88+
$html .= '<option value="' . $hour . '" ' . ($valueMin ==
9189
$i ? 'selected="selected"' : '') . '>' . $hour . '</option>';
9290
}
9391
$html .= '</select>' . "\n";
9492

9593
$html .= ':&nbsp;<select name="' . $this->getName() . '" style="width:80px" ' . $this->serialize(
96-
$this->getHtmlAttributes()
97-
) . $this->_getUiId(
98-
'second'
99-
) . '>' . "\n";
94+
$this->getHtmlAttributes()
95+
) . $this->_getUiId(
96+
'second'
97+
) . '>' . "\n";
10098
for ($i = 0; $i < 60; $i++) {
10199
$hour = str_pad($i, 2, '0', STR_PAD_LEFT);
102-
$html .= '<option value="' . $hour . '" ' . ($value_sec ==
100+
$html .= '<option value="' . $hour . '" ' . ($valueSec ==
103101
$i ? 'selected="selected"' : '') . '>' . $hour . '</option>';
104102
}
105103
$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)