Completed
Push — master ( b7cb0e...ffcfdb )
by Дмитрий
02:53
created

AliasCheck   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 100%

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A pass() 0 11 3
1
<?php
2
/**
3
 * @author Patsura Dmitry https://github.com/ovr <[email protected]>
4
 */
5
6
namespace PHPSA\Analyzer\Pass\Expression\FunctionCall;
7
8
use PhpParser\Node\Expr\FuncCall;
9
use PhpParser\Node\Name;
10
use PHPSA\Analyzer\Helper\ResolveExpressionTrait;
11
use PHPSA\Compiler\Expression;
12
use PHPSA\Context;
13
14
class AliasCheck implements PassFunctionCallInterface
15
{
16
    use ResolveExpressionTrait;
17
18
    protected $map = array(
19
        'join' => 'implode',
20
        'sizeof' => 'count'
21
    );
22
23 5
    public function pass(FuncCall $funcCall, Context $context)
24
    {
25 5
        $functionName = $this->resolveFunctionName($funcCall, $context);
26 5
        if ($functionName && isset($this->map[$functionName])) {
27 1
            $context->notice(
28 1
                'fcall.alias',
29 1
                sprintf('%s() is an alias of function. Use %s(...).', $functionName, $this->map[$functionName]),
30
                $funcCall
31 1
            );
32 1
        }
33 5
    }
34
}
35