Skip to content

Commit ead163b

Browse files
author
igor-chepurnoi
committed
fix code style
1 parent 49b6b9b commit ead163b

File tree

8 files changed

+98
-65
lines changed

8 files changed

+98
-65
lines changed

.php_cs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?php
2+
3+
$finder = Symfony\CS\Finder::create()
4+
->exclude('vendor')
5+
->in([__DIR__]);
6+
7+
$config = Symfony\CS\Config::create()
8+
->fixers([
9+
'-phpdoc_params',
10+
'-phpdoc_short_description',
11+
'-phpdoc_inline_tag',
12+
'-pre_increment',
13+
'-heredoc_to_nowdoc',
14+
'-spaces_cast',
15+
'-include',
16+
'-phpdoc_no_package',
17+
'concat_with_spaces',
18+
'ordered_use',
19+
'short_array_syntax',
20+
])
21+
->finder($finder);
22+
23+
return $config;

.travis.yml

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,6 @@ php:
55
- 5.5
66
- 5.6
77
- 7.0
8-
- hhvm
9-
10-
# run build against hhvm but allow them to fail
11-
# http://docs.travis-ci.com/user/build-configuration/#Rows-That-are-Allowed-To-Fail
12-
matrix:
13-
fast_finish: true
14-
allow_failures:
15-
- php: hhvm
168

179
# faster builds on new travis setup not using sudo
1810
sudo: false
@@ -21,6 +13,7 @@ sudo: false
2113
cache:
2214
directories:
2315
- $HOME/.composer/cache
16+
- vendor
2417

2518
install:
2619
- travis_retry composer self-update && composer --version
@@ -29,4 +22,5 @@ install:
2922
- travis_retry composer install --prefer-dist --no-interaction
3023

3124
script:
32-
- phpunit --verbose $PHPUNIT_FLAGS
25+
- vendor/friendsofphp/php-cs-fixer/php-cs-fixer fix --dry-run --diff
26+
- phpunit --verbose $PHPUNIT_FLAGS

ArrayQuery.php

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,20 @@
88

99
/**
1010
* Class ArrayQuery
11+
*
1112
* @package yii2mod\query
1213
*/
1314
class ArrayQuery extends Component
1415
{
1516
use QueryTrait;
1617

1718
/**
18-
* @var string name of the data key, which should be used as row unique id - primary key.
19+
* @var string name of the data key, which should be used as row unique id - primary key
1920
*/
2021
public $primaryKeyName = 'id';
2122

2223
/**
23-
* @var array the data to search, filter.
24+
* @var array the data to search, filter
2425
*/
2526
public $from;
2627

@@ -39,9 +40,9 @@ class ArrayQuery extends Component
3940
*/
4041
public function init()
4142
{
42-
$this->_queryProcessor = Yii::createObject($this->queryProcessorClass);
43-
4443
parent::init();
44+
45+
$this->_queryProcessor = Yii::createObject($this->queryProcessorClass);
4546
}
4647

4748
/**
@@ -96,6 +97,7 @@ public function exists()
9697
* Sets data to be selected from.
9798
*
9899
* @param array $data
100+
*
99101
* @return $this
100102
*/
101103
public function from(array $data)
@@ -119,6 +121,7 @@ protected function fetchData()
119121
* Converts the raw query results into the format as specified by this query.
120122
*
121123
* @param $rows
124+
*
122125
* @return array
123126
*/
124127
public function populate($rows)
@@ -140,4 +143,4 @@ public function populate($rows)
140143

141144
return $result;
142145
}
143-
}
146+
}

QueryProcessor.php

Lines changed: 50 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<?php
22
/**
33
* @link https://github.com/yii2tech
4+
*
45
* @copyright Copyright (c) 2015 Yii2tech
56
* @license [New BSD License](http://www.opensource.org/licenses/bsd-license.php)
67
*/
@@ -19,6 +20,7 @@
1920
*
2021
* @author Paul Klimov <[email protected]>
2122
* @author Igor Chepurnoy <[email protected]>
23+
*
2224
* @since 1.0
2325
*/
2426
class QueryProcessor extends Component
@@ -65,10 +67,10 @@ public function process($query)
6567
/**
6668
* Applies sort for given data.
6769
*
68-
* @param array $data raw data.
69-
* @param array|null $orderBy order by.
70+
* @param array $data raw data
71+
* @param array|null $orderBy order by
7072
*
71-
* @return array sorted data.
73+
* @return array sorted data
7274
*/
7375
protected function applyOrderBy(array $data, $orderBy)
7476
{
@@ -82,11 +84,11 @@ protected function applyOrderBy(array $data, $orderBy)
8284
/**
8385
* Applies limit and offset for given data.
8486
*
85-
* @param array $data raw data.
86-
* @param integer|null $limit limit value.
87-
* @param integer|null $offset offset value.
87+
* @param array $data raw data
88+
* @param int|null $limit limit value
89+
* @param int|null $offset offset value
8890
*
89-
* @return array data.
91+
* @return array data
9092
*/
9193
protected function applyLimit(array $data, $limit, $offset)
9294
{
@@ -108,10 +110,10 @@ protected function applyLimit(array $data, $limit, $offset)
108110
/**
109111
* Applies where conditions.
110112
*
111-
* @param array $data raw data.
112-
* @param array|null $where where conditions.
113+
* @param array $data raw data
114+
* @param array|null $where where conditions
113115
*
114-
* @return array data.
116+
* @return array data
115117
*/
116118
protected function applyWhere(array $data, $where)
117119
{
@@ -121,10 +123,10 @@ protected function applyWhere(array $data, $where)
121123
/**
122124
* Applies filter conditions.
123125
*
124-
* @param array $data data to be filtered.
125-
* @param array $condition filter condition.
126+
* @param array $data data to be filtered
127+
* @param array $condition filter condition
126128
*
127-
* @return array filtered data.
129+
* @return array filtered data
128130
*
129131
* @throws InvalidParamException
130132
*/
@@ -146,6 +148,7 @@ protected function filterCondition(array $data, $condition)
146148
throw new InvalidParamException("Invalid condition filter '{$operator}'");
147149
}
148150
array_shift($condition);
151+
149152
return $this->$method($data, $operator, $condition);
150153
} else {
151154
return $this->filterHashCondition($data, $condition);
@@ -156,7 +159,7 @@ protected function filterCondition(array $data, $condition)
156159
* Applies a condition based on column-value pairs.
157160
*
158161
* @param array $data data to be filtered
159-
* @param array $condition the condition specification.
162+
* @param array $condition the condition specification
160163
*
161164
* @return array filtered data
162165
*/
@@ -167,7 +170,7 @@ protected function filterHashCondition(array $data, $condition)
167170
$data = $this->filterInCondition($data, 'IN', [$column, $value]);
168171
} else {
169172
$data = array_filter($data, function ($row) use ($column, $value) {
170-
return ($row[$column] == $value);
173+
return $row[$column] == $value;
171174
});
172175
}
173176
}
@@ -179,8 +182,8 @@ protected function filterHashCondition(array $data, $condition)
179182
* Applies 2 or more conditions using 'AND' logic.
180183
*
181184
* @param array $data data to be filtered
182-
* @param string $operator operator.
183-
* @param array $operands conditions to be united.
185+
* @param string $operator operator
186+
* @param array $operands conditions to be united
184187
*
185188
* @return array filtered data
186189
*/
@@ -198,9 +201,9 @@ protected function filterAndCondition(array $data, $operator, $operands)
198201
/**
199202
* Applies 2 or more conditions using 'OR' logic.
200203
*
201-
* @param array $data data to be filtered.
202-
* @param string $operator operator.
203-
* @param array $operands conditions to be united.
204+
* @param array $data data to be filtered
205+
* @param string $operator operator
206+
* @param array $operands conditions to be united
204207
*
205208
* @return array filtered data
206209
*/
@@ -231,13 +234,13 @@ protected function filterOrCondition(array $data, $operator, $operands)
231234
/**
232235
* Inverts a filter condition.
233236
*
234-
* @param array $data data to be filtered.
235-
* @param string $operator operator.
236-
* @param array $operands operands to be inverted.
237+
* @param array $data data to be filtered
238+
* @param string $operator operator
239+
* @param array $operands operands to be inverted
237240
*
238-
* @return array filtered data.
241+
* @return array filtered data
239242
*
240-
* @throws InvalidParamException if wrong number of operands have been given.
243+
* @throws InvalidParamException if wrong number of operands have been given
241244
*/
242245
protected function filterNotCondition(array $data, $operator, $operands)
243246
{
@@ -268,14 +271,14 @@ protected function filterNotCondition(array $data, $operator, $operands)
268271
/**
269272
* Applies `BETWEEN` condition.
270273
*
271-
* @param array $data data to be filtered.
272-
* @param string $operator operator.
274+
* @param array $data data to be filtered
275+
* @param string $operator operator
273276
* @param array $operands the first operand is the column name. The second and third operands
274-
* describe the interval that column value should be in.
277+
* describe the interval that column value should be in
275278
*
276-
* @return array filtered data.
279+
* @return array filtered data
277280
*
278-
* @throws InvalidParamException if wrong number of operands have been given.
281+
* @throws InvalidParamException if wrong number of operands have been given
279282
*/
280283
protected function filterBetweenCondition(array $data, $operator, $operands)
281284
{
@@ -287,26 +290,26 @@ protected function filterBetweenCondition(array $data, $operator, $operands)
287290

288291
if (strncmp('NOT', $operator, 3) === 0) {
289292
return array_filter($data, function ($row) use ($column, $value1, $value2) {
290-
return ($row[$column] < $value1 || $row[$column] > $value2);
293+
return $row[$column] < $value1 || $row[$column] > $value2;
291294
});
292295
}
293296

294297
return array_filter($data, function ($row) use ($column, $value1, $value2) {
295-
return ($row[$column] >= $value1 && $row[$column] <= $value2);
298+
return $row[$column] >= $value1 && $row[$column] <= $value2;
296299
});
297300
}
298301

299302
/**
300303
* Applies 'IN' condition.
301304
*
302-
* @param array $data data to be filtered.
303-
* @param string $operator operator.
305+
* @param array $data data to be filtered
306+
* @param string $operator operator
304307
* @param array $operands the first operand is the column name.
305-
* The second operand is an array of values that column value should be among.
308+
* The second operand is an array of values that column value should be among
306309
*
307-
* @return array filtered data.
310+
* @return array filtered data
308311
*
309-
* @throws InvalidParamException if wrong number of operands have been given.
312+
* @throws InvalidParamException if wrong number of operands have been given
310313
*/
311314
protected function filterInCondition(array $data, $operator, $operands)
312315
{
@@ -350,14 +353,14 @@ protected function filterInCondition(array $data, $operator, $operands)
350353
/**
351354
* Applies 'LIKE' condition.
352355
*
353-
* @param array $data data to be filtered.
354-
* @param string $operator operator.
356+
* @param array $data data to be filtered
357+
* @param string $operator operator
355358
* @param array $operands the first operand is the column name. The second operand is a single value
356-
* or an array of values that column value should be compared with.
359+
* or an array of values that column value should be compared with
357360
*
358-
* @return array filtered data.
361+
* @return array filtered data
359362
*
360-
* @throws InvalidParamException if wrong number of operands have been given.
363+
* @throws InvalidParamException if wrong number of operands have been given
361364
*/
362365
protected function filterLikeCondition(array $data, $operator, $operands)
363366
{
@@ -386,6 +389,7 @@ protected function filterLikeCondition(array $data, $operator, $operands)
386389
return true;
387390
}
388391
}
392+
389393
return false;
390394
});
391395
}
@@ -396,6 +400,7 @@ protected function filterLikeCondition(array $data, $operator, $operands)
396400
return false;
397401
}
398402
}
403+
399404
return true;
400405
});
401406
}
@@ -411,6 +416,7 @@ protected function filterLikeCondition(array $data, $operator, $operands)
411416
return true;
412417
}
413418
}
419+
414420
return false;
415421
});
416422
}
@@ -421,7 +427,8 @@ protected function filterLikeCondition(array $data, $operator, $operands)
421427
return false;
422428
}
423429
}
430+
424431
return true;
425432
});
426433
}
427-
}
434+
}

composer.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,12 @@
1717
"require": {
1818
"yiisoft/yii2": "*"
1919
},
20+
"require-dev": {
21+
"friendsofphp/php-cs-fixer": "~1.7"
22+
},
2023
"autoload": {
2124
"psr-4": {
2225
"yii2mod\\query\\": ""
2326
}
2427
}
25-
}
28+
}

0 commit comments

Comments
 (0)