Completed
Pull Request — master (#209)
by Enrico
13:14
created

YieldFrom::compile()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

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