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

BacktickUsage   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
namespace PHPSA\Analyzer\Pass\Expression;
4
5
use PhpParser\Node\Expr;
6
use PHPSA\Analyzer\Helper\DefaultMetadataPassTrait;
7
use PHPSA\Analyzer\Pass\AnalyzerPassInterface;
8
use PHPSA\Context;
9
10
class BacktickUsage implements AnalyzerPassInterface
11
{
12
    use DefaultMetadataPassTrait;
13
14
    const DESCRIPTION = 'Discourages the use of backtick operator for shell execution.';
15
16
    /**
17
     * @param Expr\ShellExec $expr
18
     * @param Context $context
19
     * @return bool
20
     */
21
    public function pass(Expr\ShellExec $expr, Context $context)
22
    {
23
        $context->notice(
24
            'backtick_usage',
25
            'It\'s bad practice to use the backtick operator for shell execution',
26
            $expr
27
        );
28
29
        return true;
30
    }
31
32
    /**
33
     * {@inheritdoc}
34
     */
35
    public function getRegister()
36
    {
37
        return [
38
            Expr\ShellExec::class
39
        ];
40
    }
41
}
42