Skip to content
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

Clean code #18124

Merged
merged 9 commits into from
Dec 12, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
20 changes: 10 additions & 10 deletions app/code/Magento/Catalog/Ui/Component/ColumnFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,14 @@ public function __construct(\Magento\Framework\View\Element\UiComponentFactory $
$this->componentFactory = $componentFactory;
}

/**
* @param \Magento\Catalog\Api\Data\ProductAttributeInterface $attribute
* @param \Magento\Framework\View\Element\UiComponent\ContextInterface $context
* @param array $config
* @return \Magento\Ui\Component\Listing\Columns\ColumnInterface
*/
/**
* @param \Magento\Catalog\Api\Data\ProductAttributeInterface $attribute
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please, remove extra spaces from doc block

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please, check comment indentation

* @param \Magento\Framework\View\Element\UiComponent\ContextInterface $context
* @param array $config
*
* @return \Magento\Ui\Component\Listing\Columns\ColumnInterface
* @throws \Magento\Framework\Exception\LocalizedException
*/
public function create($attribute, $context, array $config = [])
{
$columnName = $attribute->getAttributeCode();
Expand Down Expand Up @@ -96,9 +98,7 @@ protected function getJsComponent($dataType)
*/
protected function getDataType($attribute)
{
return isset($this->dataTypeMap[$attribute->getFrontendInput()])
? $this->dataTypeMap[$attribute->getFrontendInput()]
: $this->dataTypeMap['default'];
return $this->dataTypeMap[$attribute->getFrontendInput()] ?? $this->dataTypeMap['default'];
}

/**
Expand All @@ -111,6 +111,6 @@ protected function getFilterType($frontendInput)
{
$filtersMap = ['date' => 'dateRange'];
$result = array_replace_recursive($this->dataTypeMap, $filtersMap);
return isset($result[$frontendInput]) ? $result[$frontendInput] : $result['default'];
return $result[$frontendInput] ?? $result['default'];
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,6 @@ public function prepareDataSource(array $dataSource)
protected function getAlt($row)
{
$altField = $this->getData('config/altField') ?: self::ALT_FIELD;
return isset($row[$altField]) ? $row[$altField] : null;
return $row[$altField] ?? null;
}
}
6 changes: 5 additions & 1 deletion app/code/Magento/CatalogUrlRewrite/Model/ObjectRegistry.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,19 @@ public function __construct($entities)
}

/**
* Get
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please, add a comment that describes service method

*
* @param int $entityId
* @return \Magento\Framework\DataObject|null
*/
public function get($entityId)
{
return isset($this->entitiesMap[$entityId]) ? $this->entitiesMap[$entityId] : null;
return $this->entitiesMap[$entityId] ?? null;
}

/**
* List
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please, add a comment that describes service method

*
* @return \Magento\Framework\DataObject[]
*/
public function getList()
Expand Down
18 changes: 10 additions & 8 deletions app/code/Magento/Customer/Block/Adminhtml/Edit/Tab/View/Sales.php
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ public function _beforeToHtml()
*/
public function getWebsiteCount($websiteId)
{
return isset($this->_websiteCounts[$websiteId]) ? $this->_websiteCounts[$websiteId] : 0;
return $this->_websiteCounts[$websiteId] ?? 0;
}

/**
Expand All @@ -166,13 +166,15 @@ public function getTotals()
return $this->_collection->getTotals();
}

/**
* Format price by specified website
*
* @param float $price
* @param null|int $websiteId
* @return string
*/
/**
* Format price by specified website
*
* @param float $price
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please, remove extra spaces from doc block

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please, check comment indentation

* @param null|int $websiteId
*
* @return string
* @throws \Magento\Framework\Exception\LocalizedException
*/
public function formatCurrency($price, $websiteId = null)
{
return $this->_storeManager->getWebsite($websiteId)->getBaseCurrency()->format($price);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ public function getStreet()
public function getStreetLine($number)
{
$lines = $this->getStreet();
return isset($lines[$number - 1]) ? $lines[$number - 1] : '';
return $lines[$number - 1] ?? '';
}

/**
Expand Down
13 changes: 7 additions & 6 deletions app/code/Magento/Fedex/Model/Carrier.php
Original file line number Diff line number Diff line change
Expand Up @@ -982,11 +982,12 @@ public function getCode($type, $code = '')
}
}

/**
* Return FeDex currency ISO code by Magento Base Currency Code
*
* @return string 3-digit currency code
*/
/**
* Return FeDex currency ISO code by Magento Base Currency Code
*
* @return string 3-digit currency code
* @throws \Magento\Framework\Exception\NoSuchEntityException
*/
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please, check comment indentation

public function getCurrencyCode()
{
$codes = [
Expand All @@ -1008,7 +1009,7 @@ public function getCurrencyCode()
];
$currencyCode = $this->_storeManager->getStore()->getBaseCurrencyCode();

return isset($codes[$currencyCode]) ? $codes[$currencyCode] : $currencyCode;
return $codes[$currencyCode] ?? $currencyCode;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,6 @@ public function create(VaultPaymentInterface $paymentMethod, int $storeId): Inte
*/
private function extractFromConfig($config, string $field, string $default): string
{
return isset($config[$field]) ? $config[$field] : $default;
return $config[$field] ?? $default;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ public function getName()
*/
public function getConfigData()
{
return isset($this->data['config']) ? $this->data['config'] : [];
return $this->data['config'] ?? [];
}

/**
Expand Down
2 changes: 1 addition & 1 deletion app/code/Magento/Sales/Model/Order/Address.php
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ public function getStreet()
public function getStreetLine($number)
{
$lines = $this->getStreet();
return isset($lines[$number - 1]) ? $lines[$number - 1] : '';
return $lines[$number - 1] ?? '';
}

//@codeCoverageIgnoreStart
Expand Down
2 changes: 1 addition & 1 deletion app/code/Magento/Sales/Model/Order/Payment/Info.php
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ public function getAdditionalInformation($key = null)
if (null === $key) {
return $this->additionalInformation;
}
return isset($this->additionalInformation[$key]) ? $this->additionalInformation[$key] : null;
return $this->additionalInformation[$key] ?? null;
}

/**
Expand Down
4 changes: 2 additions & 2 deletions app/code/Magento/Sales/Model/Order/Payment/Transaction.php
Original file line number Diff line number Diff line change
Expand Up @@ -472,7 +472,7 @@ public function getAdditionalInformation($key = null)
$info = [];
}
if ($key) {
return isset($info[$key]) ? $info[$key] : null;
return $info[$key] ?? null;
}
return $info;
}
Expand Down Expand Up @@ -898,7 +898,7 @@ public function getTxnId()
public function getHtmlTxnId()
{
$this->_eventManager->dispatch($this->_eventPrefix . '_html_txn_id', $this->_getEventData());
return isset($this->_data['html_txn_id']) ? $this->_data['html_txn_id'] : $this->getTxnId();
return $this->_data['html_txn_id'] ?? $this->getTxnId();
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,6 @@ protected function getLastUpdatedAtValue($default = '0000-00-00 00:00:00')

$row = $this->getConnection()->fetchRow($select);

return isset($row['updated_at']) ? $row['updated_at'] : $default;
return $row['updated_at'] ?? $default;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -184,11 +184,11 @@ public function setActiveFlag($code = 'active')
/**
* Return code of carrier
*
* @return string
* @return string|null
*/
public function getCarrierCode()
{
return isset($this->_code) ? $this->_code : null;
return $this->_code ?? null;
}

/**
Expand Down Expand Up @@ -410,7 +410,7 @@ protected function _getCachedQuotes($requestParams)
{
$key = $this->_getQuotesCacheKey($requestParams);

return isset(self::$_quotesCache[$key]) ? self::$_quotesCache[$key] : null;
return self::$_quotesCache[$key] ?? null;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,6 @@ private function getStreetLine($number, $street)
{
$lines = is_array($street) ? $street : [];

return isset($lines[$number - 1]) ? $lines[$number - 1] : '';
return $lines[$number - 1] ?? '';
}
}
Loading