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

BacktickUsage::pass()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 10

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 2
dl 0
loc 10
ccs 0
cts 6
cp 0
crap 2
rs 9.9332
c 0
b 0
f 0
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