From 3cfffb9912e93ae30cf90b4bf7a2067cbc9d1c88 Mon Sep 17 00:00:00 2001 From: Jellyfrog Date: Wed, 24 Mar 2021 15:13:43 +0100 Subject: [PATCH] Cleanups (#12642) Should only be cosmetic --- LibreNMS/Alert/Transport/Boxcar.php | 7 +++++++ LibreNMS/Alert/Transport/Clickatell.php | 4 +++- LibreNMS/Alert/Transport/Elasticsearch.php | 3 +++ LibreNMS/Alert/Transport/Osticket.php | 1 + LibreNMS/Alert/Transport/Playsms.php | 4 +++- LibreNMS/DB/Schema.php | 1 + LibreNMS/Data/Store/Rrd.php | 1 + LibreNMS/OS/Allied.php | 8 +++---- .../Snmptrap/Handlers/OspfIfStateChange.php | 3 +++ LibreNMS/Util/Clean.php | 2 +- app/ApiClients/RipeApi.php | 4 +--- app/Console/Commands/SetConfigCommand.php | 3 +-- .../Commands/SmokepingGenerateCommand.php | 3 ++- app/Console/Kernel.php | 2 ++ .../Controllers/Auth/RegisterController.php | 2 +- .../Controllers/Auth/TwoFactorController.php | 3 +-- .../Form/CopyDashboardController.php | 2 +- app/Http/Controllers/LegacyController.php | 1 + .../Controllers/PaginatedAjaxController.php | 1 - .../Select/ApplicationController.php | 3 +++ .../Controllers/ServiceTemplateController.php | 4 ++-- .../Controllers/Table/DeviceController.php | 8 +++---- .../Controllers/Table/GraylogController.php | 2 +- .../Table/RoutesTablesController.php | 3 +++ .../Controllers/Table/SyslogController.php | 4 +--- app/Http/Controllers/UserController.php | 2 +- .../Widgets/TopDevicesController.php | 4 ++-- .../Controllers/Widgets/WidgetController.php | 7 ++----- app/Jobs/PingCheck.php | 10 ++++----- app/Models/AlertRule.php | 6 +++--- app/Models/Device.php | 3 +-- app/Models/Notification.php | 21 ++++++++++--------- app/Policies/DeviceGroupPolicy.php | 2 +- app/Policies/PollerClusterPolicy.php | 1 - app/Policies/UserPolicy.php | 18 ++++++++-------- app/Providers/LegacyUserProvider.php | 5 ++--- app/View/Components/Submenu.php | 2 +- 37 files changed, 89 insertions(+), 71 deletions(-) diff --git a/LibreNMS/Alert/Transport/Boxcar.php b/LibreNMS/Alert/Transport/Boxcar.php index 37f023e353..ea5eb1f7ad 100644 --- a/LibreNMS/Alert/Transport/Boxcar.php +++ b/LibreNMS/Alert/Transport/Boxcar.php @@ -68,6 +68,9 @@ class Boxcar extends Transport $data['notification[sound]'] = $api['sound_warning']; } break; + default: + $severity = 'Unknown'; + break; } switch ($obj['state']) { case AlertState::RECOVERED: @@ -82,6 +85,10 @@ class Boxcar extends Transport case AlertState::ACKNOWLEDGED: $title_text = 'Acknowledged'; break; + default: + $title_text = $severity; + break; + } $data['notification[title]'] = $title_text . ' - ' . $obj['hostname'] . ' - ' . $obj['name']; $message_text = 'Timestamp: ' . $obj['timestamp']; diff --git a/LibreNMS/Alert/Transport/Clickatell.php b/LibreNMS/Alert/Transport/Clickatell.php index 00e47e8da1..134c7eb9d7 100644 --- a/LibreNMS/Alert/Transport/Clickatell.php +++ b/LibreNMS/Alert/Transport/Clickatell.php @@ -46,7 +46,9 @@ class Clickatell extends Transport $ret = curl_exec($curl); $code = curl_getinfo($curl, CURLINFO_HTTP_CODE); if ($code > 200) { - return var_dump($ret); + var_dump($ret); + + return; } return true; diff --git a/LibreNMS/Alert/Transport/Elasticsearch.php b/LibreNMS/Alert/Transport/Elasticsearch.php index 4d8872f308..b180dd6e2b 100644 --- a/LibreNMS/Alert/Transport/Elasticsearch.php +++ b/LibreNMS/Alert/Transport/Elasticsearch.php @@ -82,6 +82,9 @@ class Elasticsearch extends Transport case AlertState::BETTER: $state = 'better'; break; + default: + $state = 'unknown'; + break; } $data = [ diff --git a/LibreNMS/Alert/Transport/Osticket.php b/LibreNMS/Alert/Transport/Osticket.php index 99653c29f7..19fb3654cc 100644 --- a/LibreNMS/Alert/Transport/Osticket.php +++ b/LibreNMS/Alert/Transport/Osticket.php @@ -31,6 +31,7 @@ class Osticket extends Transport { $url = $opts['url']; $token = $opts['token']; + $email = ''; foreach (parse_email(Config::get('email_from')) as $from => $from_name) { $email = $from_name . ' <' . $from . '>'; diff --git a/LibreNMS/Alert/Transport/Playsms.php b/LibreNMS/Alert/Transport/Playsms.php index 75233eac36..e39884abdd 100644 --- a/LibreNMS/Alert/Transport/Playsms.php +++ b/LibreNMS/Alert/Transport/Playsms.php @@ -53,7 +53,9 @@ class Playsms extends Transport $ret = curl_exec($curl); $code = curl_getinfo($curl, CURLINFO_HTTP_CODE); if ($code > 202) { - return var_dump($ret); + var_dump($ret); + + return; } return true; diff --git a/LibreNMS/DB/Schema.php b/LibreNMS/DB/Schema.php index ca29882f4c..d521c8225b 100644 --- a/LibreNMS/DB/Schema.php +++ b/LibreNMS/DB/Schema.php @@ -144,6 +144,7 @@ class Schema public function getAllRelationshipPaths($base = 'devices') { $update_cache = true; + $cache = []; $cache_file = Config::get('install_dir') . "/cache/{$base}_relationships.cache"; $db_version = Version::get()->database(); diff --git a/LibreNMS/Data/Store/Rrd.php b/LibreNMS/Data/Store/Rrd.php index 9a4e63dab2..ffb925e762 100644 --- a/LibreNMS/Data/Store/Rrd.php +++ b/LibreNMS/Data/Store/Rrd.php @@ -357,6 +357,7 @@ class Rrd extends BaseDatastore { global $vdebug; $stat = Measurement::start($this->coalesceStatisticType($command)); + $output = null; try { $cmd = self::buildCommand($command, $filename, $options); diff --git a/LibreNMS/OS/Allied.php b/LibreNMS/OS/Allied.php index 827d73eaf3..765934ec31 100644 --- a/LibreNMS/OS/Allied.php +++ b/LibreNMS/OS/Allied.php @@ -100,9 +100,9 @@ class Allied extends OS implements OSDiscovery $hardware = $e; } - $device->version = str_replace(['"', ','], '', $version); - $device->features = str_replace('"', '', $features); - $device->hardware = str_replace('"', '', $hardware); - $device->serial = $serial; + $device->version = str_replace(['"', ','], '', $version ?? null); + $device->features = str_replace('"', '', $features ?? null); + $device->hardware = str_replace('"', '', $hardware ?? null); + $device->serial = $serial ?? null; } } diff --git a/LibreNMS/Snmptrap/Handlers/OspfIfStateChange.php b/LibreNMS/Snmptrap/Handlers/OspfIfStateChange.php index 93ad6234b8..9acda2f65f 100644 --- a/LibreNMS/Snmptrap/Handlers/OspfIfStateChange.php +++ b/LibreNMS/Snmptrap/Handlers/OspfIfStateChange.php @@ -79,6 +79,9 @@ class OspfIfStateChange implements SnmptrapHandler case 'loopback': $severity = 4; break; + default: + $severity = 0; + break; } Log::event("OSPF interface $port->ifName is $ospfPort->ospfIfState", $device->device_id, 'trap', $severity); diff --git a/LibreNMS/Util/Clean.php b/LibreNMS/Util/Clean.php index c9dd3f5c89..3eacf30b7e 100644 --- a/LibreNMS/Util/Clean.php +++ b/LibreNMS/Util/Clean.php @@ -84,7 +84,7 @@ class Clean $value = htmlentities($value); } - if (! isset($purifier)) { + if (! $purifier instanceof HTMLPurifier) { // initialize HTML Purifier here since this is the only user $p_config = HTMLPurifier_Config::createDefault(); $p_config->set('Cache.SerializerPath', Config::get('temp_dir', '/tmp')); diff --git a/app/ApiClients/RipeApi.php b/app/ApiClients/RipeApi.php index 4354b1fa72..a05d773406 100644 --- a/app/ApiClients/RipeApi.php +++ b/app/ApiClients/RipeApi.php @@ -67,12 +67,10 @@ class RipeApi extends BaseApi } /** - * @param $uri - * @param $options * @return array|mixed * @throws ApiException */ - private function makeApiCall($uri, $options) + private function makeApiCall(string $uri, array $options) { try { $response = $this->getClient()->get($uri, $options); diff --git a/app/Console/Commands/SetConfigCommand.php b/app/Console/Commands/SetConfigCommand.php index 7a58b3762f..186d4c2f67 100644 --- a/app/Console/Commands/SetConfigCommand.php +++ b/app/Console/Commands/SetConfigCommand.php @@ -85,10 +85,9 @@ class SetConfigCommand extends LnmsCommand /** * Convert the string input into the appropriate PHP native type * - * @param $value * @return mixed */ - private function juggleType($value) + private function juggleType(string $value) { $json = json_decode($value, true); diff --git a/app/Console/Commands/SmokepingGenerateCommand.php b/app/Console/Commands/SmokepingGenerateCommand.php index 659a9553ab..cc0809a034 100644 --- a/app/Console/Commands/SmokepingGenerateCommand.php +++ b/app/Console/Commands/SmokepingGenerateCommand.php @@ -124,6 +124,7 @@ class SmokepingGenerateCommand extends LnmsCommand public function buildTargetsConfiguration($devices) { // Take the devices array and build it into a hierarchical list + $smokelist = []; foreach ($devices as $device) { $smokelist[$device->type][$device->hostname] = ['transport' => $device->transport]; } @@ -222,7 +223,7 @@ class SmokepingGenerateCommand extends LnmsCommand /** * Determine if a list of targets is needed, and write one if so * - * @param array $devices A list of devices to create a a config block for + * @param array $smokelist A list of devices to create a a config block for * * @return array */ diff --git a/app/Console/Kernel.php b/app/Console/Kernel.php index dff56f6d90..31e9d4b70d 100644 --- a/app/Console/Kernel.php +++ b/app/Console/Kernel.php @@ -49,7 +49,9 @@ class Kernel extends ConsoleKernel { if (is_null($this->artisan)) { parent::getArtisan(); + /** @phpstan-ignore-next-line */ $this->artisan->setName(\LibreNMS\Config::get('project_name', 'LibreNMS')); + /** @phpstan-ignore-next-line */ $this->artisan->setVersion(Version::get()->local()); } diff --git a/app/Http/Controllers/Auth/RegisterController.php b/app/Http/Controllers/Auth/RegisterController.php index e474cec39a..2e3381519e 100644 --- a/app/Http/Controllers/Auth/RegisterController.php +++ b/app/Http/Controllers/Auth/RegisterController.php @@ -60,7 +60,7 @@ class RegisterController extends Controller * Create a new user instance after a valid registration. * * @param array $data - * @return \App\User + * @return User */ protected function create(array $data) { diff --git a/app/Http/Controllers/Auth/TwoFactorController.php b/app/Http/Controllers/Auth/TwoFactorController.php index ea5f77933f..0c4d5d4fe8 100644 --- a/app/Http/Controllers/Auth/TwoFactorController.php +++ b/app/Http/Controllers/Auth/TwoFactorController.php @@ -199,10 +199,9 @@ class TwoFactorController extends Controller } /** - * @param $user * @return mixed */ - private function loadSettings($user) + private function loadSettings(User $user) { if (Session::has('twofactoradd')) { return Session::get('twofactoradd'); diff --git a/app/Http/Controllers/Form/CopyDashboardController.php b/app/Http/Controllers/Form/CopyDashboardController.php index 24eb9c73ba..b0412a46f1 100644 --- a/app/Http/Controllers/Form/CopyDashboardController.php +++ b/app/Http/Controllers/Form/CopyDashboardController.php @@ -53,7 +53,7 @@ class CopyDashboardController extends Controller $success = $dashboard_copy->save(); } - if ($success) { + if ($success && isset($dashboard_copy)) { $widgets = UserWidget::where(['dashboard_id' => $dashboard_id, 'user_id' => Auth::id()])->get(); foreach ($widgets as $widget) { diff --git a/app/Http/Controllers/LegacyController.php b/app/Http/Controllers/LegacyController.php index 3e212e4725..6f85d4b5a8 100644 --- a/app/Http/Controllers/LegacyController.php +++ b/app/Http/Controllers/LegacyController.php @@ -58,6 +58,7 @@ class LegacyController extends Controller $html = ob_get_clean(); ob_end_clean(); + /** @phpstan-ignore-next-line */ if (isset($pagetitle) && is_array($pagetitle)) { // if prefix is set, put it in front if (Config::get('page_title_prefix')) { diff --git a/app/Http/Controllers/PaginatedAjaxController.php b/app/Http/Controllers/PaginatedAjaxController.php index 2bd272d9b2..76898fd49a 100644 --- a/app/Http/Controllers/PaginatedAjaxController.php +++ b/app/Http/Controllers/PaginatedAjaxController.php @@ -126,7 +126,6 @@ abstract class PaginatedAjaxController extends Controller { if ($search) { $query->where(function ($query) use ($fields, $search) { - /** @var Builder $query */ foreach ($fields as $field) { $query->orWhere($field, 'like', '%' . $search . '%'); } diff --git a/app/Http/Controllers/Select/ApplicationController.php b/app/Http/Controllers/Select/ApplicationController.php index 63fdb6903c..f9ac31c0e0 100644 --- a/app/Http/Controllers/Select/ApplicationController.php +++ b/app/Http/Controllers/Select/ApplicationController.php @@ -54,6 +54,9 @@ class ApplicationController extends SelectController return $query; } + /** + * @param Application $app + */ public function formatItem($app) { return [ diff --git a/app/Http/Controllers/ServiceTemplateController.php b/app/Http/Controllers/ServiceTemplateController.php index cf5da1cd63..1030aa3c11 100644 --- a/app/Http/Controllers/ServiceTemplateController.php +++ b/app/Http/Controllers/ServiceTemplateController.php @@ -211,9 +211,9 @@ class ServiceTemplateController extends Controller }, $updated)) > 0; } - if ($template->isDirty() || $devices_updated || $device_groups_updated) { + if ($template->isDirty() || $devices_updated || isset($device_groups_updated)) { try { - if ($template->save() || $devices_updated || $device_groups_updated) { + if ($template->save() || $devices_updated || isset($device_groups_updated)) { Toastr::success(__('Service Template :name updated', ['name' => $template->name])); } else { Toastr::error(__('Failed to save')); diff --git a/app/Http/Controllers/Table/DeviceController.php b/app/Http/Controllers/Table/DeviceController.php index 6018d5196a..5fa7f9e7e9 100644 --- a/app/Http/Controllers/Table/DeviceController.php +++ b/app/Http/Controllers/Table/DeviceController.php @@ -255,10 +255,10 @@ class DeviceController extends TableController } /** - * @param $device - * @param $count - * @param $tab - * @param $icon + * @param int|Device $device + * @param mixed $count + * @param mixed $tab + * @param mixed $icon * @return string */ private function formatMetric($device, $count, $tab, $icon) diff --git a/app/Http/Controllers/Table/GraylogController.php b/app/Http/Controllers/Table/GraylogController.php index 279f205f61..7dc23dede8 100644 --- a/app/Http/Controllers/Table/GraylogController.php +++ b/app/Http/Controllers/Table/GraylogController.php @@ -144,7 +144,7 @@ class GraylogController extends SimpleTableController /** * Cache device lookups so we don't lookup for every entry - * @param $source + * @param mixed $source * @return mixed */ private function deviceFromSource($source) diff --git a/app/Http/Controllers/Table/RoutesTablesController.php b/app/Http/Controllers/Table/RoutesTablesController.php index 97f0735482..9a3e0f0879 100644 --- a/app/Http/Controllers/Table/RoutesTablesController.php +++ b/app/Http/Controllers/Table/RoutesTablesController.php @@ -164,6 +164,9 @@ class RoutesTablesController extends TableController return $query; } + /** + * @param Route $route_entry + */ public function formatItem($route_entry) { $item = $route_entry->toArray(); diff --git a/app/Http/Controllers/Table/SyslogController.php b/app/Http/Controllers/Table/SyslogController.php index 1380984136..b893cf6279 100644 --- a/app/Http/Controllers/Table/SyslogController.php +++ b/app/Http/Controllers/Table/SyslogController.php @@ -25,7 +25,6 @@ namespace App\Http\Controllers\Table; use App\Models\Syslog; -use Illuminate\Database\Eloquent\Builder; class SyslogController extends TableController { @@ -68,7 +67,6 @@ class SyslogController extends TableController */ public function baseQuery($request) { - /** @var Builder $query */ return Syslog::hasAccess($request->user()) ->with('device') ->when($request->device_group, function ($query) use ($request) { @@ -109,7 +107,7 @@ class SyslogController extends TableController /** * @param int $syslog_priority - * @return string $syslog_priority_icon + * @return string|void */ private function priorityLabel($syslog_priority) { diff --git a/app/Http/Controllers/UserController.php b/app/Http/Controllers/UserController.php index 564654bd41..40c3f90787 100644 --- a/app/Http/Controllers/UserController.php +++ b/app/Http/Controllers/UserController.php @@ -202,7 +202,7 @@ class UserController extends Controller /** * @param User $user - * @param $dashboard + * @param mixed $dashboard * @return bool */ protected function updateDashboard(User $user, $dashboard) diff --git a/app/Http/Controllers/Widgets/TopDevicesController.php b/app/Http/Controllers/Widgets/TopDevicesController.php index 2ae598e934..08aedce310 100644 --- a/app/Http/Controllers/Widgets/TopDevicesController.php +++ b/app/Http/Controllers/Widgets/TopDevicesController.php @@ -123,7 +123,7 @@ class TopDevicesController extends WidgetController * @param string $left_table * @return Builder */ - private function withDeviceQuery($query, $left_table) + private function withDeviceQuery(Builder $query, $left_table) { $settings = $this->getSettings(); @@ -136,12 +136,12 @@ class TopDevicesController extends WidgetController ->groupBy("$left_table.device_id") ->where('devices.last_polled', '>', Carbon::now()->subMinutes($settings['time_interval'])) ->when($settings['device_group'], function ($query) use ($settings) { + /** @var Builder<\App\Models\DeviceRelatedModel> $query */ $query->inDeviceGroup($settings['device_group']); }); } /** - * @param Builder $query * @return Builder */ private function deviceQuery() diff --git a/app/Http/Controllers/Widgets/WidgetController.php b/app/Http/Controllers/Widgets/WidgetController.php index 18095d546e..a642dff562 100644 --- a/app/Http/Controllers/Widgets/WidgetController.php +++ b/app/Http/Controllers/Widgets/WidgetController.php @@ -60,14 +60,11 @@ abstract class WidgetController extends Controller public function __invoke(Request $request) { $this->show_settings = (bool) $request->get('settings'); + $settings = $this->getSettings(); if ($this->show_settings) { $view = $this->getSettingsView($request); - } - - $settings = $this->getSettings(); - - if (! $this->show_settings) { + } else { if (! empty($settings['device_group'])) { $this->title .= ' (' . DeviceGroup::find($settings['device_group'])->name . ')'; } diff --git a/app/Jobs/PingCheck.php b/app/Jobs/PingCheck.php index 866ebdb6ae..80c3a124d6 100644 --- a/app/Jobs/PingCheck.php +++ b/app/Jobs/PingCheck.php @@ -223,9 +223,9 @@ class PingCheck implements ShouldQueue * If the device is on the current tier, record the data and remove it * $data should have keys: hostname, status, and conditionally rtt * - * @param $data + * @param array $data */ - private function recordData($data) + private function recordData(array $data) { global $vdebug; @@ -280,7 +280,7 @@ class PingCheck implements ShouldQueue /** * Done processing $hostname, remove it from our active data * - * @param $hostname + * @param string $hostname */ private function complete($hostname) { @@ -292,9 +292,9 @@ class PingCheck implements ShouldQueue * Defer this data processing until all parent devices are complete * * - * @param $data + * @param array $data */ - private function defer($data) + private function defer(array $data) { $device = $this->devices->get($data['hostname']); diff --git a/app/Models/AlertRule.php b/app/Models/AlertRule.php index cf6a4ddc6d..84df98f4bd 100644 --- a/app/Models/AlertRule.php +++ b/app/Models/AlertRule.php @@ -34,7 +34,7 @@ class AlertRule extends BaseModel // ---- Query scopes ---- /** - * @param Builder $query + * @param Builder $query * @return Builder */ public function scopeEnabled($query) @@ -45,7 +45,7 @@ class AlertRule extends BaseModel /** * Scope for only alert rules that are currently in alarm * - * @param Builder $query + * @param Builder $query * @return Builder */ public function scopeIsActive($query) @@ -59,7 +59,7 @@ class AlertRule extends BaseModel * Scope to filter rules for devices permitted to user * (do not use for admin and global read-only users) * - * @param $query + * @param Builder $query * @param User $user * @return mixed */ diff --git a/app/Models/Device.php b/app/Models/Device.php index 94c6bd7311..44830aeb7e 100644 --- a/app/Models/Device.php +++ b/app/Models/Device.php @@ -328,10 +328,9 @@ class Device extends BaseModel * Update the location to the correct location and update GPS if needed * * @param \App\Models\Location|string $new_location location data - * @param string $hostname * @param bool $doLookup try to lookup the GPS coordinates */ - public function setLocation($new_location, $doLookup = false) + public function setLocation($new_location, bool $doLookup = false) { $new_location = $new_location instanceof Location ? $new_location : new Location(['location' => $new_location]); $new_location->location = $new_location->location ? Rewrite::location($new_location->location) : null; diff --git a/app/Models/Notification.php b/app/Models/Notification.php index 021f5cfae3..5b427a4bc4 100644 --- a/app/Models/Notification.php +++ b/app/Models/Notification.php @@ -35,7 +35,7 @@ class Notification extends Model * @param bool $enabled * @return bool */ - public function markRead($enabled = true) + public function markRead(bool $enabled = true): bool { return $this->setAttrib('read', $enabled); } @@ -46,17 +46,17 @@ class Notification extends Model * @var bool * @return bool */ - public function markSticky($enabled = true) + public function markSticky(bool $enabled = true): bool { return $this->setAttrib('sticky', $enabled); } /** - * @param $name - * @param $enabled + * @param string $name + * @param bool $enabled * @return bool */ - private function setAttrib($name, $enabled) + private function setAttrib($name, bool $enabled): bool { if ($enabled === true) { $read = new NotificationAttrib; @@ -74,7 +74,8 @@ class Notification extends Model // ---- Query Scopes ---- /** - * @param Builder $query + * @param Builder $query + * @param User $user * @return mixed */ public function scopeIsUnread(Builder $query, User $user) @@ -90,7 +91,7 @@ class Notification extends Model /** * Get all sticky notifications * - * @param Builder $query + * @param Builder $query */ public function scopeIsSticky(Builder $query) { @@ -99,7 +100,7 @@ class Notification extends Model } /** - * @param Builder $query + * @param Builder $query * @param User $user * @return mixed */ @@ -113,7 +114,7 @@ class Notification extends Model } /** - * @param Builder $query + * @param Builder $query * @return $this */ public function scopeLimit(Builder $query) @@ -122,7 +123,7 @@ class Notification extends Model } /** - * @param Builder $query + * @param Builder $query * @return Builder|static */ public function scopeSource(Builder $query) diff --git a/app/Policies/DeviceGroupPolicy.php b/app/Policies/DeviceGroupPolicy.php index f1c40ced84..19f4900b8a 100644 --- a/app/Policies/DeviceGroupPolicy.php +++ b/app/Policies/DeviceGroupPolicy.php @@ -43,7 +43,7 @@ class DeviceGroupPolicy /** * Determine whether the user can view any device group. * - * @param \App\User $user + * @param \App\Models\User $user * @return mixed */ public function viewAny(User $user) diff --git a/app/Policies/PollerClusterPolicy.php b/app/Policies/PollerClusterPolicy.php index a48241c78c..9984659398 100644 --- a/app/Policies/PollerClusterPolicy.php +++ b/app/Policies/PollerClusterPolicy.php @@ -96,7 +96,6 @@ class PollerClusterPolicy * Determine whether the user can manage the poller cluster. * * @param \App\Models\User $user - * @param \App\Models\PollerCluster $pollerCluster * @return mixed */ public function manage(User $user) diff --git a/app/Policies/UserPolicy.php b/app/Policies/UserPolicy.php index c102fc36ab..9d8e4d2cf6 100644 --- a/app/Policies/UserPolicy.php +++ b/app/Policies/UserPolicy.php @@ -12,7 +12,7 @@ class UserPolicy /** * Determine whether the user can manage users. * - * @param \App\Models\User $user + * @param User $user * @return bool */ public function manage(User $user) @@ -23,8 +23,8 @@ class UserPolicy /** * Determine whether the user can view the user. * - * @param \App\Models\User $user - * @param \App\Models\User $target + * @param User $user + * @param User $target * @return bool */ public function view(User $user, User $target) @@ -35,7 +35,7 @@ class UserPolicy /** * Determine whether the user can view any user. * - * @param \App\User $user + * @param User $user * @return mixed */ public function viewAny(User $user) @@ -46,7 +46,7 @@ class UserPolicy /** * Determine whether the user can create users. * - * @param \App\Models\User $user + * @param User $user * @return bool */ public function create(User $user) @@ -57,8 +57,8 @@ class UserPolicy /** * Determine whether the user can update the user. * - * @param \App\Models\User $user - * @param \App\Models\User $target + * @param User $user + * @param User $target * @return bool */ public function update(User $user, User $target) @@ -69,8 +69,8 @@ class UserPolicy /** * Determine whether the user can delete the user. * - * @param \App\Models\User $user - * @param \App\Models\User $target + * @param User $user + * @param User $target * @return bool */ public function delete(User $user, User $target) diff --git a/app/Providers/LegacyUserProvider.php b/app/Providers/LegacyUserProvider.php index 442c718479..738c63286f 100644 --- a/app/Providers/LegacyUserProvider.php +++ b/app/Providers/LegacyUserProvider.php @@ -138,9 +138,8 @@ class LegacyUserProvider implements UserProvider } \Toastr::error($auth_message); - if (empty($username)) { - $username = Session::get('username', $credentials['username']); - } + $username = $username ?? Session::get('username', $credentials['username']); + DB::table('authlog')->insert(['user' => $username, 'address' => Request::ip(), 'result' => $auth_message]); } finally { error_reporting(-1); diff --git a/app/View/Components/Submenu.php b/app/View/Components/Submenu.php index 341976f538..61a59f753b 100644 --- a/app/View/Components/Submenu.php +++ b/app/View/Components/Submenu.php @@ -58,7 +58,7 @@ class Submenu extends Component /** * Determine if the given option is the current selected option. * - * @param string $option + * @param string $url * @return bool */ public function isSelected($url)