Skip to content

Commit ca6ec09

Browse files
authored
ENGCOM-6921: Update the product model custom option methods PHPdoc #26697
2 parents 9003079 + ed3d80c commit ca6ec09

File tree

1 file changed

+8
-16
lines changed

1 file changed

+8
-16
lines changed

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

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
use Magento\Catalog\Api\Data\ProductInterface;
1111
use Magento\Catalog\Api\ProductLinkRepositoryInterface;
1212
use Magento\Catalog\Model\Product\Attribute\Backend\Media\EntryConverterPool;
13+
use Magento\Catalog\Model\Product\Configuration\Item\Option\OptionInterface;
1314
use Magento\Catalog\Model\FilterProductCustomAttribute;
1415
use Magento\Framework\Api\AttributeValueFactory;
1516
use Magento\Framework\App\Filesystem\DirectoryList;
@@ -108,7 +109,7 @@ class Product extends \Magento\Catalog\Model\AbstractModel implements
108109
/**
109110
* Product object customization (not stored in DB)
110111
*
111-
* @var array
112+
* @var OptionInterface[]
112113
*/
113114
protected $_customOptions = [];
114115

@@ -2062,7 +2063,7 @@ public function addCustomOption($code, $value, $product = null)
20622063
/**
20632064
* Sets custom options for the product
20642065
*
2065-
* @param array $options Array of options
2066+
* @param OptionInterface[] $options Array of options
20662067
* @return void
20672068
*/
20682069
public function setCustomOptions(array $options)
@@ -2073,7 +2074,7 @@ public function setCustomOptions(array $options)
20732074
/**
20742075
* Get all custom options of the product
20752076
*
2076-
* @return array
2077+
* @return OptionInterface[]
20772078
*/
20782079
public function getCustomOptions()
20792080
{
@@ -2084,14 +2085,11 @@ public function getCustomOptions()
20842085
* Get product custom option info
20852086
*
20862087
* @param string $code
2087-
* @return array
2088+
* @return OptionInterface|null
20882089
*/
20892090
public function getCustomOption($code)
20902091
{
2091-
if (isset($this->_customOptions[$code])) {
2092-
return $this->_customOptions[$code];
2093-
}
2094-
return null;
2092+
return $this->_customOptions[$code] ?? null;
20952093
}
20962094

20972095
/**
@@ -2101,11 +2099,7 @@ public function getCustomOption($code)
21012099
*/
21022100
public function hasCustomOptions()
21032101
{
2104-
if (count($this->_customOptions)) {
2105-
return true;
2106-
} else {
2107-
return false;
2108-
}
2102+
return (bool)count($this->_customOptions);
21092103
}
21102104

21112105
/**
@@ -2405,16 +2399,14 @@ public function reloadPriceInfo()
24052399
}
24062400
}
24072401

2408-
// phpcs:disable PHPCompatibility.FunctionNameRestrictions.ReservedFunctionNames
24092402
/**
24102403
* Return Data Object data in array format.
24112404
*
24122405
* @return array
24132406
* @todo refactor with converter for AbstractExtensibleModel
24142407
*/
2415-
public function __toArray()
2408+
public function __toArray() //phpcs:ignore PHPCompatibility.FunctionNameRestrictions.ReservedFunctionNames
24162409
{
2417-
// phpcs:enable PHPCompatibility.FunctionNameRestrictions.ReservedFunctionNames
24182410
$data = $this->_data;
24192411
$hasToArray = function ($model) {
24202412
return is_object($model) && method_exists($model, '__toArray') && is_callable([$model, '__toArray']);

0 commit comments

Comments
 (0)