Completed
Push — master ( 8419d7...269912 )
by Дмитрий
03:29
created

EvalUsage   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
dl 0
loc 32
ccs 0
cts 8
cp 0
rs 10
c 0
b 0
f 0
wmc 2
lcom 0
cbo 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A pass() 0 10 1
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\DefaultMetadataPassTrait;
10
use PHPSA\Analyzer\Pass\AnalyzerPassInterface;
11
use PHPSA\Context;
12
13
class EvalUsage implements AnalyzerPassInterface
14
{
15
    use DefaultMetadataPassTrait;
16
17
    const DESCRIPTION = 'Discourages the use of `eval()`.';
18
19
    /**
20
     * @param Expr\Eval_ $expr
21
     * @param Context $context
22
     * @return bool
23
     */
24
    public function pass(Expr\Eval_ $expr, Context $context)
25
    {
26
        $context->notice(
27
            'eval_usage',
28
            'Using eval is discouraged.',
29
            $expr
30
        );
31
32
        return true;
33
    }
34
35
    /**
36
     * {@inheritdoc}
37
     */
38
    public function getRegister()
39
    {
40
        return [
41
            Expr\Eval_::class
42
        ];
43
    }
44
}
45