subjective-php /
spl-traits
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
| 1 | <?php |
||
| 2 | |||
| 3 | namespace SubjectivePHPTest\Spl\Traits; |
||
| 4 | |||
| 5 | use SubjectivePHP\Spl\Traits\MagicPropertyDisabledTrait; |
||
| 6 | |||
| 7 | /** |
||
| 8 | * @coversDefaultClass SubjectivePHP\Spl\Traits\MagicPropertyDisabledTrait |
||
| 9 | */ |
||
| 10 | class MagicPropertyDisabledTraitTest extends \PHPUnit\Framework\TestCase |
||
| 11 | { |
||
| 12 | /** |
||
| 13 | * @test |
||
| 14 | * @covers ::__get |
||
| 15 | * @expectedException \BadMethodCallException |
||
| 16 | */ |
||
| 17 | public function magicGet() |
||
| 18 | { |
||
| 19 | $value = $this->getObject()->foo; |
||
|
0 ignored issues
–
show
|
|||
| 20 | } |
||
| 21 | |||
| 22 | /** |
||
| 23 | * @test |
||
| 24 | * @covers ::__set |
||
| 25 | * @expectedException \BadMethodCallException |
||
| 26 | */ |
||
| 27 | public function magicSet() |
||
| 28 | { |
||
| 29 | $this->getObject()->foo = 'bar'; |
||
| 30 | } |
||
| 31 | |||
| 32 | public function getObject() |
||
| 33 | { |
||
| 34 | return new class |
||
| 35 | { |
||
| 36 | use MagicPropertyDisabledTrait; |
||
| 37 | }; |
||
| 38 | } |
||
| 39 | } |
||
| 40 |
This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.
Both the
$myVarassignment in line 1 and the$higherassignment in line 2 are dead. The first because$myVaris never used and the second because$higheris always overwritten for every possible time line.