Completed
Push — master ( d93213...2ca6bd )
by Дмитрий
02:41
created

ArgumentUnpacking::pass()   A

Complexity

Conditions 4
Paths 4

Size

Total Lines 18
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 12
CRAP Score 4.0466

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 4
eloc 11
c 1
b 0
f 1
nc 4
nop 2
dl 0
loc 18
ccs 12
cts 14
cp 0.8571
crap 4.0466
rs 9.2
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
11
class ArgumentUnpacking extends AbstractFunctionCallAnalyzer
12
{
13
14 6
    public function pass(FuncCall $funcCall, Context $context)
15
    {
16 6
        $functionName = $this->resolveFunctionName($funcCall, $context);
17 6
        if ($functionName === "func_get_args") {
18 1
            $scopePointer = $context->scopePointer->getObject();
19
20 1
            if ($scopePointer instanceof ClassMethod) {
21 1
                if (count($scopePointer->getParams()) === 0) {
22 1
                    $context->notice(
23 1
                        'fcall.argumentunpacking',
24 1
                        sprintf('Please use argument unpacking (...) instead of func_get_args().'),
25
                        $funcCall
26 1
                    );
27 1
                    return;
28
                }
29
            }
30
        }
31 5
    }
32
}
33