@@ -61,7 +61,7 @@ discard block |
||
| 61 | 61 | /** |
| 62 | 62 | * Check if the logged in user has the given group. |
| 63 | 63 | * |
| 64 | - * @param array $groups |
|
| 64 | + * @param string[] $groups |
|
| 65 | 65 | * @param mixed $user |
| 66 | 66 | * @return boolean |
| 67 | 67 | */ |
@@ -155,7 +155,7 @@ discard block |
||
| 155 | 155 | * |
| 156 | 156 | * @param array $credentials |
| 157 | 157 | * @param boolean $skipConfirmEmail |
| 158 | - * @return array |
|
| 158 | + * @return boolean |
|
| 159 | 159 | */ |
| 160 | 160 | public function register($credentials, $skipConfirmEmail = false) |
| 161 | 161 | { |
@@ -246,7 +246,7 @@ discard block |
||
| 246 | 246 | * Reset the given user's password. |
| 247 | 247 | * |
| 248 | 248 | * @param array $credentials |
| 249 | - * @return array |
|
| 249 | + * @return string|null |
|
| 250 | 250 | */ |
| 251 | 251 | public function resetPassword($credentials) |
| 252 | 252 | { |
@@ -102,20 +102,16 @@ discard block |
||
| 102 | 102 | if ( ! $user = $this->first(['email' => $credentials['email']])) |
| 103 | 103 | { |
| 104 | 104 | \ErrorHandler::loginFailed(); |
| 105 | - } |
|
| 106 | - else if ($adminLogin && ! $user->groups->whereIn('name', ['Admin'])->count()) |
|
| 105 | + } else if ($adminLogin && ! $user->groups->whereIn('name', ['Admin'])->count()) |
|
| 107 | 106 | { |
| 108 | 107 | \ErrorHandler::loginFailed(); |
| 109 | - } |
|
| 110 | - else if ( ! $adminLogin && $user->groups->whereIn('name', ['Admin'])->count()) |
|
| 108 | + } else if ( ! $adminLogin && $user->groups->whereIn('name', ['Admin'])->count()) |
|
| 111 | 109 | { |
| 112 | 110 | \ErrorHandler::loginFailed(); |
| 113 | - } |
|
| 114 | - else if ($user->blocked) |
|
| 111 | + } else if ($user->blocked) |
|
| 115 | 112 | { |
| 116 | 113 | \ErrorHandler::userIsBlocked(); |
| 117 | - } |
|
| 118 | - else if ( ! config('skeleton.disable_confirm_email') && ! $user->confirmed) |
|
| 114 | + } else if ( ! config('skeleton.disable_confirm_email') && ! $user->confirmed) |
|
| 119 | 115 | { |
| 120 | 116 | \ErrorHandler::emailNotConfirmed(); |
| 121 | 117 | } |
@@ -165,8 +161,7 @@ discard block |
||
| 165 | 161 | { |
| 166 | 162 | $user->confirmed = 1; |
| 167 | 163 | $user->save(); |
| 168 | - } |
|
| 169 | - else if ( ! config('skeleton.disable_confirm_email')) |
|
| 164 | + } else if ( ! config('skeleton.disable_confirm_email')) |
|
| 170 | 165 | { |
| 171 | 166 | $this->sendConfirmationEmail($user->email); |
| 172 | 167 | } |
@@ -189,12 +184,10 @@ discard block |
||
| 189 | 184 | if ( ! $this->hasGroup(['Admin'])) |
| 190 | 185 | { |
| 191 | 186 | \ErrorHandler::noPermissions(); |
| 192 | - } |
|
| 193 | - else if (\Auth::id() == $userId) |
|
| 187 | + } else if (\Auth::id() == $userId) |
|
| 194 | 188 | { |
| 195 | 189 | \ErrorHandler::noPermissions(); |
| 196 | - } |
|
| 197 | - else if ($user->groups->pluck('name')->search('Admin', true) !== false) |
|
| 190 | + } else if ($user->groups->pluck('name')->search('Admin', true) !== false) |
|
| 198 | 191 | { |
| 199 | 192 | \ErrorHandler::noPermissions(); |
| 200 | 193 | } |
@@ -32,7 +32,7 @@ discard block |
||
| 32 | 32 | * |
| 33 | 33 | * @param array $relations |
| 34 | 34 | * @param string $sortBy |
| 35 | - * @param boolean $desc |
|
| 35 | + * @param integer $desc |
|
| 36 | 36 | * @param array $columns |
| 37 | 37 | * @return collection |
| 38 | 38 | */ |
@@ -50,7 +50,7 @@ discard block |
||
| 50 | 50 | * @param integer $perPage |
| 51 | 51 | * @param array $relations |
| 52 | 52 | * @param string $sortBy |
| 53 | - * @param boolean $desc |
|
| 53 | + * @param integer $desc |
|
| 54 | 54 | * @param array $columns |
| 55 | 55 | * @return collection |
| 56 | 56 | */ |
@@ -164,7 +164,7 @@ discard block |
||
| 164 | 164 | * @param integer $perPage |
| 165 | 165 | * @param array $relations |
| 166 | 166 | * @param string $sortBy |
| 167 | - * @param boolean $desc |
|
| 167 | + * @param integer $desc |
|
| 168 | 168 | * @param array $columns |
| 169 | 169 | * @return collection |
| 170 | 170 | */ |
@@ -182,7 +182,7 @@ discard block |
||
| 182 | 182 | * @param integer $perPage |
| 183 | 183 | * @param array $relations |
| 184 | 184 | * @param string $sortBy |
| 185 | - * @param boolean $desc |
|
| 185 | + * @param integer $desc |
|
| 186 | 186 | * @param array $columns |
| 187 | 187 | * @return collection |
| 188 | 188 | */ |
@@ -198,7 +198,7 @@ discard block |
||
| 198 | 198 | * Save the given model to the storage. |
| 199 | 199 | * |
| 200 | 200 | * @param array $data |
| 201 | - * @return mixed |
|
| 201 | + * @return boolean |
|
| 202 | 202 | */ |
| 203 | 203 | public function save(array $data) |
| 204 | 204 | { |
@@ -517,7 +517,7 @@ discard block |
||
| 517 | 517 | * id. |
| 518 | 518 | * |
| 519 | 519 | * @param integer $id |
| 520 | - * @param array $relations |
|
| 520 | + * @param string[] $relations |
|
| 521 | 521 | * @param array $columns |
| 522 | 522 | * @return object |
| 523 | 523 | */ |
@@ -533,7 +533,7 @@ discard block |
||
| 533 | 533 | * @param array $conditions array of conditions |
| 534 | 534 | * @param array $relations |
| 535 | 535 | * @param string $sortBy |
| 536 | - * @param boolean $desc |
|
| 536 | + * @param integer $desc |
|
| 537 | 537 | * @param array $columns |
| 538 | 538 | * @return collection |
| 539 | 539 | */ |
@@ -565,7 +565,7 @@ discard block |
||
| 565 | 565 | * @param array $conditions array of conditions |
| 566 | 566 | * @param integer $perPage |
| 567 | 567 | * @param string $sortBy |
| 568 | - * @param boolean $desc |
|
| 568 | + * @param integer $desc |
|
| 569 | 569 | * @param array $columns |
| 570 | 570 | * @return collection |
| 571 | 571 | */ |
@@ -471,8 +471,7 @@ discard block |
||
| 471 | 471 | { |
| 472 | 472 | $model = $this->model->lockForUpdate()->find($value); |
| 473 | 473 | $model ? $model->update($data) : 0; |
| 474 | - } |
|
| 475 | - else |
|
| 474 | + } else |
|
| 476 | 475 | { |
| 477 | 476 | call_user_func_array("{$this->getModel()}::where", array($attribute, '=', $value))->lockForUpdate()->get()->each(function ($model) use ($data){ |
| 478 | 477 | $model->update($data); |
@@ -501,8 +500,7 @@ discard block |
||
| 501 | 500 | |
| 502 | 501 | $model->delete(); |
| 503 | 502 | }); |
| 504 | - } |
|
| 505 | - else |
|
| 503 | + } else |
|
| 506 | 504 | { |
| 507 | 505 | \DB::transaction(function () use ($value, $attribute, &$result) { |
| 508 | 506 | call_user_func_array("{$this->getModel()}::where", array($attribute, '=', $value))->lockForUpdate()->get()->each(function ($model){ |
@@ -623,14 +621,12 @@ discard block |
||
| 623 | 621 | $conditions = $this->constructConditions($value, $model); |
| 624 | 622 | $conditionString .= str_replace('{op}', 'and', $conditions['conditionString']) . ' {op} '; |
| 625 | 623 | $conditionValues = array_merge($conditionValues, $conditions['conditionValues']); |
| 626 | - } |
|
| 627 | - else if ($key == 'or') |
|
| 624 | + } else if ($key == 'or') |
|
| 628 | 625 | { |
| 629 | 626 | $conditions = $this->constructConditions($value, $model); |
| 630 | 627 | $conditionString .= str_replace('{op}', 'or', $conditions['conditionString']) . ' {op} '; |
| 631 | 628 | $conditionValues = array_merge($conditionValues, $conditions['conditionValues']); |
| 632 | - } |
|
| 633 | - else |
|
| 629 | + } else |
|
| 634 | 630 | { |
| 635 | 631 | if (is_array($value)) |
| 636 | 632 | { |
@@ -639,13 +635,11 @@ discard block |
||
| 639 | 635 | { |
| 640 | 636 | $value1 = $value['val1']; |
| 641 | 637 | $value2 = $value['val2']; |
| 642 | - } |
|
| 643 | - else |
|
| 638 | + } else |
|
| 644 | 639 | { |
| 645 | 640 | $value = array_key_exists('val', $value) ? $value['val'] : ''; |
| 646 | 641 | } |
| 647 | - } |
|
| 648 | - else |
|
| 642 | + } else |
|
| 649 | 643 | { |
| 650 | 644 | $operator = '='; |
| 651 | 645 | } |
@@ -657,29 +651,24 @@ discard block |
||
| 657 | 651 | |
| 658 | 652 | $conditionString .= $key . ' <= ? {op} '; |
| 659 | 653 | $conditionValues[] = $value2; |
| 660 | - } |
|
| 661 | - elseif (strtolower($operator) == 'in') |
|
| 654 | + } elseif (strtolower($operator) == 'in') |
|
| 662 | 655 | { |
| 663 | 656 | $conditionValues = array_merge($conditionValues, $value); |
| 664 | 657 | $inBindingsString = rtrim(str_repeat('?,', count($value)), ','); |
| 665 | 658 | $conditionString .= $key . ' in (' . rtrim($inBindingsString, ',') . ') {op} '; |
| 666 | - } |
|
| 667 | - elseif (strtolower($operator) == 'null') |
|
| 659 | + } elseif (strtolower($operator) == 'null') |
|
| 668 | 660 | { |
| 669 | 661 | $conditionString .= $key . ' is null {op} '; |
| 670 | - } |
|
| 671 | - elseif (strtolower($operator) == 'not null') |
|
| 662 | + } elseif (strtolower($operator) == 'not null') |
|
| 672 | 663 | { |
| 673 | 664 | $conditionString .= $key . ' is not null {op} '; |
| 674 | - } |
|
| 675 | - elseif (strtolower($operator) == 'has') |
|
| 665 | + } elseif (strtolower($operator) == 'has') |
|
| 676 | 666 | { |
| 677 | 667 | $sql = $model->withTrashed()->has($key)->toSql(); |
| 678 | 668 | $conditions = $this->constructConditions($value, $model->$key()->getRelated()); |
| 679 | 669 | $conditionString .= rtrim(substr($sql, strpos($sql, 'exists')), ')') . ' and ' . $conditions['conditionString'] . ') {op} '; |
| 680 | 670 | $conditionValues = array_merge($conditionValues, $conditions['conditionValues']); |
| 681 | - } |
|
| 682 | - else |
|
| 671 | + } else |
|
| 683 | 672 | { |
| 684 | 673 | $conditionString .= $key . ' ' . $operator . ' ? {op} '; |
| 685 | 674 | $conditionValues[] = $value; |
@@ -124,7 +124,7 @@ discard block |
||
| 124 | 124 | * based on the docblock. |
| 125 | 125 | * |
| 126 | 126 | * @param array &$route |
| 127 | - * @param object $reflectionMethod |
|
| 127 | + * @param \ReflectionMethod $reflectionMethod |
|
| 128 | 128 | * @return void |
| 129 | 129 | */ |
| 130 | 130 | protected function processDocBlock(&$route, $reflectionMethod) |
@@ -148,7 +148,7 @@ discard block |
||
| 148 | 148 | * Generate post body for the given route. |
| 149 | 149 | * |
| 150 | 150 | * @param array &$route |
| 151 | - * @param object $reflectionMethod |
|
| 151 | + * @param \ReflectionMethod $reflectionMethod |
|
| 152 | 152 | * @param array $validationRules |
| 153 | 153 | * @return void |
| 154 | 154 | */ |
@@ -164,8 +164,7 @@ discard block |
||
| 164 | 164 | if ($match[1] == '$this->validationRules') |
| 165 | 165 | { |
| 166 | 166 | $route['body'] = $validationRules; |
| 167 | - } |
|
| 168 | - else |
|
| 167 | + } else |
|
| 169 | 168 | { |
| 170 | 169 | $route['body'] = eval('return ' . str_replace(',\'.$request->get(\'id\')', ',{id}\'', $match[1]) . ';'); |
| 171 | 170 | } |
@@ -175,14 +174,12 @@ discard block |
||
| 175 | 174 | if(strpos($rule, 'unique')) |
| 176 | 175 | { |
| 177 | 176 | $rule = substr($rule, 0, strpos($rule, 'unique') + 6); |
| 178 | - } |
|
| 179 | - elseif(strpos($rule, 'exists')) |
|
| 177 | + } elseif(strpos($rule, 'exists')) |
|
| 180 | 178 | { |
| 181 | 179 | $rule = substr($rule, 0, strpos($rule, 'exists') - 1); |
| 182 | 180 | } |
| 183 | 181 | } |
| 184 | - } |
|
| 185 | - else |
|
| 182 | + } else |
|
| 186 | 183 | { |
| 187 | 184 | $route['body'] = 'conditions'; |
| 188 | 185 | } |
@@ -24,7 +24,7 @@ |
||
| 24 | 24 | * Get the notification's delivery channels. |
| 25 | 25 | * |
| 26 | 26 | * @param mixed $notifiable |
| 27 | - * @return array |
|
| 27 | + * @return string[] |
|
| 28 | 28 | */ |
| 29 | 29 | public function via($notifiable) |
| 30 | 30 | { |
@@ -57,29 +57,23 @@ |
||
| 57 | 57 | if ($exception instanceof \Illuminate\Database\QueryException) |
| 58 | 58 | { |
| 59 | 59 | \ErrorHandler::dbQueryError(); |
| 60 | - } |
|
| 61 | - else if ($exception instanceof \predis\connection\connectionexception) |
|
| 60 | + } else if ($exception instanceof \predis\connection\connectionexception) |
|
| 62 | 61 | { |
| 63 | 62 | \ErrorHandler::redisNotRunning(); |
| 64 | - } |
|
| 65 | - else if ($exception instanceof \GuzzleHttp\Exception\ClientException) |
|
| 63 | + } else if ($exception instanceof \GuzzleHttp\Exception\ClientException) |
|
| 66 | 64 | { |
| 67 | 65 | \ErrorHandler::connectionError(); |
| 68 | - } |
|
| 69 | - else if ($exception instanceof \Symfony\Component\HttpKernel\Exception\HttpException) |
|
| 66 | + } else if ($exception instanceof \Symfony\Component\HttpKernel\Exception\HttpException) |
|
| 70 | 67 | { |
| 71 | 68 | return \Response::json($exception->getMessage(), $exception->getStatusCode()); |
| 72 | - } |
|
| 73 | - else if ($exception instanceof \Illuminate\Validation\ValidationException) |
|
| 69 | + } else if ($exception instanceof \Illuminate\Validation\ValidationException) |
|
| 74 | 70 | { |
| 75 | 71 | return \Response::json($exception->errors(), 422); |
| 76 | - } |
|
| 77 | - else if ( ! $exception instanceof \Symfony\Component\Debug\Exception\FatalErrorException) |
|
| 72 | + } else if ( ! $exception instanceof \Symfony\Component\Debug\Exception\FatalErrorException) |
|
| 78 | 73 | { |
| 79 | 74 | return parent::render($request, $exception); |
| 80 | 75 | } |
| 81 | - } |
|
| 82 | - else |
|
| 76 | + } else |
|
| 83 | 77 | { |
| 84 | 78 | return parent::render($request, $exception); |
| 85 | 79 | } |
@@ -39,8 +39,7 @@ discard block |
||
| 39 | 39 | if ( ! $report) |
| 40 | 40 | { |
| 41 | 41 | \ErrorHandler::notFound('report'); |
| 42 | - } |
|
| 43 | - else if (! $skipPermission && ! \Core::users()->can($report->view_name, 'reports')) |
|
| 42 | + } else if (! $skipPermission && ! \Core::users()->can($report->view_name, 'reports')) |
|
| 44 | 43 | { |
| 45 | 44 | \ErrorHandler::noPermissions(); |
| 46 | 45 | } |
@@ -61,8 +60,7 @@ discard block |
||
| 61 | 60 | if ($perPage) |
| 62 | 61 | { |
| 63 | 62 | return $report->paginate($perPage); |
| 64 | - } |
|
| 65 | - else |
|
| 63 | + } else |
|
| 66 | 64 | { |
| 67 | 65 | return $report->get(); |
| 68 | 66 | } |
@@ -84,8 +84,7 @@ discard block |
||
| 84 | 84 | return $this->cache->tags([$this->cacheTag])->rememberForever($cacheKey, function() use ($arguments, $name) { |
| 85 | 85 | return call_user_func_array([$this->repo, $name], $arguments); |
| 86 | 86 | }); |
| 87 | - } |
|
| 88 | - else if ($this->cacheConfig) |
|
| 87 | + } else if ($this->cacheConfig) |
|
| 89 | 88 | { |
| 90 | 89 | $this->cache->tags($this->cacheConfig)->flush(); |
| 91 | 90 | return call_user_func_array([$this->repo, $name], $arguments); |
@@ -109,8 +108,7 @@ discard block |
||
| 109 | 108 | if ($cacheConfig && in_array($name, $cacheConfig['cache'])) |
| 110 | 109 | { |
| 111 | 110 | $this->cacheConfig = 'cache'; |
| 112 | - } |
|
| 113 | - else if ($cacheConfig && isset($cacheConfig['clear'][$name])) |
|
| 111 | + } else if ($cacheConfig && isset($cacheConfig['clear'][$name])) |
|
| 114 | 112 | { |
| 115 | 113 | $this->cacheConfig = $cacheConfig['clear'][$name]; |
| 116 | 114 | } |
@@ -157,8 +157,7 @@ discard block |
||
| 157 | 157 | if ($request->has('id')) |
| 158 | 158 | { |
| 159 | 159 | $rule = str_replace('{id}', $request->get('id'), $rule); |
| 160 | - } |
|
| 161 | - else |
|
| 160 | + } else |
|
| 162 | 161 | { |
| 163 | 162 | $rule = str_replace(',{id}', '', $rule); |
| 164 | 163 | } |
@@ -228,10 +227,8 @@ discard block |
||
| 228 | 227 | } |
| 229 | 228 | |
| 230 | 229 | if ($isPasswordClient && (in_array($permission, $this->skipPermissionCheck) || \Core::users()->can($permission, $this->model))) |
| 231 | - {} |
|
| 232 | - elseif ( ! $isPasswordClient && $user->tokenCan($this->model . '-' . $permission)) |
|
| 233 | - {} |
|
| 234 | - else |
|
| 230 | + {} elseif ( ! $isPasswordClient && $user->tokenCan($this->model . '-' . $permission)) |
|
| 231 | + {} else |
|
| 235 | 232 | { |
| 236 | 233 | |
| 237 | 234 | \ErrorHandler::noPermissions(); |
@@ -97,8 +97,7 @@ |
||
| 97 | 97 | } |
| 98 | 98 | |
| 99 | 99 | $tokens[] = $device->device_token; |
| 100 | - } |
|
| 101 | - catch (\Exception $e) |
|
| 100 | + } catch (\Exception $e) |
|
| 102 | 101 | { |
| 103 | 102 | $device->forceDelete(); |
| 104 | 103 | } |