@@ -144,7 +144,7 @@ discard block |
||
144 | 144 | * |
145 | 145 | * @throws InvalidConfigException |
146 | 146 | * |
147 | - * @return string|callable|array |
|
147 | + * @return string |
|
148 | 148 | * |
149 | 149 | * @author SilverFire |
150 | 150 | */ |
@@ -469,7 +469,7 @@ discard block |
||
469 | 469 | |
470 | 470 | /** |
471 | 471 | * {@inheritdoc} |
472 | - * @return ActiveQuery the relational query object. |
|
472 | + * @return \yii\db\ActiveQuery the relational query object. |
|
473 | 473 | */ |
474 | 474 | public function hasOne($class, $link) |
475 | 475 | { |
@@ -478,7 +478,7 @@ discard block |
||
478 | 478 | |
479 | 479 | /** |
480 | 480 | * {@inheritdoc} |
481 | - * @return ActiveQuery the relational query object. |
|
481 | + * @return \yii\db\ActiveQuery the relational query object. |
|
482 | 482 | */ |
483 | 483 | public function hasMany($class, $link) |
484 | 484 | { |
@@ -201,7 +201,7 @@ discard block |
||
201 | 201 | public static function index() |
202 | 202 | { |
203 | 203 | // return Inflector::pluralize(Inflector::camel2id(StringHelper::basename(get_called_class()), '-')); |
204 | - return mb_strtolower(StringHelper::basename(get_called_class()) . 's'); |
|
204 | + return mb_strtolower(StringHelper::basename(get_called_class()).'s'); |
|
205 | 205 | } |
206 | 206 | |
207 | 207 | public static function joinIndex() |
@@ -352,7 +352,7 @@ discard block |
||
352 | 352 | */ |
353 | 353 | public static function perform($action, $options = [], $bulk = false) |
354 | 354 | { |
355 | - $action = ($bulk === true ? static::index() : static::type()) . $action; |
|
355 | + $action = ($bulk === true ? static::index() : static::type()).$action; |
|
356 | 356 | $result = static::getDb()->createCommand()->perform($action, $options); |
357 | 357 | |
358 | 358 | return $result; |
@@ -399,7 +399,7 @@ discard block |
||
399 | 399 | if (is_array($result)) { |
400 | 400 | return implode('', $result); |
401 | 401 | } else { |
402 | - return static::type() . ($bulk ? 's' : '') . $result; |
|
402 | + return static::type().($bulk ? 's' : '').$result; |
|
403 | 403 | } |
404 | 404 | } |
405 | 405 |
@@ -76,6 +76,9 @@ discard block |
||
76 | 76 | } |
77 | 77 | } |
78 | 78 | |
79 | + /** |
|
80 | + * @param string $modelName |
|
81 | + */ |
|
79 | 82 | public function get($modelName, $primaryKey, $options) |
80 | 83 | { |
81 | 84 | return $this->db->post($modelName . 'GetInfo', ArrayHelper::merge(['id' => $primaryKey], $options)); |
@@ -106,7 +109,7 @@ discard block |
||
106 | 109 | } |
107 | 110 | |
108 | 111 | /** |
109 | - * @param $action |
|
112 | + * @param string $action |
|
110 | 113 | * @param array $options |
111 | 114 | * |
112 | 115 | * @return mixed |
@@ -46,7 +46,7 @@ discard block |
||
46 | 46 | */ |
47 | 47 | public function search($options = []) |
48 | 48 | { |
49 | - $url = $this->index . Inflector::id2camel(ArrayHelper::remove($options, 'scenario', 'search')); |
|
49 | + $url = $this->index.Inflector::id2camel(ArrayHelper::remove($options, 'scenario', 'search')); |
|
50 | 50 | $query = $this->queryParts; |
51 | 51 | $options = array_merge($query, $options); |
52 | 52 | |
@@ -58,15 +58,15 @@ discard block |
||
58 | 58 | $options = array_merge($data, $options); |
59 | 59 | |
60 | 60 | if ($id !== null) { |
61 | - return $this->db->put($action . 'Update', array_merge($options, ['id' => $id])); |
|
61 | + return $this->db->put($action.'Update', array_merge($options, ['id' => $id])); |
|
62 | 62 | } else { |
63 | - return $this->db->post($action . 'Create', $options); |
|
63 | + return $this->db->post($action.'Create', $options); |
|
64 | 64 | } |
65 | 65 | } |
66 | 66 | |
67 | 67 | public function get($modelName, $primaryKey, $options) |
68 | 68 | { |
69 | - return $this->db->post($modelName . 'GetInfo', ArrayHelper::merge(['id' => $primaryKey], $options)); |
|
69 | + return $this->db->post($modelName.'GetInfo', ArrayHelper::merge(['id' => $primaryKey], $options)); |
|
70 | 70 | } |
71 | 71 | |
72 | 72 | public function mget($index, $type, $ids, $options = []) |
@@ -83,14 +83,14 @@ discard block |
||
83 | 83 | |
84 | 84 | public function delete($index, $id, $options = []) |
85 | 85 | { |
86 | - return $this->db->delete($index . 'Delete', array_merge($options, ['id' => $id])); |
|
86 | + return $this->db->delete($index.'Delete', array_merge($options, ['id' => $id])); |
|
87 | 87 | } |
88 | 88 | |
89 | 89 | public function update($index, $id, $data, $options = []) |
90 | 90 | { |
91 | 91 | $options['id'] = $id; |
92 | 92 | |
93 | - return $this->db->put($index . 'Update', array_merge($data, $options)); |
|
93 | + return $this->db->put($index.'Update', array_merge($data, $options)); |
|
94 | 94 | } |
95 | 95 | |
96 | 96 | /** |
@@ -425,7 +425,7 @@ |
||
425 | 425 | */ |
426 | 426 | public function collectData($attributes = null, $options = []) |
427 | 427 | { |
428 | - $data = []; |
|
428 | + $data = []; |
|
429 | 429 | foreach ($this->models as $model) { |
430 | 430 | /* @var $model ActiveRecord */ |
431 | 431 | $key = $model->getPrimaryKey(); |
@@ -27,6 +27,9 @@ discard block |
||
27 | 27 | |
28 | 28 | public $db; |
29 | 29 | |
30 | + /** |
|
31 | + * @param Connection $connection |
|
32 | + */ |
|
30 | 33 | public function __construct($connection, $config = []) |
31 | 34 | { |
32 | 35 | $this->db = $connection; |
@@ -59,6 +62,9 @@ discard block |
||
59 | 62 | ]; |
60 | 63 | } |
61 | 64 | |
65 | + /** |
|
66 | + * @param integer $limit |
|
67 | + */ |
|
62 | 68 | public function buildLimit($limit, &$parts) |
63 | 69 | { |
64 | 70 | if (!empty($limit)) { |
@@ -69,6 +75,10 @@ discard block |
||
69 | 75 | } |
70 | 76 | } |
71 | 77 | |
78 | + /** |
|
79 | + * @param integer $offset |
|
80 | + * @param integer $limit |
|
81 | + */ |
|
72 | 82 | public function buildPage($offset, $limit, &$parts) |
73 | 83 | { |
74 | 84 | if ($offset > 0) { |
@@ -79,7 +79,7 @@ discard block |
||
79 | 79 | public function buildOrderBy($orderBy, &$parts) |
80 | 80 | { |
81 | 81 | if (!empty($orderBy)) { |
82 | - $parts['orderby'] = key($orderBy) . $this->_sort[reset($orderBy)]; |
|
82 | + $parts['orderby'] = key($orderBy).$this->_sort[reset($orderBy)]; |
|
83 | 83 | } |
84 | 84 | } |
85 | 85 | |
@@ -120,7 +120,7 @@ discard block |
||
120 | 120 | |
121 | 121 | return $this->$method($operator, $condition); |
122 | 122 | } else { |
123 | - throw new InvalidParamException('Found unknown operator in query: ' . $operator); |
|
123 | + throw new InvalidParamException('Found unknown operator in query: '.$operator); |
|
124 | 124 | } |
125 | 125 | } else { |
126 | 126 | return $this->buildHashCondition($condition); |
@@ -133,7 +133,7 @@ discard block |
||
133 | 133 | foreach ($condition as $attribute => $value) { |
134 | 134 | if (is_array($value)) { // IN condition |
135 | 135 | // $parts[] = [$attribute.'s' => join(',',$value)]; |
136 | - $parts[$attribute . 's'] = implode(',', $value); |
|
136 | + $parts[$attribute.'s'] = implode(',', $value); |
|
137 | 137 | } else { |
138 | 138 | $parts[$attribute] = $value; |
139 | 139 | } |
@@ -144,7 +144,7 @@ discard block |
||
144 | 144 | |
145 | 145 | private function buildLikeCondition($operator, $operands) |
146 | 146 | { |
147 | - return [$operands[0] . '_like' => $operands[1]]; |
|
147 | + return [$operands[0].'_like' => $operands[1]]; |
|
148 | 148 | } |
149 | 149 | |
150 | 150 | private function buildCompareCondition($operator, $operands) |
@@ -153,7 +153,7 @@ discard block |
||
153 | 153 | throw new InvalidParamException("Operator '$operator' requires three operands."); |
154 | 154 | } |
155 | 155 | |
156 | - return [$operands[0] . '_' . $operator => $operands[1]]; |
|
156 | + return [$operands[0].'_'.$operator => $operands[1]]; |
|
157 | 157 | } |
158 | 158 | |
159 | 159 | private function buildAndCondition($operator, $operands) |
@@ -199,7 +199,7 @@ discard block |
||
199 | 199 | } |
200 | 200 | } |
201 | 201 | |
202 | - return [$column . '_in' => $values]; |
|
202 | + return [$column.'_in' => $values]; |
|
203 | 203 | } |
204 | 204 | |
205 | 205 | private function buildEqCondition($operator, $operands) |
@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | 'config' => [ |
48 | 48 | 'base_uri' => $this->site, |
49 | 49 | ], |
50 | - 'errorChecker' => function ($res) { |
|
50 | + 'errorChecker' => function($res) { |
|
51 | 51 | return null; |
52 | 52 | }, |
53 | 53 | ]); |
@@ -61,15 +61,15 @@ discard block |
||
61 | 61 | { |
62 | 62 | $result = $this->object->get($this->url, [], $this->body, false); |
63 | 63 | $this->assertSame($this->result, $result); |
64 | - $this->assertSame('request', $this->mock->name); |
|
65 | - $this->assertSame('GET', $this->mock->args[0]); |
|
66 | - $this->assertSame($this->url, $this->mock->args[1]); |
|
64 | + $this->assertSame('request', $this->mock->name); |
|
65 | + $this->assertSame('GET', $this->mock->args[0]); |
|
66 | + $this->assertSame($this->url, $this->mock->args[1]); |
|
67 | 67 | $this->assertSame($this->body, $this->mock->args[2]['form_params']); |
68 | 68 | } |
69 | 69 | |
70 | 70 | public function testErrorChecker() |
71 | 71 | { |
72 | - $this->object->setErrorChecker(function ($res) { return $res; }); |
|
72 | + $this->object->setErrorChecker(function($res) { return $res; }); |
|
73 | 73 | $this->setExpectedException('hiqdev\hiart\ErrorResponseException', $this->result); |
74 | 74 | $this->object->get($this->url, [], $this->body, false); |
75 | 75 | } |
@@ -206,7 +206,6 @@ discard block |
||
206 | 206 | /** |
207 | 207 | * XXX DEPRECATED in favour of post(). |
208 | 208 | * @param $url |
209 | - * @param array $query |
|
210 | 209 | * @return mixed |
211 | 210 | */ |
212 | 211 | public function perform($url, $body = []) |
@@ -220,6 +219,7 @@ discard block |
||
220 | 219 | * @param array $query query options, (GET parameters) |
221 | 220 | * @param string $body request body, (POST parameters) |
222 | 221 | * @param bool $raw if response body contains JSON and should be decoded |
222 | + * @param string $method |
|
223 | 223 | * @throws HiArtException |
224 | 224 | * @throws \yii\base\InvalidConfigException |
225 | 225 | * @return mixed response |
@@ -233,9 +233,9 @@ discard block |
||
233 | 233 | |
234 | 234 | /** |
235 | 235 | * Creates URL. |
236 | - * @param mixed $path path |
|
236 | + * @param string $path path |
|
237 | 237 | * @param array $query query options |
238 | - * @return array |
|
238 | + * @return string |
|
239 | 239 | */ |
240 | 240 | private function prepareUrl($path, array $query = []) |
241 | 241 | { |
@@ -322,7 +322,7 @@ discard block |
||
322 | 322 | |
323 | 323 | /** |
324 | 324 | * Setter for errorChecker. |
325 | - * @param Closure|array $value |
|
325 | + * @param Closure $value |
|
326 | 326 | * @return void |
327 | 327 | */ |
328 | 328 | public function setErrorChecker($value) |
@@ -264,7 +264,7 @@ discard block |
||
264 | 264 | $url = $path; |
265 | 265 | $query = array_merge($this->getAuth(), $query); |
266 | 266 | if (!empty($query)) { |
267 | - $url .= (strpos($url, '?') === false ? '?' : '&') . http_build_query($query); |
|
267 | + $url .= (strpos($url, '?') === false ? '?' : '&').http_build_query($query); |
|
268 | 268 | } |
269 | 269 | |
270 | 270 | return $url; |
@@ -283,7 +283,7 @@ discard block |
||
283 | 283 | protected function handleRequest($method, $url, $body = null, $raw = false) |
284 | 284 | { |
285 | 285 | $method = strtoupper($method); |
286 | - $profile = $method . ' ' . $url . '#' . (is_array($body) ? http_build_query($body) : $body); |
|
286 | + $profile = $method.' '.$url.'#'.(is_array($body) ? http_build_query($body) : $body); |
|
287 | 287 | $options = [(is_array($body) ? 'form_params' : 'body') => $body]; |
288 | 288 | Yii::beginProfile($profile, __METHOD__); |
289 | 289 | $response = $this->getHandler()->request($method, $url, $options); |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | foreach ($timings as $timing) { |
55 | 55 | $queryTime += $timing[3]; |
56 | 56 | } |
57 | - $queryTime = number_format($queryTime * 1000) . ' ms'; |
|
57 | + $queryTime = number_format($queryTime * 1000).' ms'; |
|
58 | 58 | $url = $this->getUrl(); |
59 | 59 | $output = <<<HTML |
60 | 60 | <div class="yii-debug-toolbar__block"> |
@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | try { |
84 | 84 | $component = \Yii::$app->get('hiart'); |
85 | 85 | $apiUrl = (StringHelper::endsWith($component->config['api_url'], |
86 | - '/')) ? $component->config['api_url'] : $component->config['api_url'] . '/'; |
|
86 | + '/')) ? $component->config['api_url'] : $component->config['api_url'].'/'; |
|
87 | 87 | } catch (\yii\base\InvalidConfigException $e) { |
88 | 88 | // Pass |
89 | 89 | } |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | if (!empty($traces)) { |
103 | 103 | $traceString .= Html::ul($traces, [ |
104 | 104 | 'class' => 'trace', |
105 | - 'item' => function ($trace) { |
|
105 | + 'item' => function($trace) { |
|
106 | 106 | return "<li>{$trace['file']}({$trace['line']})</li>"; |
107 | 107 | }, |
108 | 108 | ]); |
@@ -111,15 +111,15 @@ discard block |
||
111 | 111 | $runLink = Html::a('run query', $ajaxUrl, [ |
112 | 112 | 'class' => 'hiart-link', |
113 | 113 | 'data' => ['id' => $i], |
114 | - ]) . '<br/>'; |
|
114 | + ]).'<br/>'; |
|
115 | 115 | $path = preg_replace('/^[A-Z]+\s+/', '', $url); |
116 | 116 | if (strpos($path, '?') !== false) { |
117 | - $newTabUrl = $apiUrl . rtrim($path, '&') . '&' . $body; |
|
117 | + $newTabUrl = $apiUrl.rtrim($path, '&').'&'.$body; |
|
118 | 118 | } else { |
119 | - $newTabUrl = $apiUrl . $path . '?' . $body; |
|
119 | + $newTabUrl = $apiUrl.$path.'?'.$body; |
|
120 | 120 | } |
121 | - $newTabLink = Html::a('to new tab', $newTabUrl, ['target' => '_blank']) . '<br/>'; |
|
122 | - $url_encoded = Html::encode((isset($apiUrl)) ? str_replace(' ', ' ' . $apiUrl, $url) : $url); |
|
121 | + $newTabLink = Html::a('to new tab', $newTabUrl, ['target' => '_blank']).'<br/>'; |
|
122 | + $url_encoded = Html::encode((isset($apiUrl)) ? str_replace(' ', ' '.$apiUrl, $url) : $url); |
|
123 | 123 | $body_encoded = Html::encode($body); |
124 | 124 | $rows[] = <<<HTML |
125 | 125 | <tr> |
@@ -11,5 +11,5 @@ |
||
11 | 11 | |
12 | 12 | error_reporting(E_ALL & ~E_NOTICE); |
13 | 13 | |
14 | -require_once __DIR__ . '/../vendor/autoload.php'; |
|
15 | -require_once __DIR__ . '/../vendor/yiisoft/yii2/Yii.php'; |
|
14 | +require_once __DIR__.'/../vendor/autoload.php'; |
|
15 | +require_once __DIR__.'/../vendor/yiisoft/yii2/Yii.php'; |