Failed Conditions
Pull Request — master (#16)
by Chad
01:34
created

tests/MagicPropertyDisabledTraitTest.php (1 issue)

Severity

Upgrade to new PHP Analysis Engine

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
$value is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
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