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

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.

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