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 |
||
| 21 | class ShopModule extends BaseModule implements BootstrapInterface, app\modules\event\interfaces\EventInterface |
||
| 22 | { |
||
| 23 | const BACKEND_PRODUCT_GRID = 'productEditGrid'; |
||
| 24 | const BACKEND_CATEGORY_GRID = 'categoryEditGrid'; |
||
| 25 | |||
| 26 | /** |
||
| 27 | * @inheritdoc |
||
| 28 | */ |
||
| 29 | public $controllerMap = [ |
||
| 30 | 'backend-filter-sets' => 'app\modules\shop\backend\FilterSetsController', |
||
| 31 | 'backend-addons' => 'app\modules\shop\backend\AddonsController', |
||
| 32 | ]; |
||
| 33 | |||
| 34 | /** |
||
| 35 | * @var int How much products per page to show |
||
| 36 | */ |
||
| 37 | public $productsPerPage = 15; |
||
| 38 | |||
| 39 | /** |
||
| 40 | * @var string How show products in category |
||
| 41 | */ |
||
| 42 | public $listViewType = 'blockView'; |
||
| 43 | /** |
||
| 44 | * @var int How much products allow to compare at once |
||
| 45 | */ |
||
| 46 | public $maxProductsToCompare = 3; |
||
| 47 | |||
| 48 | /** |
||
| 49 | * @var bool Should we show and query for products of subcategories |
||
| 50 | */ |
||
| 51 | public $showProductsOfChildCategories = 1; |
||
| 52 | |||
| 53 | /** |
||
| 54 | * @var int How much products to show on search results page |
||
| 55 | */ |
||
| 56 | public $searchResultsLimit = 9; |
||
| 57 | |||
| 58 | /** |
||
| 59 | * @var boolean Possible to search generated products |
||
| 60 | */ |
||
| 61 | public $allowSearchGeneratedProducts = 0; |
||
| 62 | |||
| 63 | /*** |
||
| 64 | * @var bool registration Guest User In Cart as new user and send data on e-mail |
||
| 65 | */ |
||
| 66 | public $registrationGuestUserInCart = 0; |
||
| 67 | |||
| 68 | /** |
||
| 69 | * @var bool Show delete order in backend |
||
| 70 | */ |
||
| 71 | public $deleteOrdersAbility = 0; |
||
| 72 | |||
| 73 | /** |
||
| 74 | * @var bool Filtration works only on parent products but not their children |
||
| 75 | */ |
||
| 76 | public $filterOnlyByParentProduct = true; |
||
| 77 | |||
| 78 | /** |
||
| 79 | * @var string Filtration mode |
||
| 80 | */ |
||
| 81 | public $multiFilterMode = ConfigConfigurationModel::MULTI_FILTER_MODE_INTERSECTION; |
||
| 82 | |||
| 83 | /** |
||
| 84 | * @var int How much last viewed products ID's to store in session |
||
| 85 | */ |
||
| 86 | public $maxLastViewedProducts = 9; |
||
| 87 | |||
| 88 | /** |
||
| 89 | * @var bool Allow to add same product in the order |
||
| 90 | */ |
||
| 91 | public $allowToAddSameProduct = 0; |
||
| 92 | |||
| 93 | /** |
||
| 94 | * @var bool Count only unique products in the order |
||
| 95 | */ |
||
| 96 | public $countUniqueProductsOnly = 1; |
||
| 97 | |||
| 98 | /** |
||
| 99 | * @var bool Count children products in the order |
||
| 100 | */ |
||
| 101 | public $countChildrenProducts = 1; |
||
| 102 | |||
| 103 | /** |
||
| 104 | * @var int Default measure ID |
||
| 105 | */ |
||
| 106 | public $defaultMeasureId = 1; |
||
| 107 | |||
| 108 | /** |
||
| 109 | * @var int Final order stage leaf |
||
| 110 | */ |
||
| 111 | public $finalOrderStageLeaf = 0; |
||
| 112 | |||
| 113 | /** |
||
| 114 | * @var int Default filter for Orders by stage in backend |
||
| 115 | */ |
||
| 116 | public $defaultOrderStageFilterBackend = 0; |
||
| 117 | |||
| 118 | /** |
||
| 119 | * @var int |
||
| 120 | */ |
||
| 121 | public $showDeletedOrders = 0; |
||
| 122 | |||
| 123 | /** |
||
| 124 | * @var array |
||
| 125 | */ |
||
| 126 | public $ymlConfig = []; |
||
| 127 | |||
| 128 | /** |
||
| 129 | * @var array |
||
| 130 | */ |
||
| 131 | public $googleFeedConfig = []; |
||
| 132 | |||
| 133 | |||
| 134 | /** |
||
| 135 | * @var bool Show filter links in breadcrumbs |
||
| 136 | */ |
||
| 137 | public $showFiltersInBreadcrumbs = false; |
||
| 138 | |||
| 139 | /** |
||
| 140 | * @var bool Use method ceilQuantity of Measure model |
||
| 141 | */ |
||
| 142 | public $useCeilQuantity = true; |
||
| 143 | |||
| 144 | /** |
||
| 145 | * @var string View file for render product item content block |
||
| 146 | */ |
||
| 147 | public $itemView = '@app/modules/shop/views/product/item-row'; |
||
| 148 | |||
| 149 | /** |
||
| 150 | * @var string View file for render product list content block |
||
| 151 | */ |
||
| 152 | public $listView = '@app/modules/shop/views/product/item-list'; |
||
| 153 | |||
| 154 | /** |
||
| 155 | * @inheritdoc |
||
| 156 | */ |
||
| 157 | public function behaviors() |
||
| 167 | |||
| 168 | /** |
||
| 169 | * Bootstrap method to be called during application bootstrap stage. |
||
| 170 | * @param Application $app the application currently running |
||
| 171 | */ |
||
| 172 | public function bootstrap($app) |
||
| 192 | |||
| 193 | /** |
||
| 194 | * @inheritdoc |
||
| 195 | */ |
||
| 196 | public function init() |
||
| 203 | |||
| 204 | /** @inheritdoc */ |
||
| 205 | public function getBackendGrids() |
||
| 220 | |||
| 221 | /** |
||
| 222 | * @return void |
||
| 223 | */ |
||
| 224 | public static function attachEventsHandlers() |
||
| 295 | } |
||
| 296 |
This error could be the result of:
1. Missing dependencies
PHP Analyzer uses your
composer.jsonfile (if available) to determine the dependencies of your project and to determine all the available classes and functions. It expects thecomposer.jsonto be in the root folder of your repository.Are you sure this class is defined by one of your dependencies, or did you maybe not list a dependency in either the
requireorrequire-devsection?2. Missing use statement
PHP does not complain about undefined classes in
ìnstanceofchecks. For example, the following PHP code will work perfectly fine:If you have not tested against this specific condition, such errors might go unnoticed.