Skip to content

Commit

Permalink
ENGCOM-6921: Update the product model custom option methods PHPdoc #2…
Browse files Browse the repository at this point in the history
  • Loading branch information
slavvka authored Feb 24, 2020
2 parents 9003079 + ed3d80c commit ca6ec09
Showing 1 changed file with 8 additions and 16 deletions.
24 changes: 8 additions & 16 deletions app/code/Magento/Catalog/Model/Product.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
use Magento\Catalog\Api\Data\ProductInterface;
use Magento\Catalog\Api\ProductLinkRepositoryInterface;
use Magento\Catalog\Model\Product\Attribute\Backend\Media\EntryConverterPool;
use Magento\Catalog\Model\Product\Configuration\Item\Option\OptionInterface;
use Magento\Catalog\Model\FilterProductCustomAttribute;
use Magento\Framework\Api\AttributeValueFactory;
use Magento\Framework\App\Filesystem\DirectoryList;
Expand Down Expand Up @@ -108,7 +109,7 @@ class Product extends \Magento\Catalog\Model\AbstractModel implements
/**
* Product object customization (not stored in DB)
*
* @var array
* @var OptionInterface[]
*/
protected $_customOptions = [];

Expand Down Expand Up @@ -2062,7 +2063,7 @@ public function addCustomOption($code, $value, $product = null)
/**
* Sets custom options for the product
*
* @param array $options Array of options
* @param OptionInterface[] $options Array of options
* @return void
*/
public function setCustomOptions(array $options)
Expand All @@ -2073,7 +2074,7 @@ public function setCustomOptions(array $options)
/**
* Get all custom options of the product
*
* @return array
* @return OptionInterface[]
*/
public function getCustomOptions()
{
Expand All @@ -2084,14 +2085,11 @@ public function getCustomOptions()
* Get product custom option info
*
* @param string $code
* @return array
* @return OptionInterface|null
*/
public function getCustomOption($code)
{
if (isset($this->_customOptions[$code])) {
return $this->_customOptions[$code];
}
return null;
return $this->_customOptions[$code] ?? null;
}

/**
Expand All @@ -2101,11 +2099,7 @@ public function getCustomOption($code)
*/
public function hasCustomOptions()
{
if (count($this->_customOptions)) {
return true;
} else {
return false;
}
return (bool)count($this->_customOptions);
}

/**
Expand Down Expand Up @@ -2405,16 +2399,14 @@ public function reloadPriceInfo()
}
}

// phpcs:disable PHPCompatibility.FunctionNameRestrictions.ReservedFunctionNames
/**
* Return Data Object data in array format.
*
* @return array
* @todo refactor with converter for AbstractExtensibleModel
*/
public function __toArray()
public function __toArray() //phpcs:ignore PHPCompatibility.FunctionNameRestrictions.ReservedFunctionNames
{
// phpcs:enable PHPCompatibility.FunctionNameRestrictions.ReservedFunctionNames
$data = $this->_data;
$hasToArray = function ($model) {
return is_object($model) && method_exists($model, '__toArray') && is_callable([$model, '__toArray']);
Expand Down

0 comments on commit ca6ec09

Please sign in to comment.