Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.
Common duplication problems, and corresponding solutions are:
| 1 | <?php | ||
| 44 | class BunchSubject extends AbstractProductSubject implements ExportableSubjectInterface, FileUploadSubjectInterface, UrlKeyAwareSubjectInterface | ||
| 45 | { | ||
| 46 | |||
| 47 | /** | ||
| 48 | * The trait that implements the export functionality. | ||
| 49 | * | ||
| 50 | * @var \TechDivision\Import\Subjects\ExportableTrait | ||
| 51 | */ | ||
| 52 | use ExportableTrait; | ||
| 53 | |||
| 54 | /** | ||
| 55 | * The trait that provides file upload functionality. | ||
| 56 | * | ||
| 57 | * @var \TechDivision\Import\Subjects\FileUploadTrait | ||
| 58 | */ | ||
| 59 | use FileUploadTrait; | ||
| 60 | |||
| 61 | /** | ||
| 62 | * The array with the pre-loaded entity IDs. | ||
| 63 | * | ||
| 64 | * @var array | ||
| 65 | */ | ||
| 66 | protected $preLoadedEntityIds = array(); | ||
| 67 | |||
| 68 | /** | ||
| 69 | * Mappings for the table column => CSV column header. | ||
| 70 | * | ||
| 71 | * @var array | ||
| 72 | */ | ||
| 73 | protected $headerStockMappings = array( | ||
| 74 |         'qty'                         => array('qty', 'float'), | ||
| 75 |         'min_qty'                     => array('out_of_stock_qty', 'float'), | ||
| 76 |         'use_config_min_qty'          => array('use_config_min_qty', 'int'), | ||
| 77 |         'is_qty_decimal'              => array('is_qty_decimal', 'int'), | ||
| 78 |         'backorders'                  => array('allow_backorders', 'int'), | ||
| 79 |         'use_config_backorders'       => array('use_config_backorders', 'int'), | ||
| 80 |         'min_sale_qty'                => array('min_cart_qty', 'float'), | ||
| 81 |         'use_config_min_sale_qty'     => array('use_config_min_sale_qty', 'int'), | ||
| 82 |         'max_sale_qty'                => array('max_cart_qty', 'float'), | ||
| 83 |         'use_config_max_sale_qty'     => array('use_config_max_sale_qty', 'int'), | ||
| 84 |         'is_in_stock'                 => array('is_in_stock', 'int'), | ||
| 85 |         'notify_stock_qty'            => array('notify_on_stock_below', 'float'), | ||
| 86 |         'use_config_notify_stock_qty' => array('use_config_notify_stock_qty', 'int'), | ||
| 87 |         'manage_stock'                => array('manage_stock', 'int'), | ||
| 88 |         'use_config_manage_stock'     => array('use_config_manage_stock', 'int'), | ||
| 89 |         'use_config_qty_increments'   => array('use_config_qty_increments', 'int'), | ||
| 90 |         'qty_increments'              => array('qty_increments', 'float'), | ||
| 91 |         'use_config_enable_qty_inc'   => array('use_config_enable_qty_inc', 'int'), | ||
| 92 |         'enable_qty_increments'       => array('enable_qty_increments', 'int'), | ||
| 93 |         'is_decimal_divided'          => array('is_decimal_divided', 'int'), | ||
| 94 | ); | ||
| 95 | |||
| 96 | /** | ||
| 97 | * The array with the available visibility keys. | ||
| 98 | * | ||
| 99 | * @var array | ||
| 100 | */ | ||
| 101 | protected $availableVisibilities = array( | ||
| 102 | 'Not Visible Individually' => VisibilityKeys::VISIBILITY_NOT_VISIBLE, | ||
| 103 | 'Catalog' => VisibilityKeys::VISIBILITY_IN_CATALOG, | ||
| 104 | 'Search' => VisibilityKeys::VISIBILITY_IN_SEARCH, | ||
| 105 | 'Catalog, Search' => VisibilityKeys::VISIBILITY_BOTH | ||
| 106 | ); | ||
| 107 | |||
| 108 | /** | ||
| 109 | * The default callback mappings for the Magento standard product attributes. | ||
| 110 | * | ||
| 111 | * @var array | ||
| 112 | */ | ||
| 113 | protected $defaultCallbackMappings = array( | ||
| 114 |         'visibility'           => array('import_product.callback.visibility'), | ||
| 115 |         'tax_class_id'         => array('import_product.callback.tax.class'), | ||
| 116 |         'bundle_price_type'    => array('import_product_bundle.callback.bundle.type'), | ||
| 117 |         'bundle_sku_type'      => array('import_product_bundle.callback.bundle.type'), | ||
| 118 |         'bundle_weight_type'   => array('import_product_bundle.callback.bundle.type'), | ||
| 119 |         'bundle_price_view'    => array('import_product_bundle.callback.bundle.price.view'), | ||
| 120 |         'bundle_shipment_type' => array('import_product_bundle.callback.bundle.shipment.type') | ||
| 121 | ); | ||
| 122 | |||
| 123 | /** | ||
| 124 | * The available entity types. | ||
| 125 | * | ||
| 126 | * @var array | ||
| 127 | */ | ||
| 128 | protected $entityTypes = array(); | ||
| 129 | |||
| 130 | /** | ||
| 131 | * The media roles array (default: ['base', 'small', 'thumbnail', 'swatch']). | ||
| 132 | * | ||
| 133 | * @var array | ||
| 134 | */ | ||
| 135 | protected $mediaRoles = array(); | ||
| 136 | |||
| 137 | /** | ||
| 138 | * Intializes the previously loaded global data for exactly one bunch. | ||
| 139 | * | ||
| 140 | * @param string $serial The serial of the actual import | ||
| 141 | * | ||
| 142 | * @return void | ||
| 143 | */ | ||
| 144 | 18 | public function setUp($serial) | |
| 182 | |||
| 183 | /** | ||
| 184 | * Clean up the global data after importing the bunch. | ||
| 185 | * | ||
| 186 | * @param string $serial The serial of the actual import | ||
| 187 | * | ||
| 188 | * @return void | ||
| 189 | */ | ||
| 190 | public function tearDown($serial) | ||
| 207 | |||
| 208 | /** | ||
| 209 | * Return's the default callback mappings. | ||
| 210 | * | ||
| 211 | * @return array The default callback mappings | ||
| 212 | */ | ||
| 213 | public function getDefaultCallbackMappings() | ||
| 217 | |||
| 218 | /** | ||
| 219 | * Return's the mappings for the table column => CSV column header. | ||
| 220 | * | ||
| 221 | * @return array The header stock mappings | ||
| 222 | */ | ||
| 223 | 1 | public function getHeaderStockMappings() | |
| 227 | |||
| 228 | /** | ||
| 229 | * Return's the visibility key for the passed visibility string. | ||
| 230 | * | ||
| 231 | * @param string $visibility The visibility string to return the key for | ||
| 232 | * | ||
| 233 | * @return integer The requested visibility key | ||
| 234 | * @throws \Exception Is thrown, if the requested visibility is not available | ||
| 235 | */ | ||
| 236 | public function getVisibilityIdByValue($visibility) | ||
| 252 | |||
| 253 | /** | ||
| 254 | * Pre-load the entity ID for the passed product. | ||
| 255 | * | ||
| 256 | * @param array $product The product to be pre-loaded | ||
| 257 | * | ||
| 258 | * @return void | ||
| 259 | */ | ||
| 260 | public function preLoadEntityId(array $product) | ||
| 264 | |||
| 265 | /** | ||
| 266 | * Return's the entity type for the configured entity type code. | ||
| 267 | * | ||
| 268 | * @return array The requested entity type | ||
| 269 | * @throws \Exception Is thrown, if the requested entity type is not available | ||
| 270 | */ | ||
| 271 | 1 | View Code Duplication | public function getEntityType() | 
| 286 | |||
| 287 | /** | ||
| 288 | * Return's TRUE, if the passed URL key varchar value IS related with the actual PK. | ||
| 289 | * | ||
| 290 | * @param array $productVarcharAttribute The varchar value to check | ||
| 291 | * | ||
| 292 | * @return boolean TRUE if the URL key is related, else FALSE | ||
| 293 | */ | ||
| 294 | public function isUrlKeyOf(array $productVarcharAttribute) | ||
| 299 | /** | ||
| 300 | * Creates media roles from available image types. | ||
| 301 | * | ||
| 302 | * @return array | ||
| 303 | */ | ||
| 304 | 18 | public function createMediaRoles() | |
| 325 | |||
| 326 | /** | ||
| 327 | * Returns the media roles. | ||
| 328 | * | ||
| 329 | * @return array | ||
| 330 | */ | ||
| 331 | 18 | public function getMediaRoles(): array | |
| 335 | } | ||
| 336 | 
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: