Skip to content

Commit d553cf9

Browse files
authored
Merge pull request #7331 from magento-trigger/ph-delivery
[Platform Health] PHP 8.1 Updates
2 parents 5ae344e + 5f1933b commit d553cf9

File tree

174 files changed

+21442
-19742
lines changed

Some content is hidden

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

174 files changed

+21442
-19742
lines changed

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

+3-1
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,9 @@ protected function _getValue(DataObject $row)
9797
}
9898
return '';
9999
}
100-
return $row->getData($this->getColumn()->getIndex());
100+
return $this->getColumn()->getIndex() !== null
101+
? $row->getData($this->getColumn()->getIndex())
102+
: null;
101103
}
102104

103105
/**

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

+9-4
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,9 @@ protected function _getCurrencyCode($row)
102102
if ($code = $this->getColumn()->getCurrencyCode()) {
103103
return $code;
104104
}
105-
if ($code = $row->getData($this->getColumn()->getCurrency())) {
105+
$currency = $this->getColumn()->getCurrency();
106+
107+
if ($currency !== null && $code = $row->getData($currency)) {
106108
return $code;
107109
}
108110

@@ -118,11 +120,14 @@ protected function _getCurrencyCode($row)
118120
protected function _getRate($row)
119121
{
120122
if ($rate = $this->getColumn()->getRate()) {
121-
return (float)$rate;
123+
return (float) $rate;
122124
}
123-
if ($rate = $row->getData($this->getColumn()->getRateField())) {
124-
return (float)$rate;
125+
$rateField = $this->getColumn()->getRateField();
126+
127+
if ($rateField !== null && $rate = $row->getData($rateField)) {
128+
return (float) $rate;
125129
}
130+
126131
return $this->_defaultBaseCurrency->getRate($this->_getCurrencyCode($row));
127132
}
128133

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

+9-5
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public function render(\Magento\Framework\DataObject $row)
6060
return $data;
6161
}
6262

63-
$data = (float)$data * $this->_getRate($row);
63+
$data = (float) $data * $this->_getRate($row);
6464
$data = sprintf("%f", $data);
6565
$data = $this->_localeCurrency->getCurrency($currencyCode)->toCurrency($data);
6666
return $data;
@@ -79,7 +79,9 @@ protected function _getCurrencyCode($row)
7979
if ($code = $this->getColumn()->getCurrencyCode()) {
8080
return $code;
8181
}
82-
if ($code = $row->getData($this->getColumn()->getCurrency())) {
82+
$currency = $this->getColumn()->getCurrency();
83+
84+
if ($currency !== null && $code = $row->getData($currency)) {
8385
return $code;
8486
}
8587
return false;
@@ -94,10 +96,12 @@ protected function _getCurrencyCode($row)
9496
protected function _getRate($row)
9597
{
9698
if ($rate = $this->getColumn()->getRate()) {
97-
return (float)$rate;
99+
return (float) $rate;
98100
}
99-
if ($rate = $row->getData($this->getColumn()->getRateField())) {
100-
return (float)$rate;
101+
$rateField = $this->getColumn()->getRateField();
102+
103+
if ($rateField !== null && $rate = $row->getData($rateField)) {
104+
return (float) $rate;
101105
}
102106
return 1;
103107
}

app/code/Magento/CatalogRule/Block/Adminhtml/Promo/Catalog/Edit/Tab/Conditions.php

+11-6
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,15 @@
55
*/
66
namespace Magento\CatalogRule\Block\Adminhtml\Promo\Catalog\Edit\Tab;
77

8-
use Magento\Backend\Block\Widget\Form;
98
use Magento\Backend\Block\Widget\Form\Generic;
9+
use Magento\Backend\Block\Widget\Form\Renderer\Fieldset;
1010
use Magento\Ui\Component\Layout\Tabs\TabInterface;
1111
use Magento\Rule\Model\Condition\AbstractCondition;
1212

1313
class Conditions extends Generic implements TabInterface
1414
{
1515
/**
16-
* @var \Magento\Backend\Block\Widget\Form\Renderer\Fieldset
16+
* @var Fieldset
1717
*/
1818
protected $_rendererFieldset;
1919

@@ -27,15 +27,15 @@ class Conditions extends Generic implements TabInterface
2727
* @param \Magento\Framework\Registry $registry
2828
* @param \Magento\Framework\Data\FormFactory $formFactory
2929
* @param \Magento\Rule\Block\Conditions $conditions
30-
* @param \Magento\Backend\Block\Widget\Form\Renderer\Fieldset $rendererFieldset
30+
* @param Fieldset $rendererFieldset
3131
* @param array $data
3232
*/
3333
public function __construct(
3434
\Magento\Backend\Block\Template\Context $context,
3535
\Magento\Framework\Registry $registry,
3636
\Magento\Framework\Data\FormFactory $formFactory,
3737
\Magento\Rule\Block\Conditions $conditions,
38-
\Magento\Backend\Block\Widget\Form\Renderer\Fieldset $rendererFieldset,
38+
Fieldset $rendererFieldset,
3939
array $data = []
4040
) {
4141
$this->_rendererFieldset = $rendererFieldset;
@@ -121,7 +121,7 @@ public function isAjaxLoaded()
121121
}
122122

123123
/**
124-
* @return Form
124+
* @inheritdoc
125125
*/
126126
protected function _prepareForm()
127127
{
@@ -135,6 +135,8 @@ protected function _prepareForm()
135135
}
136136

137137
/**
138+
* Adds 'Conditions' to the form.
139+
*
138140
* @param \Magento\CatalogRule\Api\Data\RuleInterface $model
139141
* @param string $fieldsetId
140142
* @param string $formName
@@ -154,7 +156,8 @@ protected function addTabToForm($model, $fieldsetId = 'conditions_fieldset', $fo
154156
['form_namespace' => $formName]
155157
);
156158

157-
$renderer = $this->_rendererFieldset->setTemplate('Magento_CatalogRule::promo/fieldset.phtml')
159+
$renderer = $this->getLayout()->createBlock(Fieldset::class);
160+
$renderer->setTemplate('Magento_CatalogRule::promo/fieldset.phtml')
158161
->setNewChildUrl($newChildUrl)
159162
->setFieldSetId($conditionsFieldSetId);
160163

@@ -183,6 +186,8 @@ protected function addTabToForm($model, $fieldsetId = 'conditions_fieldset', $fo
183186
}
184187

185188
/**
189+
* Sets form name for Condition section.
190+
*
186191
* @param AbstractCondition $conditions
187192
* @param string $formName
188193
* @param string $jsFormName

app/code/Magento/CatalogSearch/Model/ResourceModel/Fulltext/Collection.php

+8-9
Original file line numberDiff line numberDiff line change
@@ -177,8 +177,8 @@ public function __construct(
177177
TotalRecordsResolverFactory $totalRecordsResolverFactory = null,
178178
DefaultFilterStrategyApplyCheckerInterface $defaultFilterStrategyApplyChecker = null
179179
) {
180-
$this->searchResultFactory = $searchResultFactory ?? \Magento\Framework\App\ObjectManager::getInstance()
181-
->get(\Magento\Framework\Api\Search\SearchResultFactory::class);
180+
$this->searchResultFactory = $searchResultFactory
181+
?? ObjectManager::getInstance()->get(SearchResultFactory::class);
182182
parent::__construct(
183183
$entityFactory,
184184
$logger,
@@ -368,13 +368,12 @@ public function _loadEntities($printQuery = false, $logQuery = false)
368368
$this->getEntity();
369369

370370
$this->printLogQuery($printQuery, $logQuery);
371-
371+
/**
372+
* Prepare select query
373+
* @var string $query
374+
*/
375+
$query = $this->getSelect();
372376
try {
373-
/**
374-
* Prepare select query
375-
* @var string $query
376-
*/
377-
$query = $this->getSelect();
378377
$rows = $this->_fetchAll($query);
379378
} catch (\Exception $e) {
380379
$this->printLogQuery(false, true, $query);
@@ -455,7 +454,7 @@ protected function _renderFiltersBefore()
455454
}
456455

457456
if ($this->searchRequestName !== 'quick_search_container'
458-
|| strlen(trim($this->queryText))
457+
|| ($this->queryText && strlen(trim($this->queryText)))
459458
) {
460459
$this->prepareSearchTermFilter();
461460
$this->preparePriceAggregation();

app/code/Magento/Checkout/view/frontend/web/template/minicart/item/default.html

+2-2
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
<dt class="label"><!-- ko text: option.label --><!-- /ko --></dt>
4343
<dd class="values">
4444
<!-- ko if: Array.isArray(option.value) -->
45-
<span data-bind="html: $parents[1].getOptionValueUnsanitizedHtml(option.value.join('<br/>'))"></span>
45+
<span data-bind="html: $parents[1].getOptionValueUnsanitizedHtml(option.value.join('<br>'))"></span>
4646
<!-- /ko -->
4747
<!-- ko if: (!Array.isArray(option.value) && ['file', 'html'].includes(option.option_type)) -->
4848
<span data-bind="html: $parents[1].getOptionValueUnsanitizedHtml(option.value)"></span>
@@ -83,7 +83,7 @@
8383
type="number"
8484
size="4"
8585
class="item-qty cart-item-qty"/>
86-
<button data-bind="attr: {
86+
<button data-bind="attr: {
8787
id: 'update-cart-item-'+item_id,
8888
'data-cart-item': item_id,
8989
title: $t('Update')

app/code/Magento/Config/Console/Command/ConfigShowCommand.php

+8-5
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,14 @@ class ConfigShowCommand extends Command
3131
/**#@+
3232
* Names of input arguments or options.
3333
*/
34-
const INPUT_OPTION_SCOPE = 'scope';
35-
const INPUT_OPTION_SCOPE_CODE = 'scope-code';
36-
const INPUT_ARGUMENT_PATH = 'path';
34+
public const INPUT_OPTION_SCOPE = 'scope';
35+
public const INPUT_OPTION_SCOPE_CODE = 'scope-code';
36+
public const INPUT_ARGUMENT_PATH = 'path';
3737
/**#@-*/
3838

39-
/**#@-*/
39+
/**
40+
* @var ValidatorInterface
41+
*/
4042
private $scopeValidator;
4143

4244
/**
@@ -165,7 +167,8 @@ protected function execute(InputInterface $input, OutputInterface $output)
165167
try {
166168
$this->scope = $input->getOption(self::INPUT_OPTION_SCOPE);
167169
$this->scopeCode = $input->getOption(self::INPUT_OPTION_SCOPE_CODE);
168-
$this->inputPath = trim($input->getArgument(self::INPUT_ARGUMENT_PATH), '/');
170+
$inputPath = $input->getArgument(self::INPUT_ARGUMENT_PATH);
171+
$this->inputPath = $inputPath !== null ? trim($inputPath, '/') : '';
169172

170173
$configValue = $this->emulatedAreaProcessor->process(function () {
171174
$this->scopeValidator->isValid($this->scope, $this->scopeCode);

app/code/Magento/Cron/Model/Config/Converter/Db.php

+3-2
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public function convert($source)
2929
/**
3030
* Extract and prepare cron job data
3131
*
32-
* @param array $jobs
32+
* @param array $cronTab
3333
* @return array
3434
*/
3535
protected function _extractParams(array $cronTab)
@@ -92,7 +92,8 @@ protected function _processScheduleParam(array $jobConfig, $jobName, array &$res
9292
protected function _processRunModel(array $jobConfig, $jobName, array &$result)
9393
{
9494
if (isset($jobConfig['run']) && is_array($jobConfig['run']) && array_key_exists('model', $jobConfig['run'])) {
95-
$callPath = explode('::', $jobConfig['run']['model']);
95+
$runModel = $jobConfig['run']['model'];
96+
$callPath = $runModel ? explode('::', $runModel) : [];
9697

9798
if (empty($callPath) || empty($callPath[0]) || empty($callPath[1])) {
9899
unset($result[$jobName]['run']);

app/code/Magento/CurrencySymbol/Block/Adminhtml/System/Currency/Rate/Matrix.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ protected function _prepareRates($array)
107107

108108
foreach ($array as $key => $rate) {
109109
foreach ($rate as $code => $value) {
110-
$parts = explode('.', $value);
110+
$parts = $value !== null ? explode('.', $value) : [];
111111
if (count($parts) == 2) {
112112
$parts[1] = str_pad(rtrim($parts[1], 0), 4, '0', STR_PAD_RIGHT);
113113
$array[$key][$code] = join('.', $parts);

app/code/Magento/GiftMessage/Block/Message/Inline.php

+2-3
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,6 @@ class Inline extends \Magento\Framework\View\Element\Template
3636
protected $_template = 'Magento_GiftMessage::inline.phtml';
3737

3838
/**
39-
* Gift message message
40-
*
4139
* @var \Magento\GiftMessage\Helper\Message|null
4240
*/
4341
protected $_giftMessageMessage = null;
@@ -324,7 +322,8 @@ public function getEntityHasMessage()
324322
*/
325323
public function getEscaped($value, $defaultValue = '')
326324
{
327-
return $this->escapeHtml(trim($value) != '' ? $value : $defaultValue);
325+
$value = ($value !== null && trim($value) != '') ? $value : $defaultValue;
326+
return $this->escapeHtml($value);
328327
}
329328

330329
/**

app/code/Magento/GiftMessage/Model/GiftMessageManager.php

+6-1
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,13 @@ public function __construct(
2525
}
2626

2727
/**
28+
* Save gift message information.
29+
*
2830
* @param array $giftMessages
2931
* @param \Magento\Quote\Model\Quote $quote
3032
* @return $this
3133
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
34+
* @SuppressWarnings(PHPMD.NPathComplexity)
3235
*/
3336
public function add($giftMessages, $quote)
3437
{
@@ -61,11 +64,12 @@ public function add($giftMessages, $quote)
6164
$giftMessage->load($entity->getGiftMessageId());
6265
}
6366

64-
if (trim($message['message']) == '') {
67+
if ($message['message'] === null || trim($message['message']) == '') {
6568
if ($giftMessage->getId()) {
6669
try {
6770
$giftMessage->delete();
6871
$entity->setGiftMessageId(0)->save();
72+
// phpcs:ignore Magento2.CodeAnalysis.EmptyBlock.DetectedCatch
6973
} catch (\Exception $e) {
7074
}
7175
}
@@ -84,6 +88,7 @@ public function add($giftMessages, $quote)
8488
)->save();
8589

8690
$entity->setGiftMessageId($giftMessage->getId())->save();
91+
// phpcs:ignore Magento2.CodeAnalysis.EmptyBlock.DetectedCatch
8792
} catch (\Exception $e) {
8893
}
8994
}

0 commit comments

Comments
 (0)