Skip to content

Commit fb39db4

Browse files
committed
php-cs-fixed
1 parent 427dc71 commit fb39db4

13 files changed

+521
-332
lines changed

.php_cs

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
<?php
2+
3+
$header = <<<EOF
4+
Tools to use API as ActiveRecord for Yii2
5+
6+
@link https://github.com/hiqdev/yii2-hiart
7+
@package yii2-hiart
8+
@license BSD-3-Clause
9+
@copyright Copyright (c) 2015, HiQDev (https://hiqdev.com/)
10+
EOF;
11+
12+
Symfony\CS\Fixer\Contrib\HeaderCommentFixer::setHeader($header);
13+
14+
return Symfony\CS\Config\Config::create()
15+
->level(Symfony\CS\FixerInterface::SYMFONY_LEVEL)
16+
->fixers([
17+
'-long_array_syntax', /// Arrays should use the long syntax.
18+
'-php4_constructor', /// Convert PHP4-style constructors to __construct. Warning! This could change code behavior.
19+
'-phpdoc_var_to_type', /// @var should always be written as @type.
20+
'header_comment', /// Add, replace or remove header comment.
21+
'align_double_arrow', /// Align double arrow symbols in consecutive lines.
22+
'align_equals', /// Align equals symbols in consecutive lines.
23+
'concat_with_spaces', /// Concatenation should be used with at least one whitespace around.
24+
'ereg_to_preg', /// Replace deprecated ereg regular expression functions with preg. Warning! This could change code behavior.
25+
'multiline_spaces_before_semicolon', /// Multi-line whitespace before closing semicolon are prohibited.
26+
'newline_after_open_tag', /// Ensure there is no code on the same line as the PHP open tag.
27+
'single_blank_line_before_namespace', /// There should be no blank lines before a namespace declaration.
28+
'ordered_use', /// Ordering use statements.
29+
'phpdoc_order', /// Annotations in phpdocs should be ordered so that @param come first, then @throws, then @return.
30+
'pre_increment', /// Pre incrementation/decrementation should be used if possible.
31+
'short_array_syntax', /// PHP arrays should use the PHP 5.4 short-syntax.
32+
'strict', /// Comparison should be strict. Warning! This could change code behavior.
33+
'strict_param', /// Functions should be used with $strict param. Warning! This could change code behavior.
34+
])
35+
->finder(
36+
Symfony\CS\Finder\DefaultFinder::create()
37+
->in(__DIR__)
38+
->notPath('vendor')
39+
->notPath('runtime')
40+
->notPath('web/assets')
41+
->notPath('tests/unit/UnitTester.php')
42+
)
43+
;

src/ActiveDataProvider.php

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
11
<?php
2-
/**
3-
* @link http://hiqdev.com/yii2-hiart
4-
* @license http://hiqdev.com/yii2-hiart/license
5-
* @copyright Copyright (c) 2015 HiQDev
2+
3+
/*
4+
* Tools to use API as ActiveRecord for Yii2
5+
*
6+
* @link https://github.com/hiqdev/yii2-hiart
7+
* @package yii2-hiart
8+
* @license BSD-3-Clause
9+
* @copyright Copyright (c) 2015, HiQDev (https://hiqdev.com/)
610
*/
711

812
namespace hiqdev\hiart;
913

10-
1114
class ActiveDataProvider extends \yii\data\ActiveDataProvider
1215
{
13-
1416
}

src/ActiveQuery.php

Lines changed: 38 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
11
<?php
2-
/**
3-
* @link http://hiqdev.com/yii2-hiart
4-
* @copyright Copyright (c) 2015 HiQDev
5-
* @license http://hiqdev.com/yii2-hiart/license
2+
3+
/*
4+
* Tools to use API as ActiveRecord for Yii2
5+
*
6+
* @link https://github.com/hiqdev/yii2-hiart
7+
* @package yii2-hiart
8+
* @license BSD-3-Clause
9+
* @copyright Copyright (c) 2015, HiQDev (https://hiqdev.com/)
610
*/
711

812
namespace hiqdev\hiart;
913

10-
use common\components\Err;
1114
use hipanel\base\Re;
1215
use yii\db\ActiveQueryInterface;
1316
use yii\db\ActiveQueryTrait;
@@ -24,14 +27,14 @@ class ActiveQuery extends Query implements ActiveQueryInterface
2427
*/
2528
const EVENT_INIT = 'init';
2629

27-
2830
/**
2931
* Constructor.
3032
*
3133
* @param array $modelClass the model class associated with this query
32-
* @param array $config configurations to be applied to the newly created query object
34+
* @param array $config configurations to be applied to the newly created query object
3335
*/
34-
public function __construct ($modelClass, $config = []) {
36+
public function __construct($modelClass, $config = [])
37+
{
3538
$this->modelClass = $modelClass;
3639
parent::__construct($config);
3740
}
@@ -42,7 +45,8 @@ public function __construct ($modelClass, $config = []) {
4245
* an [[EVENT_INIT]] event. If you override this method, make sure you call the parent implementation at the end
4346
* to ensure triggering of the event.
4447
*/
45-
public function init () {
48+
public function init()
49+
{
4650
parent::init();
4751
$this->trigger(self::EVENT_INIT);
4852
}
@@ -51,10 +55,12 @@ public function init () {
5155
* Creates a DB command that can be used to execute this query.
5256
*
5357
* @param Connection $db the DB connection used to create the DB command.
54-
* If null, the DB connection returned by [[modelClass]] will be used.
58+
* If null, the DB connection returned by [[modelClass]] will be used.
59+
*
5560
* @return Command the created DB command instance.
5661
*/
57-
public function createCommand ($db = null) {
62+
public function createCommand($db = null)
63+
{
5864
if ($this->primaryModel !== null) {
5965
// lazy loading
6066
if (is_array($this->via)) {
@@ -89,7 +95,6 @@ public function createCommand ($db = null) {
8995
$this->type = $modelClass::type();
9096
}
9197

92-
9398
$commandConfig = $db->getQueryBuilder()->build($this);
9499

95100
return $db->createCommand($commandConfig);
@@ -99,10 +104,12 @@ public function createCommand ($db = null) {
99104
* Executes query and returns all results as an array.
100105
*
101106
* @param Connection $db the DB connection used to create the DB command.
102-
* If null, the DB connection returned by [[modelClass]] will be used.
107+
* If null, the DB connection returned by [[modelClass]] will be used.
108+
*
103109
* @return array the query results. If the query results in nothing, an empty array will be returned.
104110
*/
105-
public function all ($db = null) {
111+
public function all($db = null)
112+
{
106113
if ($this->asArray) {
107114
// TODO implement with
108115
return parent::all($db);
@@ -130,16 +137,18 @@ public function all ($db = null) {
130137
* Executes query and returns a single row of result.
131138
*
132139
* @param Connection $db the DB connection used to create the DB command.
133-
* If null, the DB connection returned by [[modelClass]] will be used.
140+
* If null, the DB connection returned by [[modelClass]] will be used.
141+
*
134142
* @return ActiveRecord|array|null a single row of query result. Depending on the setting of [[asArray]],
135-
* the query result may be either an array or an ActiveRecord object. Null will be returned
136-
* if the query results in nothing.
143+
* the query result may be either an array or an ActiveRecord object. Null will be returned
144+
* if the query results in nothing.
137145
*/
138-
public function one ($db = null) {
139-
// $result = $this->createCommand($db)->get();
146+
public function one($db = null)
147+
{
148+
// $result = $this->createCommand($db)->get();
140149

141150
if (($result = parent::one($db)) === false) {
142-
return null;
151+
return;
143152
}
144153
if ($this->asArray) {
145154
// TODO implement with()
@@ -174,9 +183,10 @@ public function one ($db = null) {
174183
}
175184

176185
/**
177-
* @inheritdoc
186+
* {@inheritdoc}
178187
*/
179-
public function search ($db = null, $options = []) {
188+
public function search($db = null, $options = [])
189+
{
180190
$result = $this->createCommand($db)->search($options);
181191
// TODO implement with() for asArray
182192
if (!empty($result) && !$this->asArray) {
@@ -194,10 +204,11 @@ public function search ($db = null, $options = []) {
194204
}
195205

196206
/**
197-
* @inheritdoc
207+
* {@inheritdoc}
198208
*/
199-
public function column ($field, $db = null) {
200-
if ($field == '_id') {
209+
public function column($field, $db = null)
210+
{
211+
if ($field === '_id') {
201212
$command = $this->createCommand($db);
202213
$command->queryParts['fields'] = [];
203214
$command->queryParts['_source'] = false;
@@ -216,7 +227,8 @@ public function column ($field, $db = null) {
216227
return parent::column($field, $db);
217228
}
218229

219-
public function getList ($as_array = true, $db = null, $options = []) {
230+
public function getList($as_array = true, $db = null, $options = [])
231+
{
220232
$rawResult = $this->createCommand($db)->getList($options);
221233
foreach ($rawResult as $k => $v) {
222234
$result[] = ['gl_key' => $k, 'gl_value' => $v];

0 commit comments

Comments
 (0)