This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 252822 - PHP auto format problem
Summary: PHP auto format problem
Status: RESOLVED WORKSFORME
Alias: None
Product: php
Classification: Unclassified
Component: Formatting & Indentation (show other bugs)
Version: 8.0.2
Hardware: All All
: P3 normal (vote)
Assignee: Tomas Mysik
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-06-05 02:39 UTC by xjflyttp
Modified: 2016-06-07 14:43 UTC (History)
1 user (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
IDE log (38.48 KB, text/plain)
2015-06-05 02:39 UTC, xjflyttp
Details

Note You need to log in before you can comment on or make changes to this bug.
Description xjflyttp 2015-06-05 02:39:37 UTC
Product Version = NetBeans IDE 8.0.2 (Build 201411181905)
Operating System = Windows 7 version 6.1 running on amd64
Java; VM; Vendor = 1.7.0_71
Runtime = Java HotSpot(TM) 64-Bit Server VM 24.71-b01


Begin at "if ($archiveStatus) {"
Closure format indentation is wrong.




<?php

namespace backend\models\search;

use Yii;
use yii\base\Model;
use yii\data\ActiveDataProvider;
use common\models\AddonAritcle;
use common\models\Archive;

/**
 * AddonAritcleSearch represents the model behind the search form about `common\models\AddonAritcle`.
 */
class AddonAritcleSearch extends AddonAritcle
{

    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['aid'], 'integer'],
            [['content', 'archive.status'], 'safe'],
        ];
    }

    public function attributes()
    {
        return array_merge(parent::attributes(), ['archive.status']);
    }

    /**
     * @inheritdoc
     */
    public function scenarios()
    {
        // bypass scenarios() implementation in the parent class
        return Model::scenarios();
    }

    /**
     * Creates data provider instance with search query applied
     *
     * @param array $params
     *
     * @return ActiveDataProvider
     */
    public function search($params)
    {
        $query = AddonAritcle::find()
                ->from(['article' => AddonAritcle::tableName()])
                ->with(['archive.channel' => function($query) {
                    $query->from(['channel' => \common\models\Channel::tableName()])
                            ->select(['channel.id', 'channel.channel_name']);
                }]);

        $dataProvider = new ActiveDataProvider([
            'query' => $query,
        ]);

        $this->load($params);

        if (!$this->validate()) {
            return $dataProvider;
        }


        //get value
        $archiveStatus = $this->getAttribute('archive.status');

        if ($archiveStatus) {
            $query->joinWith([
                'archive' => function($query) {
                    $query->from(['archive' => Archive::tableName()]);
                    $query->select(['archive.aid', 'archive.channel_id', 'archive.status', 'archive.title', 'archive.click', 'archive.top1', 'archive.top2']);
                }]);
                    $query->andFilterWhere([
                        'archive.status' => $this->getAttribute('archive.status'),
                    ]);
                } else {
                    $query->with([
                        'archive' => function($query) {
                            $query->select(['status', 'title','click', 'top1', 'top2']);
                        },
                    ]);
                }

                $query->andFilterWhere([
                    'article.aid' => $this->aid,
                ]);

                $query->andFilterWhere(['like', 'article.content', $this->content]);

                return $dataProvider;
            }

        }
Comment 1 xjflyttp 2015-06-05 02:39:41 UTC
Created attachment 154063 [details]
IDE log
Comment 2 Tomas Mysik 2016-06-07 14:43:54 UTC
IMHO your source code should look like this:

--------------------------------------------------------
            $query->joinWith([
                'archive' => function($query) {
                    $query->from(['archive' => Archive::tableName()]);
                    $query->select(['archive.aid', 'archive.channel_id', 'archive.status', 'archive.title', 'archive.click', 'archive.top1', 'archive.top2']);
                }
            ]);
--------------------------------------------------------

I mean that the chars "}])" should not be "grouped" together because then it is not possible to decide properly where exactly these chars should be placed. Also, please note that these chars, their "opening" variants, are not "grouped" at all.

Thanks for reporting.