Skip to content

Commit 562865a

Browse files
karyna-tandrewbess
authored andcommitted
AC-3108: Fix possible deprecation issues with 8.1
1 parent d74bbf7 commit 562865a

File tree

15 files changed

+65
-59
lines changed

15 files changed

+65
-59
lines changed

app/code/Magento/Directory/Model/Currency.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -509,7 +509,7 @@ public function getOutputFormat()
509509
{
510510
$formatted = $this->formatTxt(0);
511511
$number = $this->formatTxt(0, ['display' => \Magento\Framework\Currency::NO_SYMBOL]);
512-
return str_replace($this->trimUnicodeDirectionMark($number), '%s', $formatted);
512+
return $formatted !== null ? str_replace($this->trimUnicodeDirectionMark($number), '%s', $formatted) : '';
513513
}
514514

515515
/**

app/code/Magento/Directory/Model/CurrencyConfig.php

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -75,10 +75,8 @@ private function getConfigForAllStores(string $path)
7575
{
7676
$storesResult = [];
7777
foreach ($this->storeManager->getStores() as $store) {
78-
$storesResult[] = explode(
79-
',',
80-
$this->config->getValue($path, ScopeInterface::SCOPE_STORE, $store->getCode())
81-
);
78+
$value = $this->config->getValue($path, ScopeInterface::SCOPE_STORE, $store->getCode());
79+
$storesResult[] = $value !== null ? explode(',', $value) : [];
8280
}
8381

8482
return array_merge([], ...$storesResult);
@@ -94,6 +92,7 @@ private function getConfigForCurrentStore(string $path)
9492
{
9593
$store = $this->storeManager->getStore();
9694

97-
return explode(',', $this->config->getValue($path, ScopeInterface::SCOPE_STORE, $store->getCode()));
95+
$value = $this->config->getValue($path, ScopeInterface::SCOPE_STORE, $store->getCode());
96+
return $value !== null ? explode(',', $value) : [];
9897
}
9998
}

app/code/Magento/Email/Model/Template/Filter.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -638,7 +638,7 @@ public function transDirective($construction)
638638
*/
639639
protected function getTransParameters($value)
640640
{
641-
if (preg_match(self::TRANS_DIRECTIVE_REGEX, $value, $matches) !== 1) {
641+
if ($value === null || preg_match(self::TRANS_DIRECTIVE_REGEX, $value, $matches) !== 1) {
642642
return ['', []]; // malformed directive body; return without breaking list
643643
}
644644
// phpcs:disable Magento2.Functions.DiscouragedFunction
@@ -691,7 +691,7 @@ public function varDirective($construction)
691691
*/
692692
protected function explodeModifiers($value, $default = null)
693693
{
694-
$parts = explode('|', $value, 2);
694+
$parts = $value !== null ? explode('|', $value, 2) : [];
695695
if (2 === count($parts)) {
696696
return $parts;
697697
}
@@ -710,7 +710,8 @@ protected function explodeModifiers($value, $default = null)
710710
*/
711711
protected function applyModifiers($value, $modifiers)
712712
{
713-
foreach (explode('|', $modifiers) as $part) {
713+
$modifiersParts = $modifiers !== null ? explode('|', $modifiers) : [];
714+
foreach ($modifiersParts as $part) {
714715
if (empty($part)) {
715716
continue;
716717
}

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,8 @@ public function isMessagesAvailable()
358358
*/
359359
public function isItemMessagesAvailable($item)
360360
{
361-
$type = substr($this->getType(), 0, 5) == 'multi' ? 'address_item' : 'item';
361+
$type = $this->getType() !== null && substr($this->getType(), 0, 5) === 'multi' ?
362+
'address_item' : 'item';
362363
return $this->_giftMessageMessage->isMessagesAllowed($type, $item);
363364
}
364365

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

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@ public function __construct(
5555
}
5656

5757
/**
58+
* Model construct that should be used for object initialization
59+
*
5860
* @return void
5961
*/
6062
protected function _construct()
@@ -80,85 +82,85 @@ public function getEntityModelByType($type)
8082
*/
8183
public function isMessageEmpty()
8284
{
83-
return trim($this->getMessage()) == '';
85+
return $this->getMessage() === null || trim($this->getMessage()) == '';
8486
}
8587

8688
//@codeCoverageIgnoreStart
8789

8890
/**
89-
* {@inheritdoc}
91+
* @inheritdoc
9092
*/
9193
public function getGiftMessageId()
9294
{
9395
return $this->getData(self::GIFT_MESSAGE_ID);
9496
}
9597

9698
/**
97-
* {@inheritdoc}
99+
* @inheritdoc
98100
*/
99101
public function setGiftMessageId($id)
100102
{
101103
return $this->setData(self::GIFT_MESSAGE_ID, $id);
102104
}
103105

104106
/**
105-
* {@inheritdoc}
107+
* @inheritdoc
106108
*/
107109
public function getCustomerId()
108110
{
109111
return $this->getData(self::CUSTOMER_ID);
110112
}
111113

112114
/**
113-
* {@inheritdoc}
115+
* @inheritdoc
114116
*/
115117
public function setCustomerId($id)
116118
{
117119
return $this->setData(self::CUSTOMER_ID, $id);
118120
}
119121

120122
/**
121-
* {@inheritdoc}
123+
* @inheritdoc
122124
*/
123125
public function getSender()
124126
{
125127
return $this->getData(self::SENDER);
126128
}
127129

128130
/**
129-
* {@inheritdoc}
131+
* @inheritdoc
130132
*/
131133
public function setSender($sender)
132134
{
133135
return $this->setData(self::SENDER, $sender);
134136
}
135137

136138
/**
137-
* {@inheritdoc}
139+
* @inheritdoc
138140
*/
139141
public function getRecipient()
140142
{
141143
return $this->getData(self::RECIPIENT);
142144
}
143145

144146
/**
145-
* {@inheritdoc}
147+
* @inheritdoc
146148
*/
147149
public function setRecipient($recipient)
148150
{
149151
return $this->setData(self::RECIPIENT, $recipient);
150152
}
151153

152154
/**
153-
* {@inheritdoc}
155+
* @inheritdoc
154156
*/
155157
public function getMessage()
156158
{
157159
return $this->getData(self::MESSAGE);
158160
}
159161

160162
/**
161-
* {@inheritdoc}
163+
* @inheritdoc
162164
*/
163165
public function setMessage($message)
164166
{

app/code/Magento/GraphQl/Controller/GraphQl.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ public function dispatch(RequestInterface $request): ResponseInterface
205205
$jsonResult->renderResult($this->httpResponse);
206206

207207
// log information about the query, unless it is an introspection query
208-
if (strpos($data['query'], 'IntrospectionQuery') === false) {
208+
if (!isset($data['query']) || strpos($data['query'], 'IntrospectionQuery') === false) {
209209
$queryInformation = $this->logDataHelper->getLogData($request, $data, $schema, $this->httpResponse);
210210
$this->loggerPool->execute($queryInformation);
211211
}

app/code/Magento/GraphQl/Controller/HttpRequestValidator/HttpVerbValidator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public function validate(HttpRequestInterface $request): void
4949
]
5050
);
5151

52-
if (strtolower($operationType) === 'mutation') {
52+
if ($operationType !== null && strtolower($operationType) === 'mutation') {
5353
throw new GraphQlInputException(
5454
new Phrase('Mutation requests allowed only for POST requests')
5555
);

app/code/Magento/GraphQl/Model/Query/Logger/NewRelic.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public function execute(array $queryDetails)
5050
}
5151

5252
$transactionName = $queryDetails[LoggerInterface::OPERATION_NAMES] ?: '';
53-
if (strpos($queryDetails[LoggerInterface::OPERATION_NAMES], ',') !== false) {
53+
if (strpos($transactionName, ',') !== false) {
5454
$transactionName = 'multipleQueries';
5555
}
5656
$this->newRelicWrapper->setTransactionName('GraphQL-' . $transactionName);

app/code/Magento/ImportExport/Controller/Adminhtml/Import/Download.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
*/
2727
class Download extends ImportController implements HttpGetActionInterface
2828
{
29-
const SAMPLE_FILES_MODULE = 'Magento_ImportExport';
29+
public const SAMPLE_FILES_MODULE = 'Magento_ImportExport';
3030

3131
/**
3232
* @var RawFactory
@@ -88,7 +88,7 @@ public function __construct(
8888
*/
8989
public function execute()
9090
{
91-
$entityName = $this->getRequest()->getParam('filename');
91+
$entityName = $this->getRequest()->getParam('filename', '');
9292

9393
if (preg_match('/^\w+$/', $entityName) == 0) {
9494
$this->messageManager->addErrorMessage(__('Incorrect entity name.'));

app/code/Magento/ImportExport/Model/Export/Entity/AbstractEav.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
/**
1515
* Export EAV entity abstract model
1616
*
17+
* phpcs:disable Magento2.Classes.AbstractApi
1718
* @api
1819
*
1920
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
@@ -37,8 +38,6 @@ abstract class AbstractEav extends \Magento\ImportExport\Model\Export\AbstractEn
3738
protected $attributeTypes = [];
3839

3940
/**
40-
* Entity type id.
41-
*
4241
* @var int
4342
*/
4443
protected $_entityTypeId;
@@ -131,6 +130,7 @@ protected function _prepareEntityCollection(AbstractCollection $collection)
131130
* @param AbstractCollection $collection
132131
* @return AbstractCollection
133132
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
133+
* phpcs:disable Generic.Metrics.NestingLevel
134134
*/
135135
public function filterEntityCollection(AbstractCollection $collection)
136136
{
@@ -158,7 +158,7 @@ public function filterEntityCollection(AbstractCollection $collection)
158158
$attributeCode,
159159
['eq' => $exportFilter[$attributeCode]]
160160
);
161-
} else if (is_array($exportFilter[$attributeCode])) {
161+
} elseif (is_array($exportFilter[$attributeCode])) {
162162
$collection->addAttributeToFilter(
163163
$attributeCode,
164164
['in' => $exportFilter[$attributeCode]]
@@ -214,6 +214,7 @@ public function filterEntityCollection(AbstractCollection $collection)
214214
}
215215
return $collection;
216216
}
217+
// phpcs:enable Generic.Metrics.NestingLevel
217218

218219
/**
219220
* Add not skipped attributes to select
@@ -249,12 +250,13 @@ public function getAttributeOptions(AbstractAttribute $attribute)
249250
foreach ($attribute->getSource()->getAllOptions(false) as $option) {
250251
$optionValues = is_array($option['value']) ? $option['value'] : [$option];
251252
foreach ($optionValues as $innerOption) {
252-
if (strlen($innerOption['value'])) {
253+
if (isset($innerOption['value']) && strlen($innerOption['value'])) {
253254
// skip ' -- Please Select -- ' option
254255
$options[$innerOption['value']] = $innerOption[$index];
255256
}
256257
}
257258
}
259+
// phpcs:ignore Magento2.CodeAnalysis.EmptyBlock.DetectedCatch
258260
} catch (\Exception $e) {
259261
// ignore exceptions connected with source models
260262
}

0 commit comments

Comments
 (0)