1

Magento 2 module testing tools gives error "short array syntax not allowed",

we do code like following

public function toOptionArray()
    {
        return [
            ['value' => 0, 'label' => __('Disable')],
            ['value' => 1, 'label' => __('Enable')],

        ];
    }

Here is screenshot

enter image description here

Can any one tell me how can i solve this?

2
  • which php version you are using ? Commented Nov 25, 2017 at 6:54
  • i use 7.0.24 php version. Commented Nov 25, 2017 at 7:45

1 Answer 1

2

This is because the Marketplace coding standard enforces the old long array syntax array() instead of [] for historic reasons.

You have three options:

In the Magento repository itself it is already the other way around: the short array syntax is enforced: https://github.com/magento/magento2/blob/2.2-develop/dev/tests/static/framework/Magento/Sniffs/Arrays/ShortArraySyntaxSniff.php

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.