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?

  • which php version you are using ? – Chander Shekhar Nov 25 '17 at 6:54
  • i use 7.0.24 php version. – Bharat Desai Nov 25 '17 at 7:45

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, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.