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

VariableVariableUsage   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 34
ccs 10
cts 10
cp 1
rs 10
c 1
b 0
f 0
wmc 3
lcom 0
cbo 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A pass() 0 14 2
A getRegister() 0 6 1
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