yiisoft / yii2-coding-standards

Yii 2 coding standards
182 stars 49 forks source link

Line indented incorrectly in rules #15

Closed githubjeka closed 9 years ago

githubjeka commented 10 years ago

This code not valid for phpcs:

<?php
namespace test;

class NEW1
{
    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['date'], 'date'],
            [
                ['ip_manual'],
                'filter',
                'filter' => function ($v) {
                        if ($this->operator == 3 || $this->operator == 4) { //here
                            return null;
                        }
                        return $v;
                    } //and here
            ],
        ];
    }
}

PHPCS requires ugly operations from me:

<?php
namespace test;

class NEW1
{
    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['date'], 'date'],
            [
                ['ip_manual'],
                'filter',
                'filter' => function ($v) {
            if ($this->operator == 3 || $this->operator == 4) {
                return null;
            }
            return $v;
                }
            ],
        ];
    }
}
samdark commented 9 years ago

I think it's a bug in PHPCS.