Completed
Pull Request — master (#116)
by Enrico
04:25
created

UnsetCast::compile()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 3
nc 1
nop 2
dl 0
loc 6
ccs 3
cts 3
cp 1
crap 1
rs 9.4285
c 1
b 0
f 0
1
<?php
2
3
namespace PHPSA\Compiler\Expression\Casts;
4
5
use PHPSA\CompiledExpression;
6
use PHPSA\Context;
7
use PHPSA\Compiler\Expression;
8
use PHPSA\Compiler\Expression\AbstractExpressionCompiler;
9
10
class UnsetCast extends AbstractExpressionCompiler
11
{
12
    protected $name = 'PhpParser\Node\Expr\Cast\Unset_';
13
14
    /**
15
     * (unset) {$expr}
16
     *
17
     * @param \PhpParser\Node\Expr\Cast\Unset_ $expr
18
     * @param Context $context
19
     * @return CompiledExpression
20
     */
21 1
    protected function compile($expr, Context $context)
22
    {
23 1
        $compiledExpression = $context->getExpressionCompiler()->compile($expr->expr);
0 ignored issues
show
Unused Code introduced by
$compiledExpression 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...
24
25 1
        return new CompiledExpression(CompiledExpression::NULL, null);
26
    }
27
}
28