Completed
Push — master ( 6c3584...3bd08b )
by Дмитрий
02:31
created

ArrayShortDefinition   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 4

Test Coverage

Coverage 0%

Importance

Changes 2
Bugs 0 Features 0
Metric Value
c 2
b 0
f 0
dl 0
loc 27
ccs 0
cts 18
cp 0
rs 10
wmc 4
lcom 0
cbo 4

1 Method

Rating   Name   Duplication   Size   Complexity  
B pass() 0 24 4
1
<?php
2
/**
3
 * @author Patsura Dmitry https://github.com/ovr <[email protected]>
4
 */
5
6
namespace PHPSA\Analyzer\Pass\FunctionCall;
7
8
use PhpParser\Node\Expr\FuncCall;
9
use PhpParser\Node\Name;
10
use PHPSA\Compiler\Expression;
11
use PHPSA\Context;
12
13
class ArrayShortDefinition implements PassFunctionCallInterface
14
{
15
    public function pass(FuncCall $funcCall, Context $context)
16
    {
17
        $compiler = $context->getExpressionCompiler();
18
        $funcNameCompiledExpression = $compiler->compile($funcCall->name);
0 ignored issues
show
Comprehensibility Naming introduced by
The variable name $funcNameCompiledExpression exceeds the maximum configured length of 20.

Very long variable names usually make code harder to read. It is therefore recommended not to make variable names too verbose.

Loading history...
19
20
        if ($funcNameCompiledExpression->isString() && $funcNameCompiledExpression->isCorrectValue()) {
21
            $name = $funcNameCompiledExpression->getValue();
22
        } else {
23
            $context->debug(
24
                'Unexpected function name type ' . $funcNameCompiledExpression->getType(),
25
                $funcCall->name
26
            );
27
28
            return false;
29
        }
30
31
        if ($name == 'array') {
32
            $context->notice(
33
                'array.short-syntax',
34
                'Please use [] (short syntax) for array definition.',
35
                $funcCall
36
            );
37
        }
38
    }
39
}
40