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

ArrayShortDefinition::pass()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 14
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 9
CRAP Score 2

Importance

Changes 2
Bugs 0 Features 0
Metric Value
cc 2
eloc 8
c 2
b 0
f 0
nc 2
nop 2
dl 0
loc 14
ccs 9
cts 9
cp 1
crap 2
rs 9.4285
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