Completed
Push — master ( 68bd43...22e0e3 )
by Дмитрий
02:33
created

ArrayShortDefinition   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 100%

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A pass() 0 14 2
1
<?php
2
/**
3
 * @author Patsura Dmitry https://github.com/ovr <[email protected]>
4
 */
5
6
namespace PHPSA\Analyzer\Pass\Expression;
7
8
use PhpParser\Node\Expr;
9
use PHPSA\Compiler\Expression;
10
use PHPSA\Context;
11
12
class ArrayShortDefinition
13
{
14
    /**
15
     * @param Expr\Array_ $expr
16
     * @param Context $context
17
     * @return bool
18
     */
19 2
    public function pass(Expr\Array_ $expr, Context $context)
20
    {
21 2
        if ($expr->getAttribute('kind') == Expr\Array_::KIND_LONG) {
22 1
            $context->notice(
23 1
                'array.short-syntax',
24 1
                'Please use [] (short syntax) for array definition.',
25 1
                $expr
26 1
            );
27
28 1
            return true;
29
        }
30
31 1
        return false;
32
    }
33
}
34