We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.
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 |
||
| 35 | class DOM_Test extends PHP_Typography_Testcase { |
||
| 36 | |||
| 37 | /** |
||
| 38 | * HTML parser. |
||
| 39 | * |
||
| 40 | * @var \Masterminds\HTML5 |
||
| 41 | */ |
||
| 42 | private $parser; |
||
| 43 | |||
| 44 | /** |
||
| 45 | * Sets up the fixture, for example, opens a network connection. |
||
| 46 | * This method is called before a test is executed. |
||
| 47 | */ |
||
| 48 | protected function setUp() { // @codingStandardsIgnoreLine |
||
| 53 | |||
| 54 | /** |
||
| 55 | * Tears down the fixture, for example, closes a network connection. |
||
| 56 | * This method is called after a test is executed. |
||
| 57 | */ |
||
| 58 | protected function tearDown() { // @codingStandardsIgnoreLine |
||
| 60 | |||
| 61 | /** |
||
| 62 | * Load given HTML document. |
||
| 63 | * |
||
| 64 | * @param string $html An HTML document. |
||
| 65 | * |
||
| 66 | * @return \DOMDocument |
||
| 67 | */ |
||
| 68 | protected function load_html( $html ) { |
||
| 71 | |||
| 72 | /** |
||
| 73 | * Test block_tags. |
||
| 74 | * |
||
| 75 | * @covers ::block_tags |
||
| 76 | */ |
||
| 77 | public function test_block_tags() { |
||
| 96 | |||
| 97 | /** |
||
| 98 | * Test nodelist_to_array. |
||
| 99 | * |
||
| 100 | * @covers ::nodelist_to_array |
||
| 101 | */ |
||
| 102 | public function test_nodelist_to_array() { |
||
| 119 | |||
| 120 | /** |
||
| 121 | * Provide data for testing get_ancestors. |
||
| 122 | * |
||
| 123 | * @return array |
||
| 124 | */ |
||
| 125 | public function provide_get_ancestors_data() { |
||
| 130 | |||
| 131 | /** |
||
| 132 | * Test get_ancestors. |
||
| 133 | * |
||
| 134 | * @covers ::get_ancestors |
||
| 135 | * |
||
| 136 | * @uses ::nodelist_to_array |
||
| 137 | * |
||
| 138 | * @dataProvider provide_get_ancestors_data |
||
| 139 | * |
||
| 140 | * @param string $html HTML input. |
||
| 141 | * @param string $xpath_query XPath query. |
||
| 142 | */ |
||
| 143 | public function test_get_ancestors( $html, $xpath_query ) { |
||
| 159 | |||
| 160 | /** |
||
| 161 | * Provide data for testing has_class. |
||
| 162 | * |
||
| 163 | * @return array |
||
| 164 | */ |
||
| 165 | public function provide_has_class_data() { |
||
| 179 | |||
| 180 | /** |
||
| 181 | * Test has_class. |
||
| 182 | * |
||
| 183 | * @covers ::has_class |
||
| 184 | * |
||
| 185 | * @dataProvider provide_has_class_data |
||
| 186 | * |
||
| 187 | * @param string $html HTML input. |
||
| 188 | * @param string $xpath_query XPath query. |
||
| 189 | * @param array $classnames Array of classnames. |
||
| 190 | * @param bool $result Expected result. |
||
| 191 | */ |
||
| 192 | public function test_has_class( $html, $xpath_query, $classnames, $result ) { |
||
| 204 | |||
| 205 | /** |
||
| 206 | * Provides data for testing get_block_parent. |
||
| 207 | * |
||
| 208 | * @return array |
||
| 209 | */ |
||
| 210 | public function provide_get_block_parent_data() { |
||
| 222 | |||
| 223 | /** |
||
| 224 | * Test get_block_parent. |
||
| 225 | * |
||
| 226 | * @covers ::get_block_parent |
||
| 227 | * |
||
| 228 | * @dataProvider provide_get_block_parent_data |
||
| 229 | * |
||
| 230 | * @param string $input_xpath Input element/node. |
||
| 231 | * @param string $parent_xpath Expected result element. |
||
| 232 | * @param string $parent_tag Parent tag name. |
||
| 233 | * @param string $html HTML code. |
||
| 234 | */ |
||
| 235 | public function test_get_block_parent( $input_xpath, $parent_xpath, $parent_tag, $html ) { |
||
| 253 | |||
| 254 | /** |
||
| 255 | * Test get_block_parent_name. |
||
| 256 | * |
||
| 257 | * @covers ::get_block_parent_name |
||
| 258 | * |
||
| 259 | * @uses ::get_block_parent |
||
| 260 | * |
||
| 261 | * @dataProvider provide_get_block_parent_data |
||
| 262 | * |
||
| 263 | * @param string $input_xpath Input element/node. |
||
| 264 | * @param string $parent_xpath Ignored. |
||
| 265 | * @param string $parent_tag Parent tag name. |
||
| 266 | * @param string $html HTML code. |
||
| 267 | */ |
||
| 268 | View Code Duplication | public function test_get_block_parent_name( $input_xpath, $parent_xpath, $parent_tag, $html ) { |
|
| 276 | |||
| 277 | /** |
||
| 278 | * Test get_prev_chr. |
||
| 279 | * |
||
| 280 | * @covers ::get_prev_chr |
||
| 281 | * @covers ::get_adjacent_chr |
||
| 282 | * @covers ::get_previous_textnode |
||
| 283 | * @covers ::get_adjacent_textnode |
||
| 284 | * |
||
| 285 | * @uses ::get_last_textnode |
||
| 286 | * @uses ::get_edge_textnode |
||
| 287 | * @uses PHP_Typography\Strings::functions |
||
| 288 | */ |
||
| 289 | View Code Duplication | public function test_get_prev_chr() { |
|
| 302 | |||
| 303 | /** |
||
| 304 | * Test get_previous_textnode. |
||
| 305 | * |
||
| 306 | * @covers ::get_previous_textnode |
||
| 307 | * @covers ::get_adjacent_textnode |
||
| 308 | */ |
||
| 309 | public function test_get_previous_textnode_null() { |
||
| 313 | |||
| 314 | /** |
||
| 315 | * Test get_next_chr. |
||
| 316 | * |
||
| 317 | * @covers ::get_next_chr |
||
| 318 | * @covers ::get_adjacent_chr |
||
| 319 | * @covers ::get_next_textnode |
||
| 320 | * @covers ::get_adjacent_textnode |
||
| 321 | * |
||
| 322 | * @uses ::get_first_textnode |
||
| 323 | * @uses ::get_edge_textnode |
||
| 324 | * @uses PHP_Typography\Strings::functions |
||
| 325 | */ |
||
| 326 | View Code Duplication | public function test_get_next_chr() { |
|
| 339 | |||
| 340 | /** |
||
| 341 | * Test get_next_textnode. |
||
| 342 | * |
||
| 343 | * @covers ::get_next_textnode |
||
| 344 | * @covers ::get_adjacent_textnode |
||
| 345 | */ |
||
| 346 | public function test_get_next_textnode_null() { |
||
| 350 | |||
| 351 | |||
| 352 | /** |
||
| 353 | * Test get_first_textnode. |
||
| 354 | * |
||
| 355 | * @covers ::get_first_textnode |
||
| 356 | * @covers ::get_edge_textnode |
||
| 357 | */ |
||
| 358 | View Code Duplication | public function test_get_first_textnode() { |
|
| 379 | |||
| 380 | /** |
||
| 381 | * Test get_first_textnode. |
||
| 382 | * |
||
| 383 | * @covers ::get_first_textnode |
||
| 384 | * @covers ::get_edge_textnode |
||
| 385 | */ |
||
| 386 | public function test_get_first_textnode_null() { |
||
| 393 | |||
| 394 | /** |
||
| 395 | * Test get_first_textnode. |
||
| 396 | * |
||
| 397 | * @covers ::get_first_textnode |
||
| 398 | * @covers ::get_edge_textnode |
||
| 399 | */ |
||
| 400 | View Code Duplication | public function test_get_first_textnode_only_block_level() { |
|
| 409 | |||
| 410 | /** |
||
| 411 | * Test get_last_textnode. |
||
| 412 | * |
||
| 413 | * @covers ::get_last_textnode |
||
| 414 | * @covers ::get_edge_textnode |
||
| 415 | * |
||
| 416 | * @uses ::get_first_textnode |
||
| 417 | */ |
||
| 418 | View Code Duplication | public function test_get_last_textnode() { |
|
| 440 | |||
| 441 | /** |
||
| 442 | * Test get_last_textnode. |
||
| 443 | * |
||
| 444 | * @covers ::get_last_textnode |
||
| 445 | * @covers ::get_edge_textnode |
||
| 446 | */ |
||
| 447 | public function test_get_last_textnode_null() { |
||
| 454 | |||
| 455 | |||
| 456 | /** |
||
| 457 | * Test get_last_textnode. |
||
| 458 | * |
||
| 459 | * @covers ::get_last_textnode |
||
| 460 | * @covers ::get_edge_textnode |
||
| 461 | */ |
||
| 462 | View Code Duplication | public function test_get_last_textnode_only_block_level() { |
|
| 471 | } |
||
| 472 |
An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.
If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.