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 |
||
| 11 | class PanelsInPlaceContext extends DrupalSubContextBase { |
||
| 12 | |||
| 13 | /** |
||
| 14 | * The Mink context. |
||
| 15 | * |
||
| 16 | * @var MinkContext |
||
| 17 | */ |
||
| 18 | protected $minkContext; |
||
| 19 | |||
| 20 | /** |
||
| 21 | * Gathers required contexts. |
||
| 22 | * |
||
| 23 | * @BeforeScenario |
||
| 24 | */ |
||
| 25 | public function gatherContexts() { |
||
| 28 | |||
| 29 | /** |
||
| 30 | * Returns the active Panels IPE tab's contents. |
||
| 31 | * |
||
| 32 | * @return \Behat\Mink\Element\NodeElement |
||
| 33 | * The active tab's contents. |
||
| 34 | */ |
||
| 35 | protected function getActiveTab() { |
||
| 39 | |||
| 40 | /** |
||
| 41 | * Asserts the presence of the Panels IPE tray. |
||
| 42 | * |
||
| 43 | * @return \Behat\Mink\Element\NodeElement |
||
| 44 | * The Panels IPE tray element. |
||
| 45 | * |
||
| 46 | * @Then I should see the Panels IPE tray |
||
| 47 | */ |
||
| 48 | public function assertTray() { |
||
| 51 | |||
| 52 | /** |
||
| 53 | * Opens a tab of the Panels IPE tray. |
||
| 54 | * |
||
| 55 | * @param string $tab |
||
| 56 | * The title of the tab to activate. |
||
| 57 | * |
||
| 58 | * @return \Behat\Mink\Element\NodeElement |
||
| 59 | * The tab contents. |
||
| 60 | * |
||
| 61 | * @When I open the :tab tab |
||
| 62 | */ |
||
| 63 | public function openTab($tab) { |
||
| 81 | |||
| 82 | /** |
||
| 83 | * Opens a particular block category of the "Manage Content" tab. |
||
| 84 | * |
||
| 85 | * @param string $category |
||
| 86 | * The category to open. |
||
| 87 | * |
||
| 88 | * @return \Behat\Mink\Element\NodeElement |
||
| 89 | * The tab contents. |
||
| 90 | * |
||
| 91 | * @When I open the :category category |
||
| 92 | */ |
||
| 93 | public function openCategory($category) { |
||
| 111 | |||
| 112 | /** |
||
| 113 | * Asserts that a particular block plugin is available. |
||
| 114 | * |
||
| 115 | * @param string $plugin_id |
||
| 116 | * The block plugin ID. |
||
| 117 | * @param string $category |
||
| 118 | * (optional) The category to open. |
||
| 119 | * |
||
| 120 | * @return \Behat\Mink\Element\NodeElement |
||
| 121 | * The link to instantiate the block plugin. |
||
| 122 | * |
||
| 123 | * @Then I should see the :plugin_id plugin |
||
| 124 | * @Then I should see the :plugin_id plugin in the :category category |
||
| 125 | */ |
||
| 126 | View Code Duplication | public function assertBlockPluginExists($plugin_id, $category = NULL) { |
|
| 134 | |||
| 135 | /** |
||
| 136 | * Asserts that a particular block plugin is not available. |
||
| 137 | * |
||
| 138 | * @param string $plugin_id |
||
| 139 | * The block plugin ID. |
||
| 140 | * @param string $category |
||
| 141 | * (optional) The category to open. |
||
| 142 | * |
||
| 143 | * @Then I should not see the :plugin_id plugin |
||
| 144 | * @Then I should not see the :plugin_id plugin in the :category category |
||
| 145 | */ |
||
| 146 | View Code Duplication | public function assertBlockPluginNotExists($plugin_id, $category = NULL) { |
|
| 154 | |||
| 155 | /** |
||
| 156 | * Instantiates a block plugin. |
||
| 157 | * |
||
| 158 | * @param string $plugin_id |
||
| 159 | * The block plugin ID. |
||
| 160 | * @param string $category |
||
| 161 | * (optional) The category in which the block plugin resides. |
||
| 162 | * |
||
| 163 | * @return \Behat\Mink\Element\NodeElement |
||
| 164 | * The block plugin configuration form. |
||
| 165 | * |
||
| 166 | * @When I instantiate the :plugin_id block |
||
| 167 | * @When I instantiate the :plugin_id block from the :category category |
||
| 168 | */ |
||
| 169 | public function instantiateBlock($plugin_id, $category = NULL) { |
||
| 178 | |||
| 179 | /** |
||
| 180 | * Saves the current IPE layout as a custom layout. |
||
| 181 | * |
||
| 182 | * @When I save the layout |
||
| 183 | */ |
||
| 184 | public function saveLayout() { |
||
| 195 | |||
| 196 | /** |
||
| 197 | * Places a block into a Panels IPE layout. |
||
| 198 | * |
||
| 199 | * @param string $plugin_id |
||
| 200 | * The block plugin ID. |
||
| 201 | * @param string $category |
||
| 202 | * (optional) The category in which the block plugin resides. |
||
| 203 | * |
||
| 204 | * @When I place the :plugin_id block from the :category category |
||
| 205 | * @When I place the :plugin_id block |
||
| 206 | */ |
||
| 207 | public function placeBlock($plugin_id, $category = NULL) { |
||
| 213 | |||
| 214 | /** |
||
| 215 | * Reverts a panelized layout to its default state. |
||
| 216 | * |
||
| 217 | * @When I revert the layout |
||
| 218 | */ |
||
| 219 | public function revertLayout() { |
||
| 226 | |||
| 227 | /** |
||
| 228 | * Opens the moderation sidebar. |
||
| 229 | * |
||
| 230 | * @When I open the moderation sidebar |
||
| 231 | */ |
||
| 232 | public function openModerationSidebar() { |
||
| 248 | |||
| 249 | /** |
||
| 250 | * Close the Panels IPE tray. |
||
| 251 | * |
||
| 252 | * @When I close the editor |
||
| 253 | */ |
||
| 254 | public function closeEditor() { |
||
| 268 | |||
| 269 | } |
||
| 270 |
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.
Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..