Skip to content

Commit 587d385

Browse files
author
Stanislav Idolov
authored
ENGCOM-2932: [Forwardport] Clean code #17765
2 parents 1ce48cf + e4de37c commit 587d385

File tree

30 files changed

+39
-46
lines changed

30 files changed

+39
-46
lines changed

app/code/Magento/Analytics/ReportXml/ReportProvider.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ public function __construct(
5555
private function getIteratorName(Query $query)
5656
{
5757
$config = $query->getConfig();
58-
return isset($config['iterator']) ? $config['iterator'] : null;
58+
return $config['iterator'] ?? null;
5959
}
6060

6161
/**

app/code/Magento/Backend/App/DefaultPath.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,6 @@ public function __construct(\Magento\Backend\App\ConfigInterface $config)
4242
*/
4343
public function getPart($code)
4444
{
45-
return isset($this->_parts[$code]) ? $this->_parts[$code] : null;
45+
return $this->_parts[$code] ?? null;
4646
}
4747
}

app/code/Magento/Backend/Model/Menu/Builder.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,6 @@ public function getResult(\Magento\Backend\Model\Menu $menu)
102102
*/
103103
protected function _getParam($params, $paramName, $defaultValue = null)
104104
{
105-
return isset($params[$paramName]) ? $params[$paramName] : $defaultValue;
105+
return $params[$paramName] ?? $defaultValue;
106106
}
107107
}

app/code/Magento/Backup/Helper/Data.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ public function getBackupsDir()
110110
public function getExtensionByType($type)
111111
{
112112
$extensions = $this->getExtensions();
113-
return isset($extensions[$type]) ? $extensions[$type] : '';
113+
return $extensions[$type] ?? '';
114114
}
115115

116116
/**

app/code/Magento/BundleImportExport/Model/Export/RowCustomizer.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,7 @@ function ($title, $storeName) {
322322
*/
323323
protected function getTypeValue($type)
324324
{
325-
return isset($this->typeMapping[$type]) ? $this->typeMapping[$type] : self::VALUE_DYNAMIC;
325+
return $this->typeMapping[$type] ?? self::VALUE_DYNAMIC;
326326
}
327327

328328
/**
@@ -333,7 +333,7 @@ protected function getTypeValue($type)
333333
*/
334334
protected function getPriceViewValue($type)
335335
{
336-
return isset($this->priceViewMapping[$type]) ? $this->priceViewMapping[$type] : self::VALUE_PRICE_RANGE;
336+
return $this->priceViewMapping[$type] ?? self::VALUE_PRICE_RANGE;
337337
}
338338

339339
/**
@@ -344,7 +344,7 @@ protected function getPriceViewValue($type)
344344
*/
345345
protected function getPriceTypeValue($type)
346346
{
347-
return isset($this->priceTypeMapping[$type]) ? $this->priceTypeMapping[$type] : null;
347+
return $this->priceTypeMapping[$type] ?? null;
348348
}
349349

350350
/**
@@ -355,7 +355,7 @@ protected function getPriceTypeValue($type)
355355
*/
356356
private function getShipmentTypeValue($type)
357357
{
358-
return isset($this->shipmentTypeMapping[$type]) ? $this->shipmentTypeMapping[$type] : null;
358+
return $this->shipmentTypeMapping[$type] ?? null;
359359
}
360360

361361
/**

app/code/Magento/Captcha/Observer/CaptchaStringResolver.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,6 @@ public function resolve(\Magento\Framework\App\RequestInterface $request, $formI
1818
{
1919
$captchaParams = $request->getPost(\Magento\Captcha\Helper\Data::INPUT_NAME_FIELD_VALUE);
2020

21-
return isset($captchaParams[$formId]) ? $captchaParams[$formId] : '';
21+
return $captchaParams[$formId] ?? '';
2222
}
2323
}

app/code/Magento/Catalog/Block/Product/View/Gallery.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ public function getImageAttribute($imageId, $attributeName, $default = null)
205205
{
206206
$attributes =
207207
$this->getConfigView()->getMediaAttributes('Magento_Catalog', Image::MEDIA_TYPE_CONFIG_NODE, $imageId);
208-
return isset($attributes[$attributeName]) ? $attributes[$attributeName] : $default;
208+
return $attributes[$attributeName] ?? $default;
209209
}
210210

211211
/**

app/code/Magento/Catalog/Cron/FrontendActionsFlush.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,7 @@ private function getLifeTimeByNamespace($namespace)
5757
];
5858
}
5959

60-
return isset($configuration['lifetime']) ?
61-
(int) $configuration['lifetime'] : FrontendStorageConfigurationInterface::DEFAULT_LIFETIME;
60+
return (int)$configuration['lifetime'] ?? FrontendStorageConfigurationInterface::DEFAULT_LIFETIME;
6261
}
6362

6463
/**

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -859,7 +859,7 @@ public function getFrame()
859859
*/
860860
protected function getAttribute($name)
861861
{
862-
return isset($this->attributes[$name]) ? $this->attributes[$name] : null;
862+
return $this->attributes[$name] ?? null;
863863
}
864864

865865
/**

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ public function addHandler($method, $handler)
116116
public function getHandlers($method)
117117
{
118118
$method = strtolower($method);
119-
return isset($this->_handlers[$method]) ? $this->_handlers[$method] : [];
119+
return $this->_handlers[$method] ?? [];
120120
}
121121

122122
/**

app/code/Magento/Catalog/Model/Api/SearchCriteria/CollectionProcessor/ConditionProcessor/ConditionBuilder/NativeAttributeCondition.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ private function mapConditionType(string $conditionType, string $field): string
7777
];
7878
}
7979

80-
return isset($conditionsMap[$conditionType]) ? $conditionsMap[$conditionType] : $conditionType;
80+
return $conditionsMap[$conditionType] ?? $conditionType;
8181
}
8282

8383
/**

app/code/Magento/Catalog/Model/Config.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -381,7 +381,7 @@ public function getProductTypeName($id)
381381

382382
$this->loadProductTypes();
383383

384-
return isset($this->_productTypesById[$id]) ? $this->_productTypesById[$id] : false;
384+
return $this->_productTypesById[$id] ?? false;
385385
}
386386

387387
/**

app/code/Magento/Catalog/Model/Product/Option.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,7 @@ public function getGroupByType($type = null)
323323
self::OPTION_TYPE_TIME => self::OPTION_GROUP_DATE,
324324
];
325325

326-
return isset($optionGroupsToTypes[$type]) ? $optionGroupsToTypes[$type] : '';
326+
return $optionGroupsToTypes[$type] ?? '';
327327
}
328328

329329
/**

app/code/Magento/Catalog/Model/Product/Option/Type/DefaultType.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,7 @@ public function getFormattedOptionValue($optionValue)
279279
*/
280280
public function getCustomizedView($optionInfo)
281281
{
282-
return isset($optionInfo['value']) ? $optionInfo['value'] : $optionInfo;
282+
return $optionInfo['value'] ?? $optionInfo;
283283
}
284284

285285
/**

app/code/Magento/Catalog/Model/Product/Option/Validator/Pool.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,6 @@ public function __construct(array $validators)
2929
*/
3030
public function get($type)
3131
{
32-
return isset($this->validators[$type]) ? $this->validators[$type] : $this->validators['default'];
32+
return $this->validators[$type] ?? $this->validators['default'];
3333
}
3434
}

app/code/Magento/Catalog/Model/Product/Type.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ public function getOptions()
232232
public function getOptionText($optionId)
233233
{
234234
$options = $this->getOptionArray();
235-
return isset($options[$optionId]) ? $options[$optionId] : null;
235+
return $options[$optionId] ?? null;
236236
}
237237

238238
/**

app/code/Magento/Catalog/Ui/Component/FilterFactory.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,6 @@ public function create($attribute, $context, $config = [])
7171
*/
7272
protected function getFilterType($attribute)
7373
{
74-
return isset($this->filterMap[$attribute->getFrontendInput()])
75-
? $this->filterMap[$attribute->getFrontendInput()]
76-
: $this->filterMap['default'];
74+
return $this->filterMap[$attribute->getFrontendInput()] ?? $this->filterMap['default'];
7775
}
7876
}

app/code/Magento/Catalog/Ui/Component/Listing/Columns.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,6 @@ public function prepare()
8080
*/
8181
protected function getFilterType($frontendInput)
8282
{
83-
return isset($this->filterMap[$frontendInput]) ? $this->filterMap[$frontendInput] : $this->filterMap['default'];
83+
return $this->filterMap[$frontendInput] ?? $this->filterMap['default'];
8484
}
8585
}

app/code/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/Eav.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -890,7 +890,7 @@ private function getFormElementsMapValue($value)
890890
{
891891
$valueMap = $this->formElementMapper->getMappings();
892892

893-
return isset($valueMap[$value]) ? $valueMap[$value] : $value;
893+
return $valueMap[$value] ?? $value;
894894
}
895895

896896
/**

app/code/Magento/CatalogImportExport/Model/Import/Product/CategoryProcessor.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ public function clearFailedCategories()
234234
*/
235235
public function getCategoryById($categoryId)
236236
{
237-
return isset($this->categoriesCache[$categoryId]) ? $this->categoriesCache[$categoryId] : null;
237+
return $this->categoriesCache[$categoryId] ?? null;
238238
}
239239

240240
/**

app/code/Magento/CatalogImportExport/Model/Import/Product/SkuProcessor.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ public function getNewSku($sku = null)
142142
{
143143
if ($sku !== null) {
144144
$sku = strtolower($sku);
145-
return isset($this->newSkus[$sku]) ? $this->newSkus[$sku] : null;
145+
return $this->newSkus[$sku] ?? null;
146146
}
147147
return $this->newSkus;
148148
}

app/code/Magento/CatalogImportExport/Model/Import/Product/StoreResolver.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ public function getWebsiteCodeToId($code = null)
7575
$this->_initWebsites();
7676
}
7777
if ($code) {
78-
return isset($this->websiteCodeToId[$code]) ? $this->websiteCodeToId[$code] : null;
78+
return $this->websiteCodeToId[$code] ?? null;
7979
}
8080
return $this->websiteCodeToId;
8181
}
@@ -90,7 +90,7 @@ public function getWebsiteCodeToStoreIds($code = null)
9090
$this->_initWebsites();
9191
}
9292
if ($code) {
93-
return isset($this->websiteCodeToStoreIds[$code]) ? $this->websiteCodeToStoreIds[$code] : null;
93+
return $this->websiteCodeToStoreIds[$code] ?? null;
9494
}
9595
return $this->websiteCodeToStoreIds;
9696
}
@@ -119,7 +119,7 @@ public function getStoreCodeToId($code = null)
119119
$this->_initStores();
120120
}
121121
if ($code) {
122-
return isset($this->storeCodeToId[$code]) ? $this->storeCodeToId[$code] : null;
122+
return $this->storeCodeToId[$code] ?? null;
123123
}
124124
return $this->storeCodeToId;
125125
}
@@ -134,7 +134,7 @@ public function getStoreIdToWebsiteStoreIds($code = null)
134134
$this->_initStores();
135135
}
136136
if ($code) {
137-
return isset($this->storeIdToWebsiteStoreIds[$code]) ? $this->storeIdToWebsiteStoreIds[$code] : null;
137+
return $this->storeIdToWebsiteStoreIds[$code] ?? null;
138138
}
139139
return $this->storeIdToWebsiteStoreIds;
140140
}

app/code/Magento/CatalogInventory/Block/Adminhtml/Form/Field/Customergroup.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ protected function _getCustomerGroups($groupId = null)
8484
$this->_customerGroups[$notLoggedInGroup->getId()] = $notLoggedInGroup->getCode();
8585
}
8686
if ($groupId !== null) {
87-
return isset($this->_customerGroups[$groupId]) ? $this->_customerGroups[$groupId] : null;
87+
return $this->_customerGroups[$groupId] ?? null;
8888
}
8989
return $this->_customerGroups;
9090
}

app/code/Magento/CatalogInventory/Model/StockRegistryStorage.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ public function removeStock($scopeId = null)
6868
*/
6969
public function getStockItem($productId, $scopeId)
7070
{
71-
return isset($this->stockItems[$productId][$scopeId]) ? $this->stockItems[$productId][$scopeId] : null;
71+
return $this->stockItems[$productId][$scopeId] ?? null;
7272
}
7373

7474
/**
@@ -103,7 +103,7 @@ public function removeStockItem($productId, $scopeId = null)
103103
*/
104104
public function getStockStatus($productId, $scopeId)
105105
{
106-
return isset($this->stockStatuses[$productId][$scopeId]) ? $this->stockStatuses[$productId][$scopeId] : null;
106+
return $this->stockStatuses[$productId][$scopeId] ?? null;
107107
}
108108

109109
/**

app/code/Magento/CatalogRule/Observer/RulePricesStorage.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class RulePricesStorage
2222
*/
2323
public function getRulePrice($id)
2424
{
25-
return isset($this->rulePrices[$id]) ? $this->rulePrices[$id] : false;
25+
return $this->rulePrices[$id] ?? false;
2626
}
2727

2828
/**

lib/internal/Magento/Framework/DataObject/Copy/Config.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,6 @@ public function getFieldset($name, $root = 'global')
4444
if (empty($fieldsets)) {
4545
return null;
4646
}
47-
return isset($fieldsets[$name]) ? $fieldsets[$name] : null;
47+
return $fieldsets[$name] ?? null;
4848
}
4949
}

lib/internal/Magento/Framework/View/Page/Config/Structure.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,6 @@ public function populateWithArray(array $data)
251251
*/
252252
private function getArrayValueByKey($key, array $array)
253253
{
254-
return isset($array[$key]) ? $array[$key] : [];
254+
return $array[$key] ?? [];
255255
}
256256
}

lib/internal/Magento/Framework/View/TemplateEngine/Xhtml/Compiler.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ public function postprocessing($content)
122122
return preg_replace_callback(
123123
'#' . $patternTag . '(.+?)' . $patternTag . '#',
124124
function ($match) {
125-
return isset($this->data[$match[1]]) ? $this->data[$match[1]] : '';
125+
return $this->data[$match[1]] ?? '';
126126
},
127127
$content
128128
);

setup/src/Magento/Setup/Fixtures/ImagesFixture.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -417,7 +417,7 @@ private function getImagesToGenerate()
417417
{
418418
$config = $this->fixtureModel->getValue('product-images', []);
419419

420-
return isset($config['images-count']) ? $config['images-count'] : null;
420+
return $config['images-count'] ?? null;
421421
}
422422

423423
/**
@@ -429,7 +429,7 @@ private function getImagesPerProduct()
429429
{
430430
$config = $this->fixtureModel->getValue('product-images', []);
431431

432-
return isset($config['images-per-product']) ? $config['images-per-product'] : null;
432+
return $config['images-per-product'] ?? null;
433433
}
434434

435435
/**

setup/src/Magento/Setup/Module/Setup/SetupCache.php

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,9 @@ public function setField($table, $parentId, $rowId, $field, $value)
4141
public function get($table, $parentId, $rowId, $field = null)
4242
{
4343
if (null === $field) {
44-
return isset($this->data[$table][$parentId][$rowId]) ?
45-
$this->data[$table][$parentId][$rowId] :
46-
false;
44+
return $this->data[$table][$parentId][$rowId] ?? false;
4745
} else {
48-
return isset($this->data[$table][$parentId][$rowId][$field]) ?
49-
$this->data[$table][$parentId][$rowId][$field] :
50-
false;
46+
return $this->data[$table][$parentId][$rowId][$field] ?? false;
5147
}
5248
}
5349

0 commit comments

Comments
 (0)