Completed
Pull Request — master (#209)
by Enrico
03:57
created

YieldFrom   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 5

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 19
rs 10
c 1
b 0
f 0
wmc 1
lcom 0
cbo 5

1 Method

Rating   Name   Duplication   Size   Complexity  
A compile() 0 7 1
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