Skip to content

Commit 42fe223

Browse files
authored
Merge pull request #7255 from magento-trigger/ph-delivery
[Platform Health] Updates for PHP8.1 and js libs
2 parents e53b4ef + efd1c34 commit 42fe223

File tree

132 files changed

+1338
-1177
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

132 files changed

+1338
-1177
lines changed

app/code/Magento/Backend/Block/Widget/Grid/Column/Renderer/AbstractRenderer.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,9 +138,10 @@ public function renderHeader()
138138
{
139139
if (false !== $this->getColumn()->getSortable()) {
140140
$className = 'not-sort';
141-
$dir = strtolower($this->getColumn()->getDir());
141+
$dir = is_string($this->getColumn()->getDir()) ? strtolower($this->getColumn()->getDir()) : '';
142142
$nDir = $dir == 'asc' ? 'desc' : 'asc';
143-
if ($this->getColumn()->getDir()) {
143+
144+
if ($dir) {
144145
$className = '_' . $dir . 'end';
145146
}
146147
$out = '<th data-sort="' .

app/code/Magento/Backend/Test/Unit/Block/Widget/Grid/Column/Renderer/CurrencyTest.php

Lines changed: 19 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ protected function setUp(): void
7272

7373
$this->_curLocatorMock = $this->createMock(DefaultLocator::class);
7474
$this->_columnMock = $this->getMockBuilder(Column::class)
75-
->addMethods(['getIndex'])
75+
->addMethods(['getIndex', 'getCurrency', 'getRateField'])
7676
->disableOriginalConstructor()
7777
->getMock();
7878
$this->_columnMock->expects($this->any())->method('getIndex')->willReturn('columnIndex');
@@ -115,45 +115,25 @@ protected function tearDown(): void
115115
*/
116116
public function testRenderWithDefaultCurrency()
117117
{
118-
$this->_currencyMock->expects(
119-
$this->once()
120-
)->method(
121-
'getRate'
122-
)->with(
123-
'defaultCurrency'
124-
)->willReturn(
125-
1.5
126-
);
127-
128-
$this->_curLocatorMock->expects(
129-
$this->any()
130-
)->method(
131-
'getDefaultCurrency'
132-
)->with(
133-
$this->_requestMock
134-
)->willReturn(
135-
'defaultCurrency'
136-
);
137-
118+
$this->_currencyMock->expects($this->once())
119+
->method('getRate')
120+
->with('defaultCurrency')
121+
->willReturn(1.5);
122+
$this->_curLocatorMock->expects($this->any())
123+
->method('getDefaultCurrency')
124+
->with($this->_requestMock)
125+
->willReturn('defaultCurrency');
138126
$currLocaleMock = $this->createMock(\Zend_Currency::class);
139-
$currLocaleMock->expects(
140-
$this->once()
141-
)->method(
142-
'toCurrency'
143-
)->with(
144-
15.0000
145-
)->willReturn(
146-
'15USD'
147-
);
148-
$this->_localeMock->expects(
149-
$this->once()
150-
)->method(
151-
'getCurrency'
152-
)->with(
153-
'defaultCurrency'
154-
)->willReturn(
155-
$currLocaleMock
156-
);
127+
$currLocaleMock->expects($this->once())
128+
->method('toCurrency')
129+
->with(15.0000)
130+
->willReturn('15USD');
131+
$this->_localeMock->expects($this->once())
132+
->method('getCurrency')
133+
->with('defaultCurrency')
134+
->willReturn($currLocaleMock);
135+
$this->_columnMock->method('getCurrency')->willReturn('USD');
136+
$this->_columnMock->method('getRateField')->willReturn('test_rate_field');
157137

158138
$this->assertEquals('15USD', $this->_blockCurrency->render($this->_row));
159139
}

app/code/Magento/Backend/view/adminhtml/templates/widget/form/renderer/fieldset.phtml

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ if ($isField) {
3434
* echo $element->getSubFieldsetHtml();
3535
*/ ?>
3636

37-
<?php if ($isWrapped) : ?>
37+
<?php if ($isWrapped): ?>
3838
<div class="fieldset-wrapper <?= ($isCollapsable) ? 'admin__collapsible-block-wrapper ' : '' ?>"
3939
id="<?= $block->escapeHtmlAttr($containerId ? $containerId : $id . '-wrapper') ?>"
4040
data-role="<?= $block->escapeHtmlAttr($id) ?>-wrapper">
@@ -51,12 +51,12 @@ if ($isField) {
5151
data-role="<?= $block->escapeHtmlAttr($id) ?>-content">
5252
<?php endif; ?>
5353

54-
<?php if (!$element->getNoContainer()) : ?>
54+
<?php if (!$element->getNoContainer()): ?>
5555
<fieldset class="<?= $block->escapeHtmlAttr($cssClass) ?>" id="<?= $block->escapeHtmlAttr($id) ?>">
56-
<?php if (strlen($element->getBeforeElementHtml())) : ?>
56+
<?php if (is_string($element->getBeforeElementHtml()) && strlen($element->getBeforeElementHtml())): ?>
5757
<?= $element->getBeforeElementHtml() ?>
5858
<?php endif ?>
59-
<?php if ($element->getLegend() && !$isWrapped) : ?>
59+
<?php if ($element->getLegend() && !$isWrapped): ?>
6060
<legend class="<?= /* @noEscape */ $isField ? 'label admin__field-label' : 'admin__legend legend' ?>">
6161
<span><?= $block->escapeHtml($element->getLegend()) ?></span>
6262
</legend><br />
@@ -65,41 +65,41 @@ if ($isField) {
6565

6666

6767
<div class="messages">
68-
<?php if ($element->getComment() && !$isField) : ?>
68+
<?php if ($element->getComment() && !$isField): ?>
6969
<div class="message message-notice"><?= $block->escapeHtml($element->getComment()) ?></div>
7070
<?php endif; ?>
7171
</div>
7272

7373

7474
<?= ($isField) ? '<div class="control admin__field-control">' : '' ?>
7575

76-
<?php if ($element->hasHtmlContent() && !$isField) : ?>
76+
<?php if ($element->hasHtmlContent() && !$isField): ?>
7777
<?= $element->getHtmlContent() ?>
78-
<?php else : ?>
78+
<?php else: ?>
7979

80-
<?php if ($isField && $count > 1) : ?>
80+
<?php if ($isField && $count > 1): ?>
8181
<div class="fields-group-<?= /* @noEscape */ $count ?>">
8282
<?php endif; ?>
8383

8484
<?= $element->getBasicChildrenHtml() ?>
8585

8686
<?= ($isField && $count > 1) ? '</div>' : '' ?>
8787

88-
<?php if ($element->getComment() && $isField) : ?>
88+
<?php if ($element->getComment() && $isField): ?>
8989
<div class="note"><?= $block->escapeHtml($element->getComment()) ?></div>
9090
<?php endif; ?>
9191

92-
<?php if ($element->hasAdvanced() && !$isField) : ?>
92+
<?php if ($element->hasAdvanced() && !$isField): ?>
9393
<?= (!$element->getNoContainer() && $advancedAfter) ? '</fieldset>' : '' ?>
9494
<details class="details admin__collapsible-block-wrapper" id="details<?= /* @noEscape */ $id ?>">
95-
<summary class="details-summary admin__collapsible-title" id="details-summary<?= /* @noEscape */ $id ?>">
95+
<summary class="details-summary admin__collapsible-title" id="details-summary<?= /* @noEscape */ $id?>">
9696
<span><?= $block->escapeHtml($advancedLabel) ?></span>
9797
</summary>
9898
<div class="details-content admin__fieldset" id="details-content<?= /* @noEscape */ $id ?>">
9999
<?= $element->getAdvancedChildrenHtml() ?>
100100
</div>
101101
</details>
102-
<?php elseif ($element->hasAdvanced() && $isField) : ?>
102+
<?php elseif ($element->hasAdvanced() && $isField): ?>
103103
<div class="nested" id="nested<?= /* @noEscape */ $id ?>">
104104
<?= $element->getAdvancedChildrenHtml() ?>
105105
</div>
@@ -110,11 +110,11 @@ if ($isField) {
110110
<?php endif; ?>
111111

112112

113-
<?php if (!$element->getNoContainer() && !$advancedAfter) : ?>
113+
<?php if (!$element->getNoContainer() && !$advancedAfter): ?>
114114
</fieldset>
115115
<?php endif; ?>
116116

117-
<?php if ($isWrapped) : ?>
117+
<?php if ($isWrapped): ?>
118118
</div>
119119
</div>
120120
<?php endif; ?>

app/code/Magento/Bundle/Block/Adminhtml/Catalog/Product/Edit/Tab/Bundle/Option/Search/Grid.php

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@
1313
class Grid extends \Magento\Backend\Block\Widget\Grid\Extended
1414
{
1515
/**
16-
* Bundle data
17-
*
1816
* @var \Magento\Bundle\Helper\Data
1917
*/
2018
protected $_bundleData = null;
@@ -44,7 +42,10 @@ public function __construct(
4442
}
4543

4644
/**
45+
* Initialization
46+
*
4747
* @return void
48+
* @throws \Magento\Framework\Exception\FileSystemException
4849
*/
4950
protected function _construct()
5051
{
@@ -190,18 +191,22 @@ public function getGridUrl()
190191
}
191192

192193
/**
194+
* Get selected products
195+
*
193196
* @return mixed
194197
*/
195198
protected function _getSelectedProducts()
196199
{
197200
$products = $this->getRequest()->getPost(
198201
'selected_products',
199-
explode(',', $this->getRequest()->getParam('productss'))
202+
explode(',', $this->getRequest()->getParam('productss', ''))
200203
);
201204
return $products;
202205
}
203206

204207
/**
208+
* Get products
209+
*
205210
* @return array
206211
*/
207212
protected function _getProducts()

app/code/Magento/Bundle/Test/Unit/Model/Product/TypeTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2786,7 +2786,9 @@ public function notAvailableOptionProvider(): array
27862786
private function expectProductEntityMetadata(): void
27872787
{
27882788
$entityMetadataMock = $this->getMockBuilder(EntityMetadataInterface::class)
2789+
->onlyMethods(['getLinkField'])
27892790
->getMockForAbstractClass();
2791+
$entityMetadataMock->method('getLinkField')->willReturn('test_link_field');
27902792
$this->metadataPool->expects($this->any())->method('getMetadata')
27912793
->with(ProductInterface::class)
27922794
->willReturn($entityMetadataMock);

app/code/Magento/Catalog/Block/Product/ProductList/Toolbar.php

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,6 @@ class Toolbar extends \Magento\Framework\View\Element\Template
5050
protected $_enableViewSwitcher = true;
5151

5252
/**
53-
* Is Expanded
54-
*
5553
* @var bool
5654
*/
5755
protected $_isExpanded = true;
@@ -89,15 +87,11 @@ class Toolbar extends \Magento\Framework\View\Element\Template
8987
protected $_template = 'Magento_Catalog::product/list/toolbar.phtml';
9088

9189
/**
92-
* Catalog config
93-
*
9490
* @var \Magento\Catalog\Model\Config
9591
*/
9692
protected $_catalogConfig;
9793

9894
/**
99-
* Catalog session
100-
*
10195
* @var \Magento\Catalog\Model\Session
10296
* @deprecated 103.0.1
10397
*/
@@ -308,7 +302,9 @@ public function getCurrentDirection()
308302
}
309303

310304
$directions = ['asc', 'desc'];
311-
$dir = strtolower($this->toolbarMemorizer->getDirection());
305+
$dir = is_string($this->toolbarMemorizer->getDirection()) ?
306+
strtolower($this->toolbarMemorizer->getDirection()) : '';
307+
312308
if (!$dir || !in_array($dir, $directions)) {
313309
$dir = $this->_direction;
314310
}

app/code/Magento/Catalog/Controller/Category/View.php

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -40,22 +40,16 @@
4040
class View extends Action implements HttpGetActionInterface, HttpPostActionInterface
4141
{
4242
/**
43-
* Core registry
44-
*
4543
* @var Registry
4644
*/
4745
protected $_coreRegistry = null;
4846

4947
/**
50-
* Catalog session
51-
*
5248
* @var Session
5349
*/
5450
protected $_catalogSession;
5551

5652
/**
57-
* Catalog design
58-
*
5953
* @var Design
6054
*/
6155
protected $_catalogDesign;
@@ -212,6 +206,7 @@ public function execute()
212206
$result = null;
213207

214208
if ($this->_request->getParam(ActionInterface::PARAM_NAME_URL_ENCODED)) {
209+
//phpcs:ignore Magento2.Legacy.ObsoleteResponse
215210
return $this->resultRedirectFactory->create()->setUrl($this->_redirect->getRedirectUrl());
216211
}
217212
$category = $this->_initCategory();
@@ -240,7 +235,9 @@ public function execute()
240235
$page->addPageLayoutHandles(['type' => $parentPageType], null, false);
241236
}
242237
$page->addPageLayoutHandles(['type' => $pageType], null, false);
243-
$page->addPageLayoutHandles(['displaymode' => strtolower($category->getDisplayMode())], null, false);
238+
$categoryDisplayMode = is_string($category->getDisplayMode()) ?
239+
strtolower($category->getDisplayMode()) : '';
240+
$page->addPageLayoutHandles(['displaymode' => $categoryDisplayMode], null, false);
244241
$page->addPageLayoutHandles(['id' => $category->getId()]);
245242

246243
// apply custom layout update once layout is loaded

app/code/Magento/Catalog/Helper/Image.php

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,15 @@
1616
*
1717
* @api
1818
* @SuppressWarnings(PHPMD.TooManyFields)
19+
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
1920
* @since 100.0.2
2021
*/
2122
class Image extends AbstractHelper implements ArgumentInterface
2223
{
2324
/**
2425
* Media config node
2526
*/
26-
const MEDIA_TYPE_CONFIG_NODE = 'images';
27+
public const MEDIA_TYPE_CONFIG_NODE = 'images';
2728

2829
/**
2930
* Current model
@@ -47,8 +48,6 @@ class Image extends AbstractHelper implements ArgumentInterface
4748
protected $_scheduleRotate = false;
4849

4950
/**
50-
* Angle
51-
*
5251
* @var int
5352
*/
5453
protected $_angle;
@@ -61,22 +60,16 @@ class Image extends AbstractHelper implements ArgumentInterface
6160
protected $_watermark;
6261

6362
/**
64-
* Watermark Position
65-
*
6663
* @var string
6764
*/
6865
protected $_watermarkPosition;
6966

7067
/**
71-
* Watermark Size
72-
*
7368
* @var string
7469
*/
7570
protected $_watermarkSize;
7671

7772
/**
78-
* Watermark Image opacity
79-
*
8073
* @var int
8174
*/
8275
protected $_watermarkImageOpacity;
@@ -89,8 +82,6 @@ class Image extends AbstractHelper implements ArgumentInterface
8982
protected $_product;
9083

9184
/**
92-
* Image File
93-
*
9485
* @var string
9586
*/
9687
protected $_imageFile;
@@ -108,8 +99,6 @@ class Image extends AbstractHelper implements ArgumentInterface
10899
protected $_assetRepo;
109100

110101
/**
111-
* Product image factory
112-
*
113102
* @var \Magento\Catalog\Model\Product\ImageFactory
114103
*/
115104
protected $_productImageFactory;
@@ -787,8 +776,8 @@ protected function getImageFile()
787776
*/
788777
protected function parseSize($string)
789778
{
790-
$size = explode('x', strtolower($string));
791-
if (count($size) == 2) {
779+
$size = $string !== null ? explode('x', strtolower($string)) : [];
780+
if (count($size) === 2) {
792781
return ['width' => $size[0] > 0 ? $size[0] : null, 'height' => $size[1] > 0 ? $size[1] : null];
793782
}
794783
return false;

0 commit comments

Comments
 (0)