Completed
Pull Request — master (#139)
by Kévin
22:48 queued 19:51
created

VariableVariableUsage::getConfiguration()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 5
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 9
ccs 0
cts 5
cp 0
crap 2
rs 9.6666
1
<?php
2
/**
3
 * @author Kévin Gomez https://github.com/K-Phoen <[email protected]>
4
 */
5
6
namespace PHPSA\Analyzer\Pass\Expression;
7
8
use PhpParser\Node\Expr;
9
use PHPSA\Analyzer\Helper\ConfigurablePassTrait;
10
use PHPSA\Analyzer\Pass;
11
use PHPSA\Context;
12
13
class VariableVariableUsage implements Pass\AnalyzerPassInterface, Pass\ConfigurablePassInterface
14
{
15
    use ConfigurablePassTrait;
16
17
    /**
18
     * @param Expr\Assign $expr
19
     * @param Context $context
20
     * @return bool
21
     */
22 11
    public function pass(Expr\Assign $expr, Context $context)
23
    {
24 11
        if ($expr->var->name instanceof Expr\Variable) {
0 ignored issues
show
Bug introduced by
The property name does not seem to exist in PhpParser\Node\Expr.

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
25 1
            $context->notice(
26 1
                'variable.dynamic_assignment',
27 1
                'Dynamic assignment is greatly discouraged.',
28
                $expr
29 1
            );
30
31 1
            return true;
32
        }
33
34 11
        return false;
35
    }
36
37
    /**
38
     * @return array
39
     */
40 1
    public function getRegister()
41
    {
42
        return [
43
            Expr\Assign::class
44 1
        ];
45
    }
46
}
47