Skip to content

Code cleanup of lib files #17103

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 2, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public function getCustomAttribute($attributeCode)
*/
public function getCustomAttributes()
{
return isset($this->_data[self::CUSTOM_ATTRIBUTES]) ? $this->_data[self::CUSTOM_ATTRIBUTES] : [];
return $this->_data[self::CUSTOM_ATTRIBUTES] ?? [];
}

/**
Expand Down Expand Up @@ -129,7 +129,7 @@ public function setCustomAttribute($attributeCode, $attributeValue)
*/
protected function getCustomAttributesCodes()
{
return isset($this->customAttributesCodes) ? $this->customAttributesCodes : [];
return $this->customAttributesCodes ?? [];
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public function __construct(array $data = [])
*/
protected function _get($key)
{
return isset($this->_data[$key]) ? $this->_data[$key] : null;
return $this->_data[$key] ?? null;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion lib/internal/Magento/Framework/Api/ImageProcessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ public function processImageContent($entityType, $imageContent)
*/
protected function getMimeTypeExtension($mimeType)
{
return isset($this->mimeTypeExtensionMap[$mimeType]) ? $this->mimeTypeExtensionMap[$mimeType] : '';
return $this->mimeTypeExtensionMap[$mimeType] ?? '';
}

/**
Expand Down
4 changes: 1 addition & 3 deletions lib/internal/Magento/Framework/Api/Search/Document.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,7 @@ public function setId($id)
*/
public function getCustomAttribute($attributeCode)
{
return isset($this->_data[self::CUSTOM_ATTRIBUTES][$attributeCode])
? $this->_data[self::CUSTOM_ATTRIBUTES][$attributeCode]
: null;
return $this->_data[self::CUSTOM_ATTRIBUTES][$attributeCode] ?? null;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,6 @@ private function getCustomFilterForField($field)
*/
private function getFieldMapping($field)
{
return isset($this->fieldMapping[$field]) ? $this->fieldMapping[$field] : $field;
return $this->fieldMapping[$field] ?? $field;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,6 @@ private function getCustomJoin($field)
*/
private function getFieldMapping($field)
{
return isset($this->fieldMapping[$field]) ? $this->fieldMapping[$field] : $field;
return $this->fieldMapping[$field] ?? $field;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public function process(SearchCriteriaInterface $searchCriteria, AbstractDb $col
*/
private function getFieldMapping($field)
{
return isset($this->fieldMapping[$field]) ? $this->fieldMapping[$field] : $field;
return $this->fieldMapping[$field] ?? $field;
}

/**
Expand Down
4 changes: 1 addition & 3 deletions lib/internal/Magento/Framework/App/ActionFlag.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,7 @@ public function get($action, $flag = '')
$action = $this->_request->getActionName();
}
if ('' === $flag) {
return isset(
$this->_flags[$this->_getControllerKey()]
) ? $this->_flags[$this->_getControllerKey()] : [];
return $this->_flags[$this->_getControllerKey()] ?? [];
} elseif (isset($this->_flags[$this->_getControllerKey()][$action][$flag])) {
return $this->_flags[$this->_getControllerKey()][$action][$flag];
} else {
Expand Down
4 changes: 2 additions & 2 deletions lib/internal/Magento/Framework/App/AreaList.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ public function getCodeByFrontName($frontName)
*/
public function getFrontName($areaCode)
{
return isset($this->_areas[$areaCode]['frontName']) ? $this->_areas[$areaCode]['frontName'] : null;
return $this->_areas[$areaCode]['frontName'] ?? null;
}

/**
Expand All @@ -111,7 +111,7 @@ public function getCodes()
*/
public function getDefaultRouter($areaCode)
{
return isset($this->_areas[$areaCode]['router']) ? $this->_areas[$areaCode]['router'] : null;
return $this->_areas[$areaCode]['router'] ?? null;
}

/**
Expand Down
4 changes: 2 additions & 2 deletions lib/internal/Magento/Framework/App/Config/Initial.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,9 @@ public function getData($scope)
list($scopeType, $scopeCode) = array_pad(explode('|', $scope), 2, null);

if (ScopeConfigInterface::SCOPE_TYPE_DEFAULT == $scopeType) {
return isset($this->_data[$scopeType]) ? $this->_data[$scopeType] : [];
return $this->_data[$scopeType] ?? [];
} elseif ($scopeCode) {
return isset($this->_data[$scopeType][$scopeCode]) ? $this->_data[$scopeType][$scopeCode] : [];
return $this->_data[$scopeType][$scopeCode] ?? [];
}
return [];
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,6 @@ public function __construct(array $parts)
*/
public function getPart($code)
{
return isset($this->_parts[$code]) ? $this->_parts[$code] : null;
return $this->_parts[$code] ?? null;
}
}
2 changes: 1 addition & 1 deletion lib/internal/Magento/Framework/App/DeploymentConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public function get($key = null, $defaultValue = null)
if ($key === null) {
return $this->flatData;
}
return isset($this->flatData[$key]) ? $this->flatData[$key] : $defaultValue;
return $this->flatData[$key] ?? $defaultValue;
}

/**
Expand Down
4 changes: 1 addition & 3 deletions lib/internal/Magento/Framework/App/Http/Context.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,7 @@ public function unsValue($name)
*/
public function getValue($name)
{
return isset($this->data[$name])
? $this->data[$name]
: (isset($this->default[$name]) ? $this->default[$name] : null);
return $this->data[$name] ?? ($this->default[$name] ?? null);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public function getPaths($type)
public function getPath($type, $componentName)
{
self::validateType($type);
return isset(self::$paths[$type][$componentName]) ? self::$paths[$type][$componentName] : null;
return self::$paths[$type][$componentName] ?? null;
}

/**
Expand Down
14 changes: 6 additions & 8 deletions lib/internal/Magento/Framework/Config/View.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public function __construct(
public function getVars($module)
{
$this->initData();
return isset($this->data['vars'][$module]) ? $this->data['vars'][$module] : [];
return $this->data['vars'][$module] ?? [];
}

/**
Expand Down Expand Up @@ -110,7 +110,7 @@ public function getVarValue($module, $var)
public function getMediaEntities($module, $mediaType)
{
$this->initData();
return isset($this->data['media'][$module][$mediaType]) ? $this->data['media'][$module][$mediaType] : [];
return $this->data['media'][$module][$mediaType] ?? [];
}

/**
Expand All @@ -124,9 +124,7 @@ public function getMediaEntities($module, $mediaType)
public function getMediaAttributes($module, $mediaType, $mediaId)
{
$this->initData();
return isset($this->data['media'][$module][$mediaType][$mediaId])
? $this->data['media'][$module][$mediaType][$mediaId]
: [];
return $this->data['media'][$module][$mediaType][$mediaId] ?? [];
}

/**
Expand Down Expand Up @@ -163,7 +161,7 @@ protected function getIdAttributes()
public function getExcludedFiles()
{
$items = $this->getItems();
return isset($items['file']) ? $items['file'] : [];
return $items['file'] ?? [];
}

/**
Expand All @@ -174,7 +172,7 @@ public function getExcludedFiles()
public function getExcludedDir()
{
$items = $this->getItems();
return isset($items['directory']) ? $items['directory'] : [];
return $items['directory'] ?? [];
}

/**
Expand All @@ -185,7 +183,7 @@ public function getExcludedDir()
protected function getItems()
{
$this->initData();
return isset($this->data['exclude']) ? $this->data['exclude'] : [];
return $this->data['exclude'] ?? [];
}

/**
Expand Down
2 changes: 1 addition & 1 deletion lib/internal/Magento/Framework/DB/Adapter/Pdo/Mysql.php
Original file line number Diff line number Diff line change
Expand Up @@ -483,7 +483,7 @@ public function rawFetchRow($sql, $field = null)
if (empty($field)) {
return $row;
} else {
return isset($row[$field]) ? $row[$field] : false;
return $row[$field] ?? false;
}
}

Expand Down
2 changes: 1 addition & 1 deletion lib/internal/Magento/Framework/Data/AbstractCriteria.php
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ public function getLimit()
*/
public function getPart($name, $default = null)
{
return isset($this->data[$name]) ? $this->data[$name] : $default;
return $this->data[$name] ?? $default;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion lib/internal/Magento/Framework/Data/AbstractDataObject.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,6 @@ public function toArray()
*/
protected function get($key)
{
return isset($this->data[$key]) ? $this->data[$key] : null;
return $this->data[$key] ?? null;
}
}
2 changes: 1 addition & 1 deletion lib/internal/Magento/Framework/Data/Collection.php
Original file line number Diff line number Diff line change
Expand Up @@ -851,7 +851,7 @@ public function count()
*/
public function getFlag($flag)
{
return isset($this->_flags[$flag]) ? $this->_flags[$flag] : null;
return $this->_flags[$flag] ?? null;
}

/**
Expand Down
8 changes: 3 additions & 5 deletions lib/internal/Magento/Framework/Data/Structure.php
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ public function createElement($elementId, array $data)
*/
public function getElement($elementId)
{
return isset($this->_elements[$elementId]) ? $this->_elements[$elementId] : false;
return $this->_elements[$elementId] ?? false;
}

/**
Expand Down Expand Up @@ -456,9 +456,7 @@ public function getChildId($parentId, $alias)
*/
public function getChildren($parentId)
{
return isset(
$this->_elements[$parentId][self::CHILDREN]
) ? $this->_elements[$parentId][self::CHILDREN] : [];
return $this->_elements[$parentId][self::CHILDREN] ?? [];
}

/**
Expand All @@ -469,7 +467,7 @@ public function getChildren($parentId)
*/
public function getParentId($childId)
{
return isset($this->_elements[$childId][self::PARENT]) ? $this->_elements[$childId][self::PARENT] : false;
return $this->_elements[$childId][self::PARENT] ?? false;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion lib/internal/Magento/Framework/Event.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ public function dispatch()
*/
public function getName()
{
return isset($this->_data['name']) ? $this->_data['name'] : null;
return $this->_data['name'] ?? null;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion lib/internal/Magento/Framework/Filesystem/Io/File.php
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ public function streamStat($part = null, $default = null)
}
$stat = @fstat($this->_streamHandler);
if ($part !== null) {
return isset($stat[$part]) ? $stat[$part] : $default;
return $stat[$part] ?? $default;
}
return $stat;
}
Expand Down
2 changes: 1 addition & 1 deletion lib/internal/Magento/Framework/Filter/AbstractFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public function canCreateFilter($alias)
*/
public function isShared($class)
{
return isset($this->shared[$class]) ? $this->shared[$class] : $this->shareByDefault;
return $this->shared[$class] ?? $this->shareByDefault;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion lib/internal/Magento/Framework/Filter/Input.php
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ public function getFilters($name = null)
if (null === $name) {
return $this->_filters;
} else {
return isset($this->_filters[$name]) ? $this->_filters[$name] : null;
return $this->_filters[$name] ?? null;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ public function getNext($type, $method, $code = '__self')
$this->_inheritPlugins($type);
}
$key = $type . '_' . lcfirst($method) . '_' . $code;
return isset($this->_processed[$key]) ? $this->_processed[$key] : null;
return $this->_processed[$key] ?? null;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion lib/internal/Magento/Framework/Message/Collection.php
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ public function getItems()
*/
public function getItemsByType($type)
{
return isset($this->messages[$type]) ? $this->messages[$type] : [];
return $this->messages[$type] ?? [];
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,9 +151,7 @@ public function getCustomAttributes()
public function getCustomAttribute($attributeCode)
{
$this->initializeCustomAttributes();
return isset($this->_data[self::CUSTOM_ATTRIBUTES][$attributeCode])
? $this->_data[self::CUSTOM_ATTRIBUTES][$attributeCode]
: null;
return $this->_data[self::CUSTOM_ATTRIBUTES][$attributeCode] ?? null;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion lib/internal/Magento/Framework/Module/FullModuleList.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public function getAll()
public function getOne($name)
{
$data = $this->getAll();
return isset($data[$name]) ? $data[$name] : null;
return $data[$name] ?? null;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion lib/internal/Magento/Framework/Module/ModuleList.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ public function getAll()
public function getOne($name)
{
$enabled = $this->getAll();
return isset($enabled[$name]) ? $enabled[$name] : null;
return $enabled[$name] ?? null;
}

/**
Expand Down
4 changes: 2 additions & 2 deletions lib/internal/Magento/Framework/Module/ModuleResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ public function getDbVersion($moduleName)
return false;
}
$this->_loadVersion('db');
return isset(self::$schemaVersions[$moduleName]) ? self::$schemaVersions[$moduleName] : false;
return self::$schemaVersions[$moduleName] ?? false;
}

/**
Expand Down Expand Up @@ -116,7 +116,7 @@ public function getDataVersion($moduleName)
return false;
}
$this->_loadVersion('data');
return isset(self::$dataVersions[$moduleName]) ? self::$dataVersions[$moduleName] : false;
return self::$dataVersions[$moduleName] ?? false;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion lib/internal/Magento/Framework/Module/PackageInfo.php
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,6 @@ public function getConflict($moduleName)
public function getVersion($moduleName)
{
$this->load();
return isset($this->modulePackageVersionMap[$moduleName]) ? $this->modulePackageVersionMap[$moduleName] : '';
return $this->modulePackageVersionMap[$moduleName] ?? '';
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ protected function _loadMessages()
public function getMessageByIdentity($identity)
{
$this->_loadMessages();
return isset($this->_messages[$identity]) ? $this->_messages[$identity] : null;
return $this->_messages[$identity] ?? null;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,6 @@ public function __construct()
*/
public function getArg($key)
{
return isset($this->args[$key]) ? $this->args[$key] : null;
return $this->args[$key] ?? null;
}
}
Loading