1 | <?php |
||
13 | class ArrayShortDefinition implements AnalyzerPassInterface |
||
14 | { |
||
15 | use DefaultMetadataPassTrait { |
||
16 | DefaultMetadataPassTrait::getMetadata as defaultMetadata; |
||
17 | } |
||
18 | |||
19 | const DESCRIPTION = 'Short syntax can be used in array literals.'; |
||
20 | |||
21 | /** |
||
22 | * @param Expr\Array_ $expr |
||
23 | * @param Context $context |
||
24 | * @return bool |
||
25 | */ |
||
26 | 28 | public function pass(Expr\Array_ $expr, Context $context) |
|
27 | { |
||
28 | 28 | if ($expr->getAttribute('kind') == Expr\Array_::KIND_LONG) { |
|
29 | 2 | $context->notice( |
|
30 | 2 | 'array.short-syntax', |
|
31 | 2 | 'Please use [] (short syntax) for array definition.', |
|
32 | $expr |
||
33 | 2 | ); |
|
34 | |||
35 | 2 | return true; |
|
36 | } |
||
37 | |||
38 | 27 | return false; |
|
39 | } |
||
40 | |||
41 | /** |
||
42 | * @return array |
||
43 | */ |
||
44 | 1 | public function getRegister() |
|
50 | |||
51 | /** |
||
52 | * {@inheritdoc} |
||
53 | */ |
||
54 | 1 | public static function getMetadata() |
|
61 | } |
||
62 |