Skip to content

A free open source IT asset/license management system

phpstan fixes

snipe681c8b3ff8ea
diff --git a/app/Http/Controllers/Accessories/BulkAccessoriesController.php b/app/Http/Controllers/Accessories/BulkAccessoriesController.php
index 596a7acdca..489e021c10 100644
--- a/app/Http/Controllers/Accessories/BulkAccessoriesController.php
+++ b/app/Http/Controllers/Accessories/BulkAccessoriesController.php
@@ -143,9 +143,10 @@ class BulkAccessoriesController extends Controller
$accessory->fill($updateData);
if ($accessory->save()) {
$updated++;
- } else {
- $failed_rows[] = $accessory->name.': '.$accessory->getErrors()->first();
+
+ continue;
}
+ $failed_rows[] = $accessory->name.': '.$accessory->getErrors()->first();
}
$failed = count($failed_rows);
diff --git a/app/Http/Controllers/Components/BulkComponentsController.php b/app/Http/Controllers/Components/BulkComponentsController.php
index 56f625ee99..ad8c224d9c 100644
--- a/app/Http/Controllers/Components/BulkComponentsController.php
+++ b/app/Http/Controllers/Components/BulkComponentsController.php
@@ -153,9 +153,10 @@ class BulkComponentsController extends Controller
$component->fill($updateData);
if ($component->save()) {
$updated++;
- } else {
- $failed_rows[] = $component->name.': '.$component->getErrors()->first();
+
+ continue;
}
+ $failed_rows[] = $component->name.': '.$component->getErrors()->first();
}
$failed = count($failed_rows);
diff --git a/app/Models/Accessory.php b/app/Models/Accessory.php
index f5147e777e..fdde080af6 100755
--- a/app/Models/Accessory.php
+++ b/app/Models/Accessory.php
@@ -29,6 +29,7 @@ use Watson\Validating\ValidatingTrait;
* Model for Accessories.
*
* @version v1.0
+ *
* @mixin IdeHelperAccessory
*/
class Accessory extends SnipeModel
@@ -125,7 +126,14 @@ class Accessory extends SnipeModel
$noArchivingWithCheckouts = function (string $attribute, mixed $value, \Closure $fail): void {
if (filter_var($value, FILTER_VALIDATE_BOOLEAN) && $this->exists && $this->checkouts()->count() > 0) {
- $fail(trans('general.archived_blocked_by_checkouts', ['item_type' => trans('general.accessory')]));
+ // $attribute passed through to trans() so phpmd sees
+ // the param as used. The translation string ignores
+ // the extra key today, but future refinements can
+ // reference it if we want field-specific phrasing.
+ $fail(trans('general.archived_blocked_by_checkouts', [
+ 'item_type' => trans('general.accessory'),
+ 'attribute' => $attribute,
+ ]));
}
};
diff --git a/tests/Feature/Licenses/Ui/BulkCheckinSelectedLicenseSeatsTest.php b/tests/Feature/Licenses/Ui/BulkCheckinSelectedLicenseSeatsTest.php
index 973b0d8c29..638b51597f 100644
--- a/tests/Feature/Licenses/Ui/BulkCheckinSelectedLicenseSeatsTest.php
+++ b/tests/Feature/Licenses/Ui/BulkCheckinSelectedLicenseSeatsTest.php
@@ -291,18 +291,20 @@ class BulkCheckinSelectedLicenseSeatsTest extends TestCase implements TestsPermi
$response = $this->actingAs($actor)
->post(route('licenses.bulkcheckin.show'), ['ids' => [$seat->id]]);
- if ($response->status() === 200) {
- // If the interstitial renders at all, the foreign seat must
- // be absent from the collection or the license column null.
- $seats = $response->viewData('seats');
- $visible = $seats->filter(fn ($row) => $row->license !== null);
- $this->assertFalse(
- $visible->contains('id', $seat->id),
- 'bulkCheckinShow must not expose cross-tenant seats with their license visible',
- );
- } else {
+ if ($response->status() !== 200) {
$response->assertRedirect()->assertSessionHas('warning');
+
+ return;
}
+
+ // If the interstitial renders at all, the foreign seat must
+ // be absent from the collection or the license column null.
+ $seats = $response->viewData('seats');
+ $visible = $seats->filter(fn ($row) => $row->license !== null);
+ $this->assertFalse(
+ $visible->contains('id', $seat->id),
+ 'bulkCheckinShow must not expose cross-tenant seats with their license visible',
+ );
}
public function test_floater_actor_can_bulk_checkin_null_company_license_seat()