diff --git a/app/Liquid/Utils/ExpressionUtils.php b/app/Liquid/Utils/ExpressionUtils.php index 402719c..9ed70d2 100644 --- a/app/Liquid/Utils/ExpressionUtils.php +++ b/app/Liquid/Utils/ExpressionUtils.php @@ -12,7 +12,7 @@ class ExpressionUtils */ public static function isAssociativeArray(array $array): bool { - if (empty($array)) { + if ($array === []) { return false; } @@ -81,8 +81,10 @@ class ExpressionUtils self::evaluateCondition($condition['right'], $variable, $object); case 'or': - return self::evaluateCondition($condition['left'], $variable, $object) || - self::evaluateCondition($condition['right'], $variable, $object); + if (self::evaluateCondition($condition['left'], $variable, $object)) { + return true; + } + return self::evaluateCondition($condition['right'], $variable, $object); case 'comparison': $leftValue = self::resolveValue($condition['left'], $variable, $object); diff --git a/app/Notifications/BatteryLow.php b/app/Notifications/BatteryLow.php index 09a5755..e590398 100644 --- a/app/Notifications/BatteryLow.php +++ b/app/Notifications/BatteryLow.php @@ -36,7 +36,7 @@ class BatteryLow extends Notification return (new MailMessage)->markdown('mail.battery-low', ['device' => $this->device]); } - public function toWebhook(object $notifiable) + public function toWebhook(object $notifiable): \App\Notifications\Messages\WebhookMessage { return WebhookMessage::create() ->data([ diff --git a/app/Services/PluginExportService.php b/app/Services/PluginExportService.php index 4cd246d..241764d 100644 --- a/app/Services/PluginExportService.php +++ b/app/Services/PluginExportService.php @@ -58,6 +58,7 @@ class PluginExportService // Generate shared.liquid if needed (for liquid templates) if ($plugin->markup_language === 'liquid') { $sharedTemplate = $this->generateSharedTemplate(); + /** @phpstan-ignore-next-line */ if ($sharedTemplate) { File::put($tempDir.'/shared.liquid', $sharedTemplate); } diff --git a/tests/Feature/GenerateDefaultImagesTest.php b/tests/Feature/GenerateDefaultImagesTest.php index dba668d..5a7b69a 100644 --- a/tests/Feature/GenerateDefaultImagesTest.php +++ b/tests/Feature/GenerateDefaultImagesTest.php @@ -18,7 +18,7 @@ beforeEach(function (): void { Storage::disk('public')->put('/images/sleep.bmp', 'fake-bmp-content'); }); -test('command transforms default images for all device models', function () { +test('command transforms default images for all device models', function (): void { // Ensure we have device models $deviceModels = DeviceModel::all(); expect($deviceModels)->not->toBeEmpty(); @@ -43,7 +43,7 @@ test('command transforms default images for all device models', function () { } }); -test('getDeviceSpecificDefaultImage returns correct path for device with model', function () { +test('getDeviceSpecificDefaultImage returns correct path for device with model', function (): void { $deviceModel = DeviceModel::first(); expect($deviceModel)->not->toBeNull(); @@ -66,7 +66,7 @@ test('getDeviceSpecificDefaultImage returns correct path for device with model', expect($sleepImage)->toBe($sleepPath); }); -test('getDeviceSpecificDefaultImage falls back to original images for device without model', function () { +test('getDeviceSpecificDefaultImage falls back to original images for device without model', function (): void { $device = new Device(); $device->deviceModel = null; @@ -77,7 +77,7 @@ test('getDeviceSpecificDefaultImage falls back to original images for device wit expect($sleepImage)->toBe('images/sleep.bmp'); }); -test('generateDefaultScreenImage creates images from Blade templates', function () { +test('generateDefaultScreenImage creates images from Blade templates', function (): void { $device = Device::factory()->create(); $setupUuid = ImageGenerationService::generateDefaultScreenImage($device, 'setup-logo'); @@ -97,14 +97,14 @@ test('generateDefaultScreenImage creates images from Blade templates', function expect(Storage::disk('public')->exists($sleepPath))->toBeTrue(); }); -test('generateDefaultScreenImage throws exception for invalid image type', function () { +test('generateDefaultScreenImage throws exception for invalid image type', function (): void { $device = Device::factory()->create(); - expect(fn () => ImageGenerationService::generateDefaultScreenImage($device, 'invalid-type')) + expect(fn (): string => ImageGenerationService::generateDefaultScreenImage($device, 'invalid-type')) ->toThrow(InvalidArgumentException::class); }); -test('getDeviceSpecificDefaultImage returns null for invalid image type', function () { +test('getDeviceSpecificDefaultImage returns null for invalid image type', function (): void { $device = new Device(); $device->deviceModel = DeviceModel::first(); diff --git a/tests/Feature/PluginLiquidFilterTest.php b/tests/Feature/PluginLiquidFilterTest.php index d571341..e6272c7 100644 --- a/tests/Feature/PluginLiquidFilterTest.php +++ b/tests/Feature/PluginLiquidFilterTest.php @@ -146,7 +146,7 @@ LIQUID // Instead of checking for absence of 1 and 2, let's verify the count // The filtered result should only contain 3, 4, 5 - $filteredContent = strip_tags($result); + $filteredContent = strip_tags((string) $result); $this->assertStringNotContainsString('1', $filteredContent); $this->assertStringNotContainsString('2', $filteredContent); }); diff --git a/tests/Feature/TransformDefaultImagesTest.php b/tests/Feature/TransformDefaultImagesTest.php index 9a27c03..2ea995f 100644 --- a/tests/Feature/TransformDefaultImagesTest.php +++ b/tests/Feature/TransformDefaultImagesTest.php @@ -17,7 +17,7 @@ beforeEach(function (): void { Storage::disk('public')->put('/images/sleep.bmp', 'fake-bmp-content'); }); -test('command transforms default images for all device models', function () { +test('command transforms default images for all device models', function (): void { // Ensure we have device models $deviceModels = DeviceModel::all(); expect($deviceModels)->not->toBeEmpty(); @@ -42,7 +42,7 @@ test('command transforms default images for all device models', function () { } }); -test('getDeviceSpecificDefaultImage falls back to original images for device without model', function () { +test('getDeviceSpecificDefaultImage falls back to original images for device without model', function (): void { $device = new Device(); $device->deviceModel = null; @@ -53,7 +53,7 @@ test('getDeviceSpecificDefaultImage falls back to original images for device wit expect($sleepImage)->toBe('images/sleep.bmp'); }); -test('generateDefaultScreenImage creates images from Blade templates', function () { +test('generateDefaultScreenImage creates images from Blade templates', function (): void { $device = Device::factory()->create(); $setupUuid = ImageGenerationService::generateDefaultScreenImage($device, 'setup-logo'); @@ -71,14 +71,14 @@ test('generateDefaultScreenImage creates images from Blade templates', function expect(Storage::disk('public')->exists($sleepPath))->toBeTrue(); })->skipOnCI(); -test('generateDefaultScreenImage throws exception for invalid image type', function () { +test('generateDefaultScreenImage throws exception for invalid image type', function (): void { $device = Device::factory()->create(); - expect(fn () => ImageGenerationService::generateDefaultScreenImage($device, 'invalid-type')) + expect(fn (): string => ImageGenerationService::generateDefaultScreenImage($device, 'invalid-type')) ->toThrow(InvalidArgumentException::class); }); -test('getDeviceSpecificDefaultImage returns null for invalid image type', function () { +test('getDeviceSpecificDefaultImage returns null for invalid image type', function (): void { $device = new Device(); $device->deviceModel = DeviceModel::first();