Completed
Push — master ( b59b39...7e1c48 )
by Дмитрий
03:46
created

ArgumentUnpacking::pass()   B

Complexity

Conditions 5
Paths 4

Size

Total Lines 18
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 14
CRAP Score 5

Importance

Changes 2
Bugs 0 Features 2
Metric Value
cc 5
eloc 11
c 2
b 0
f 2
nc 4
nop 2
dl 0
loc 18
rs 8.8571
ccs 14
cts 14
cp 1
crap 5
1
<?php
2
3
namespace PHPSA\Analyzer\Pass\Expression\FunctionCall;
4
5
use PhpParser\Node\Expr\FuncCall;
6
use PhpParser\Node\Name;
7
use PHPSA\Compiler\Expression;
8
use PHPSA\Context;
9
use PHPSA\Definition\ClassMethod;
10
use PHPSA\Definition\FunctionDefinition;
11
12
class ArgumentUnpacking extends AbstractFunctionCallAnalyzer
13
{
14
15 8
    public function pass(FuncCall $funcCall, Context $context)
16
    {
17 8
        $functionName = $this->resolveFunctionName($funcCall, $context);
18 8
        if ($functionName === "func_get_args") {
19 1
            $scopePointer = $context->scopePointer->getObject();
20
            
21 1
            if ($scopePointer instanceof ClassMethod || $scopePointer instanceof FunctionDefinition) {
22 1
                if (count($scopePointer->getParams()) === 0) {
23 1
                    $context->notice(
24 1
                        'fcall.argumentunpacking',
25 1
                        sprintf('Please use argument unpacking (...) instead of func_get_args().'),
26
                        $funcCall
27 1
                    );
28 1
                    return;
29
                }
30 1
            }
31 1
        }
32 8
    }
33
}
34