These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
| 1 | <?php |
||
| 2 | /** |
||
| 3 | * Parentheses around function parameters throws warning in PHP 7.0 |
||
| 4 | * |
||
| 5 | * @package PHPCompatibility |
||
| 6 | */ |
||
| 7 | |||
| 8 | |||
| 9 | /** |
||
| 10 | * Parentheses around function parameters throws warning in PHP 7.0 |
||
| 11 | * |
||
| 12 | * @uses BaseSniffTest |
||
| 13 | * @package PHPCompatibility |
||
| 14 | * @author Jansen Price <[email protected]> |
||
| 15 | */ |
||
| 16 | View Code Duplication | class ForbiddenSwitchWithMultipleDefaultBlocksSniffTest extends BaseSniffTest |
|
|
0 ignored issues
–
show
|
|||
| 17 | { |
||
| 18 | /** |
||
| 19 | * testSettingTestVersion |
||
| 20 | * |
||
| 21 | * @return void |
||
| 22 | */ |
||
| 23 | public function testSettingTestVersion() |
||
| 24 | { |
||
| 25 | $file = $this->sniffFile('sniff-examples/forbidden_switch_with_multiple_default_blocks.php', '5.6'); |
||
| 26 | $this->assertNoViolation($file, 3); |
||
| 27 | $this->assertNoViolation($file, 14); |
||
| 28 | $this->assertNoViolation($file, 23); |
||
| 29 | |||
| 30 | $file = $this->sniffFile('sniff-examples/forbidden_switch_with_multiple_default_blocks.php', '7.0'); |
||
| 31 | $this->assertError($file, 3, 'Switch statements can not have multiple default blocks since PHP 7.0'); |
||
| 32 | $this->assertNoViolation($file, 14); |
||
| 33 | $this->assertNoViolation($file, 23); |
||
| 34 | } |
||
| 35 | } |
||
| 36 | |||
| 37 |
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.