Skip to content

Commit c930f86

Browse files
author
Stanislav Idolov
authored
ENGCOM-2640: [Forwardport] Code cleanup of lib files #17329
2 parents d4e92fc + 58a9786 commit c930f86

Some content is hidden

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

49 files changed

+68
-86
lines changed

lib/internal/Magento/Framework/Api/AbstractExtensibleObject.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ public function getCustomAttribute($attributeCode)
7676
*/
7777
public function getCustomAttributes()
7878
{
79-
return isset($this->_data[self::CUSTOM_ATTRIBUTES]) ? $this->_data[self::CUSTOM_ATTRIBUTES] : [];
79+
return $this->_data[self::CUSTOM_ATTRIBUTES] ?? [];
8080
}
8181

8282
/**
@@ -131,7 +131,7 @@ public function setCustomAttribute($attributeCode, $attributeValue)
131131
*/
132132
protected function getCustomAttributesCodes()
133133
{
134-
return isset($this->customAttributesCodes) ? $this->customAttributesCodes : [];
134+
return $this->customAttributesCodes ?? [];
135135
}
136136

137137
/**

lib/internal/Magento/Framework/Api/AbstractSimpleObject.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public function __construct(array $data = [])
3434
*/
3535
protected function _get($key)
3636
{
37-
return isset($this->_data[$key]) ? $this->_data[$key] : null;
37+
return $this->_data[$key] ?? null;
3838
}
3939

4040
/**

lib/internal/Magento/Framework/Api/ImageProcessor.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ public function processImageContent($entityType, $imageContent)
172172
*/
173173
protected function getMimeTypeExtension($mimeType)
174174
{
175-
return isset($this->mimeTypeExtensionMap[$mimeType]) ? $this->mimeTypeExtensionMap[$mimeType] : '';
175+
return $this->mimeTypeExtensionMap[$mimeType] ?? '';
176176
}
177177

178178
/**

lib/internal/Magento/Framework/Api/Search/Document.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,7 @@ public function setId($id)
3333
*/
3434
public function getCustomAttribute($attributeCode)
3535
{
36-
return isset($this->_data[self::CUSTOM_ATTRIBUTES][$attributeCode])
37-
? $this->_data[self::CUSTOM_ATTRIBUTES][$attributeCode]
38-
: null;
36+
return $this->_data[self::CUSTOM_ATTRIBUTES][$attributeCode] ?? null;
3937
}
4038

4139
/**

lib/internal/Magento/Framework/Api/SearchCriteria/CollectionProcessor/FilterProcessor.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,6 @@ private function getCustomFilterForField($field)
123123
*/
124124
private function getFieldMapping($field)
125125
{
126-
return isset($this->fieldMapping[$field]) ? $this->fieldMapping[$field] : $field;
126+
return $this->fieldMapping[$field] ?? $field;
127127
}
128128
}

lib/internal/Magento/Framework/Api/SearchCriteria/CollectionProcessor/JoinProcessor.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,6 @@ private function getCustomJoin($field)
121121
*/
122122
private function getFieldMapping($field)
123123
{
124-
return isset($this->fieldMapping[$field]) ? $this->fieldMapping[$field] : $field;
124+
return $this->fieldMapping[$field] ?? $field;
125125
}
126126
}

lib/internal/Magento/Framework/Api/SearchCriteria/CollectionProcessor/SortingProcessor.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ public function process(SearchCriteriaInterface $searchCriteria, AbstractDb $col
5959
*/
6060
private function getFieldMapping($field)
6161
{
62-
return isset($this->fieldMapping[$field]) ? $this->fieldMapping[$field] : $field;
62+
return $this->fieldMapping[$field] ?? $field;
6363
}
6464

6565
/**

lib/internal/Magento/Framework/App/ActionFlag.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,7 @@ public function get($action, $flag = '')
6565
$action = $this->_request->getActionName();
6666
}
6767
if ('' === $flag) {
68-
return isset(
69-
$this->_flags[$this->_getControllerKey()]
70-
) ? $this->_flags[$this->_getControllerKey()] : [];
68+
return $this->_flags[$this->_getControllerKey()] ?? [];
7169
} elseif (isset($this->_flags[$this->_getControllerKey()][$action][$flag])) {
7270
return $this->_flags[$this->_getControllerKey()][$action][$flag];
7371
} else {

lib/internal/Magento/Framework/App/AreaList.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ public function getCodeByFrontName($frontName)
8888
*/
8989
public function getFrontName($areaCode)
9090
{
91-
return isset($this->_areas[$areaCode]['frontName']) ? $this->_areas[$areaCode]['frontName'] : null;
91+
return $this->_areas[$areaCode]['frontName'] ?? null;
9292
}
9393

9494
/**
@@ -111,7 +111,7 @@ public function getCodes()
111111
*/
112112
public function getDefaultRouter($areaCode)
113113
{
114-
return isset($this->_areas[$areaCode]['router']) ? $this->_areas[$areaCode]['router'] : null;
114+
return $this->_areas[$areaCode]['router'] ?? null;
115115
}
116116

117117
/**

lib/internal/Magento/Framework/App/Config/Initial.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,9 @@ public function getData($scope)
7272
list($scopeType, $scopeCode) = array_pad(explode('|', $scope), 2, null);
7373

7474
if (ScopeConfigInterface::SCOPE_TYPE_DEFAULT == $scopeType) {
75-
return isset($this->_data[$scopeType]) ? $this->_data[$scopeType] : [];
75+
return $this->_data[$scopeType] ?? [];
7676
} elseif ($scopeCode) {
77-
return isset($this->_data[$scopeType][$scopeCode]) ? $this->_data[$scopeType][$scopeCode] : [];
77+
return $this->_data[$scopeType][$scopeCode] ?? [];
7878
}
7979
return [];
8080
}

lib/internal/Magento/Framework/App/DefaultPath/DefaultPath.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,6 @@ public function __construct(array $parts)
3232
*/
3333
public function getPart($code)
3434
{
35-
return isset($this->_parts[$code]) ? $this->_parts[$code] : null;
35+
return $this->_parts[$code] ?? null;
3636
}
3737
}

lib/internal/Magento/Framework/App/DeploymentConfig.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ public function get($key = null, $defaultValue = null)
7070
if ($key === null) {
7171
return $this->flatData;
7272
}
73-
return isset($this->flatData[$key]) ? $this->flatData[$key] : $defaultValue;
73+
return $this->flatData[$key] ?? $defaultValue;
7474
}
7575

7676
/**

lib/internal/Magento/Framework/App/Http/Context.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,9 +84,7 @@ public function unsValue($name)
8484
*/
8585
public function getValue($name)
8686
{
87-
return isset($this->data[$name])
88-
? $this->data[$name]
89-
: (isset($this->default[$name]) ? $this->default[$name] : null);
87+
return $this->data[$name] ?? ($this->default[$name] ?? null);
9088
}
9189

9290
/**

lib/internal/Magento/Framework/Component/ComponentRegistrar.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ public function getPaths($type)
7070
public function getPath($type, $componentName)
7171
{
7272
self::validateType($type);
73-
return isset(self::$paths[$type][$componentName]) ? self::$paths[$type][$componentName] : null;
73+
return self::$paths[$type][$componentName] ?? null;
7474
}
7575

7676
/**

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

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ public function __construct(
7171
public function getVars($module)
7272
{
7373
$this->initData();
74-
return isset($this->data['vars'][$module]) ? $this->data['vars'][$module] : [];
74+
return $this->data['vars'][$module] ?? [];
7575
}
7676

7777
/**
@@ -110,7 +110,7 @@ public function getVarValue($module, $var)
110110
public function getMediaEntities($module, $mediaType)
111111
{
112112
$this->initData();
113-
return isset($this->data['media'][$module][$mediaType]) ? $this->data['media'][$module][$mediaType] : [];
113+
return $this->data['media'][$module][$mediaType] ?? [];
114114
}
115115

116116
/**
@@ -124,9 +124,7 @@ public function getMediaEntities($module, $mediaType)
124124
public function getMediaAttributes($module, $mediaType, $mediaId)
125125
{
126126
$this->initData();
127-
return isset($this->data['media'][$module][$mediaType][$mediaId])
128-
? $this->data['media'][$module][$mediaType][$mediaId]
129-
: [];
127+
return $this->data['media'][$module][$mediaType][$mediaId] ?? [];
130128
}
131129

132130
/**
@@ -163,7 +161,7 @@ protected function getIdAttributes()
163161
public function getExcludedFiles()
164162
{
165163
$items = $this->getItems();
166-
return isset($items['file']) ? $items['file'] : [];
164+
return $items['file'] ?? [];
167165
}
168166

169167
/**
@@ -174,7 +172,7 @@ public function getExcludedFiles()
174172
public function getExcludedDir()
175173
{
176174
$items = $this->getItems();
177-
return isset($items['directory']) ? $items['directory'] : [];
175+
return $items['directory'] ?? [];
178176
}
179177

180178
/**
@@ -185,7 +183,7 @@ public function getExcludedDir()
185183
protected function getItems()
186184
{
187185
$this->initData();
188-
return isset($this->data['exclude']) ? $this->data['exclude'] : [];
186+
return $this->data['exclude'] ?? [];
189187
}
190188

191189
/**

lib/internal/Magento/Framework/DB/Adapter/Pdo/Mysql.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -490,7 +490,7 @@ public function rawFetchRow($sql, $field = null)
490490
if (empty($field)) {
491491
return $row;
492492
} else {
493-
return isset($row[$field]) ? $row[$field] : false;
493+
return $row[$field] ?? false;
494494
}
495495
}
496496

lib/internal/Magento/Framework/Data/AbstractCriteria.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ public function getLimit()
274274
*/
275275
public function getPart($name, $default = null)
276276
{
277-
return isset($this->data[$name]) ? $this->data[$name] : $default;
277+
return $this->data[$name] ?? $default;
278278
}
279279

280280
/**

lib/internal/Magento/Framework/Data/AbstractDataObject.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,6 @@ public function toArray()
5050
*/
5151
protected function get($key)
5252
{
53-
return isset($this->data[$key]) ? $this->data[$key] : null;
53+
return $this->data[$key] ?? null;
5454
}
5555
}

lib/internal/Magento/Framework/Data/Collection.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -851,7 +851,7 @@ public function count()
851851
*/
852852
public function getFlag($flag)
853853
{
854-
return isset($this->_flags[$flag]) ? $this->_flags[$flag] : null;
854+
return $this->_flags[$flag] ?? null;
855855
}
856856

857857
/**

lib/internal/Magento/Framework/Data/Structure.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ public function createElement($elementId, array $data)
172172
*/
173173
public function getElement($elementId)
174174
{
175-
return isset($this->_elements[$elementId]) ? $this->_elements[$elementId] : false;
175+
return $this->_elements[$elementId] ?? false;
176176
}
177177

178178
/**
@@ -466,9 +466,7 @@ public function getChildId($parentId, $alias)
466466
*/
467467
public function getChildren($parentId)
468468
{
469-
return isset(
470-
$this->_elements[$parentId][self::CHILDREN]
471-
) ? $this->_elements[$parentId][self::CHILDREN] : [];
469+
return $this->_elements[$parentId][self::CHILDREN] ?? [];
472470
}
473471

474472
/**
@@ -479,7 +477,7 @@ public function getChildren($parentId)
479477
*/
480478
public function getParentId($childId)
481479
{
482-
return isset($this->_elements[$childId][self::PARENT]) ? $this->_elements[$childId][self::PARENT] : false;
480+
return $this->_elements[$childId][self::PARENT] ?? false;
483481
}
484482

485483
/**

lib/internal/Magento/Framework/Event.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ public function dispatch()
8888
*/
8989
public function getName()
9090
{
91-
return isset($this->_data['name']) ? $this->_data['name'] : null;
91+
return $this->_data['name'] ?? null;
9292
}
9393

9494
/**

lib/internal/Magento/Framework/Filesystem/Io/File.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ public function streamStat($part = null, $default = null)
233233
}
234234
$stat = @fstat($this->_streamHandler);
235235
if ($part !== null) {
236-
return isset($stat[$part]) ? $stat[$part] : $default;
236+
return $stat[$part] ?? $default;
237237
}
238238
return $stat;
239239
}

lib/internal/Magento/Framework/Filter/AbstractFactory.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ public function canCreateFilter($alias)
6868
*/
6969
public function isShared($class)
7070
{
71-
return isset($this->shared[$class]) ? $this->shared[$class] : $this->shareByDefault;
71+
return $this->shared[$class] ?? $this->shareByDefault;
7272
}
7373

7474
/**

lib/internal/Magento/Framework/Filter/Input.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ public function getFilters($name = null)
183183
if (null === $name) {
184184
return $this->_filters;
185185
} else {
186-
return isset($this->_filters[$name]) ? $this->_filters[$name] : null;
186+
return $this->_filters[$name] ?? null;
187187
}
188188
}
189189

lib/internal/Magento/Framework/Interception/PluginList/PluginList.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ public function getNext($type, $method, $code = '__self')
268268
$this->_inheritPlugins($type);
269269
}
270270
$key = $type . '_' . lcfirst($method) . '_' . $code;
271-
return isset($this->_processed[$key]) ? $this->_processed[$key] : null;
271+
return $this->_processed[$key] ?? null;
272272
}
273273

274274
/**

lib/internal/Magento/Framework/Message/Collection.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ public function getItems()
136136
*/
137137
public function getItemsByType($type)
138138
{
139-
return isset($this->messages[$type]) ? $this->messages[$type] : [];
139+
return $this->messages[$type] ?? [];
140140
}
141141

142142
/**

lib/internal/Magento/Framework/Model/AbstractExtensibleModel.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -154,9 +154,7 @@ public function getCustomAttributes()
154154
public function getCustomAttribute($attributeCode)
155155
{
156156
$this->initializeCustomAttributes();
157-
return isset($this->_data[self::CUSTOM_ATTRIBUTES][$attributeCode])
158-
? $this->_data[self::CUSTOM_ATTRIBUTES][$attributeCode]
159-
: null;
157+
return $this->_data[self::CUSTOM_ATTRIBUTES][$attributeCode] ?? null;
160158
}
161159

162160
/**

lib/internal/Magento/Framework/Module/FullModuleList.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ public function getAll()
5555
public function getOne($name)
5656
{
5757
$data = $this->getAll();
58-
return isset($data[$name]) ? $data[$name] : null;
58+
return $data[$name] ?? null;
5959
}
6060

6161
/**

lib/internal/Magento/Framework/Module/ModuleList.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ public function getAll()
9090
public function getOne($name)
9191
{
9292
$enabled = $this->getAll();
93-
return isset($enabled[$name]) ? $enabled[$name] : null;
93+
return $enabled[$name] ?? null;
9494
}
9595

9696
/**

lib/internal/Magento/Framework/Module/ModuleResource.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ public function getDbVersion($moduleName)
8787
return false;
8888
}
8989
$this->_loadVersion('db');
90-
return isset(self::$schemaVersions[$moduleName]) ? self::$schemaVersions[$moduleName] : false;
90+
return self::$schemaVersions[$moduleName] ?? false;
9191
}
9292

9393
/**
@@ -119,7 +119,7 @@ public function getDataVersion($moduleName)
119119
return false;
120120
}
121121
$this->_loadVersion('data');
122-
return isset(self::$dataVersions[$moduleName]) ? self::$dataVersions[$moduleName] : false;
122+
return self::$dataVersions[$moduleName] ?? false;
123123
}
124124

125125
/**

lib/internal/Magento/Framework/Module/PackageInfo.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,6 @@ public function getConflict($moduleName)
283283
public function getVersion($moduleName)
284284
{
285285
$this->load();
286-
return isset($this->modulePackageVersionMap[$moduleName]) ? $this->modulePackageVersionMap[$moduleName] : '';
286+
return $this->modulePackageVersionMap[$moduleName] ?? '';
287287
}
288288
}

lib/internal/Magento/Framework/Notification/MessageList.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ protected function _loadMessages()
7272
public function getMessageByIdentity($identity)
7373
{
7474
$this->_loadMessages();
75-
return isset($this->_messages[$identity]) ? $this->_messages[$identity] : null;
75+
return $this->_messages[$identity] ?? null;
7676
}
7777

7878
/**

lib/internal/Magento/Framework/ObjectManager/Test/Unit/Factory/Fixture/Polymorphous.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,6 @@ public function __construct()
2626
*/
2727
public function getArg($key)
2828
{
29-
return isset($this->args[$key]) ? $this->args[$key] : null;
29+
return $this->args[$key] ?? null;
3030
}
3131
}

0 commit comments

Comments
 (0)