10
10
use Magento \Catalog \Api \Data \ProductInterface ;
11
11
use Magento \Catalog \Api \ProductLinkRepositoryInterface ;
12
12
use Magento \Catalog \Model \Product \Attribute \Backend \Media \EntryConverterPool ;
13
+ use Magento \Catalog \Model \Product \Configuration \Item \Option \OptionInterface ;
13
14
use Magento \Catalog \Model \FilterProductCustomAttribute ;
14
15
use Magento \Framework \Api \AttributeValueFactory ;
15
16
use Magento \Framework \App \Filesystem \DirectoryList ;
@@ -108,7 +109,7 @@ class Product extends \Magento\Catalog\Model\AbstractModel implements
108
109
/**
109
110
* Product object customization (not stored in DB)
110
111
*
111
- * @var array
112
+ * @var OptionInterface[]
112
113
*/
113
114
protected $ _customOptions = [];
114
115
@@ -2062,7 +2063,7 @@ public function addCustomOption($code, $value, $product = null)
2062
2063
/**
2063
2064
* Sets custom options for the product
2064
2065
*
2065
- * @param array $options Array of options
2066
+ * @param OptionInterface[] $options Array of options
2066
2067
* @return void
2067
2068
*/
2068
2069
public function setCustomOptions (array $ options )
@@ -2073,7 +2074,7 @@ public function setCustomOptions(array $options)
2073
2074
/**
2074
2075
* Get all custom options of the product
2075
2076
*
2076
- * @return array
2077
+ * @return OptionInterface[]
2077
2078
*/
2078
2079
public function getCustomOptions ()
2079
2080
{
@@ -2084,14 +2085,11 @@ public function getCustomOptions()
2084
2085
* Get product custom option info
2085
2086
*
2086
2087
* @param string $code
2087
- * @return array
2088
+ * @return OptionInterface|null
2088
2089
*/
2089
2090
public function getCustomOption ($ code )
2090
2091
{
2091
- if (isset ($ this ->_customOptions [$ code ])) {
2092
- return $ this ->_customOptions [$ code ];
2093
- }
2094
- return null ;
2092
+ return $ this ->_customOptions [$ code ] ?? null ;
2095
2093
}
2096
2094
2097
2095
/**
@@ -2101,11 +2099,7 @@ public function getCustomOption($code)
2101
2099
*/
2102
2100
public function hasCustomOptions ()
2103
2101
{
2104
- if (count ($ this ->_customOptions )) {
2105
- return true ;
2106
- } else {
2107
- return false ;
2108
- }
2102
+ return (bool )count ($ this ->_customOptions );
2109
2103
}
2110
2104
2111
2105
/**
@@ -2405,16 +2399,14 @@ public function reloadPriceInfo()
2405
2399
}
2406
2400
}
2407
2401
2408
- // phpcs:disable PHPCompatibility.FunctionNameRestrictions.ReservedFunctionNames
2409
2402
/**
2410
2403
* Return Data Object data in array format.
2411
2404
*
2412
2405
* @return array
2413
2406
* @todo refactor with converter for AbstractExtensibleModel
2414
2407
*/
2415
- public function __toArray ()
2408
+ public function __toArray () //phpcs:ignore PHPCompatibility.FunctionNameRestrictions.ReservedFunctionNames
2416
2409
{
2417
- // phpcs:enable PHPCompatibility.FunctionNameRestrictions.ReservedFunctionNames
2418
2410
$ data = $ this ->_data ;
2419
2411
$ hasToArray = function ($ model ) {
2420
2412
return is_object ($ model ) && method_exists ($ model , '__toArray ' ) && is_callable ([$ model , '__toArray ' ]);
0 commit comments