Completed
Push — master ( 9b2dbf...68bd43 )
by Дмитрий
02:56
created

AliasCheck::pass()   A

Complexity

Conditions 3
Paths 2

Size

Total Lines 11
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 12

Importance

Changes 2
Bugs 0 Features 1
Metric Value
cc 3
eloc 7
c 2
b 0
f 1
nc 2
nop 2
dl 0
loc 11
ccs 0
cts 9
cp 0
crap 12
rs 9.4285
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
    public function pass(FuncCall $funcCall, Context $context)
24
    {
25
        $functionName = $this->resolveFunctionName($funcCall, $context);
26
        if ($functionName && isset($this->map[$functionName])) {
27
            $context->notice(
28
                'fcall.alias',
29
                sprintf('%s() is an alias of function. Use %s(...).', $functionName, $this->map[$functionName]),
30
                $funcCall
31
            );
32
        }
33
    }
34
}
35