Skip to content

A free open source IT asset/license management system

Small cleanups for phpstan

snipec0b8d8957499
diff --git a/app/Http/Controllers/SettingsController.php b/app/Http/Controllers/SettingsController.php
index 9a4589f3ab..c89a4477b1 100644
--- a/app/Http/Controllers/SettingsController.php
+++ b/app/Http/Controllers/SettingsController.php
@@ -910,8 +910,8 @@ class SettingsController extends Controller
if ($requestedSlug !== null) {
$selectedSlug = $requestedSlug;
} else {
- $firstEnabled = collect($adapters)->first(fn ($a) => $a->isEnabled());
- $selectedSlug = $firstEnabled?->name() ?? ($adapters[0]->name() ?? null);
+ $default = collect($adapters)->first(fn ($a) => $a->isEnabled()) ?? ($adapters[0] ?? null);
+ $selectedSlug = $default?->name();
}
$selected = collect($adapters)->first(fn ($a) => $a->name() === $selectedSlug);
diff --git a/app/SyncAdapters/Fleet/FleetAdapter.php b/app/SyncAdapters/Fleet/FleetAdapter.php
index 8e389ae777..764ead3470 100644
--- a/app/SyncAdapters/Fleet/FleetAdapter.php
+++ b/app/SyncAdapters/Fleet/FleetAdapter.php
@@ -81,8 +81,17 @@ class FleetAdapter extends ConfigurableAdapter
protected function afterSaveConfig(): void
{
$url = $this->url();
- $token = $this->credential('token');
- if ($url === null || $url === '' || $token === null || $token === '') {
+ if ($url === '') {
+ return;
+ }
+
+ try {
+ $token = $this->credential('token');
+ } catch (\Throwable) {
+ return;
+ }
+
+ if ($token === '') {
return;
}
diff --git a/app/SyncAdapters/HostInventoryAdapter.php b/app/SyncAdapters/HostInventoryAdapter.php
index 525198b5f0..1250f3876a 100644
--- a/app/SyncAdapters/HostInventoryAdapter.php
+++ b/app/SyncAdapters/HostInventoryAdapter.php
@@ -55,6 +55,14 @@ interface HostInventoryAdapter
*/
public function isActive(): bool;
+ /**
+ * Three-state readiness for the settings-page tab indicator:
+ * 'active' (will sync), 'partial' (turned on but missing config),
+ * 'inactive' (toggle off). Drives the green/yellow/red dot and
+ * the sort order on the shared adapters page.
+ */
+ public function readinessStatus(): string;
+
/**
* Whether this instance is a shipped built-in (undeletable). The
* blade uses this to hide the delete control.
diff --git a/app/SyncAdapters/Mosyle/MosyleAdapter.php b/app/SyncAdapters/Mosyle/MosyleAdapter.php
index 1fa4c99f29..e13105cdb6 100644
--- a/app/SyncAdapters/Mosyle/MosyleAdapter.php
+++ b/app/SyncAdapters/Mosyle/MosyleAdapter.php
@@ -183,9 +183,6 @@ class MosyleAdapter extends ConfigurableAdapter implements PushableAdapter
if ($serial === null || $serial === '') {
$serial = $externalSource->external_id;
}
- if ($serial === '' || $serial === null) {
- return;
- }
$pushedFields = [];
$client = null;
diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon
index c562d15c5a..ac681b6bca 100644
--- a/phpstan-baseline.neon
+++ b/phpstan-baseline.neon
@@ -450,6 +450,12 @@ parameters:
count: 1
path: app/Console/Commands/PurgeEulaPDFs.php
+ -
+ message: '#^Access to an undefined property Illuminate\\Database\\Eloquent\\Model\:\:\$id\.$#'
+ identifier: property.notFound
+ count: 1
+ path: app/Console/Commands/PushInventory.php
+
-
message: '#^Offset int does not exist on array\<string, string\>\.$#'
identifier: offsetAccess.notFound
@@ -3264,6 +3270,12 @@ parameters:
count: 1
path: app/Http/Controllers/SettingsController.php
+ -
+ message: '#^Access to an undefined property Illuminate\\Database\\Eloquent\\Model\:\:\$id\.$#'
+ identifier: property.notFound
+ count: 1
+ path: app/Http/Controllers/SettingsController.php
+
-
message: '#^Loose comparison using \=\= between false and ''1'' will always evaluate to false\.$#'
identifier: equal.alwaysFalse
@@ -9738,6 +9750,30 @@ parameters:
count: 1
path: app/SyncAdapters/Support/MappingTargets.php
+ -
+ message: '#^Using nullsafe property access "\?\-\>email" on left side of \?\? is unnecessary\. Use \-\> instead\.$#'
+ identifier: nullsafe.neverNull
+ count: 1
+ path: app/SyncAdapters/Support/NotesComposer.php
+
+ -
+ message: '#^Using nullsafe property access "\?\-\>model_number" on left side of \?\? is unnecessary\. Use \-\> instead\.$#'
+ identifier: nullsafe.neverNull
+ count: 1
+ path: app/SyncAdapters/Support/NotesComposer.php
+
+ -
+ message: '#^Using nullsafe property access "\?\-\>name" on left side of \?\? is unnecessary\. Use \-\> instead\.$#'
+ identifier: nullsafe.neverNull
+ count: 7
+ path: app/SyncAdapters/Support/NotesComposer.php
+
+ -
+ message: '#^Using nullsafe property access "\?\-\>username" on left side of \?\? is unnecessary\. Use \-\> instead\.$#'
+ identifier: nullsafe.neverNull
+ count: 1
+ path: app/SyncAdapters/Support/NotesComposer.php
+
-
message: '#^Access to an undefined property App\\Models\\Actionlog\:\:\$created_by\.$#'
identifier: property.notFound