From 751f59af8917bcc097bb9abe63151a0bc3a43f5e Mon Sep 17 00:00:00 2001 From: Fabio Ivona Date: Thu, 15 Feb 2024 09:53:37 +0100 Subject: [PATCH] fix #517 BC --- src/Concerns/SendsAttachments.php | 37 ++++++++++++------------------- 1 file changed, 14 insertions(+), 23 deletions(-) diff --git a/src/Concerns/SendsAttachments.php b/src/Concerns/SendsAttachments.php index 582779a6..adf7fbf0 100644 --- a/src/Concerns/SendsAttachments.php +++ b/src/Concerns/SendsAttachments.php @@ -181,9 +181,8 @@ public function thumbnail(string $path): self $telegraph = clone $this; if (File::exists($path)) { - $maxSizeKb = config('telegraph.attachments.thumbnail.max_size_kb', 200); - - assert(is_float($maxSizeKb)); + /* @phpstan-ignore-next-line */ + $maxSizeKb = floatval(config('telegraph.attachments.thumbnail.max_size_kb', 200)); if (($size = $telegraph->fileSizeInKb($path)) > $maxSizeKb) { throw FileException::thumbnailSizeExceeded($size, $maxSizeKb); @@ -293,10 +292,8 @@ public function dice(string $emoji = null): self protected function attachPhoto(self $telegraph, string $path, ?string $filename): void { if (File::exists($path)) { - - $maxSizeInMb = config('telegraph.attachments.photo.max_size_mb', 10); - - assert(is_float($maxSizeInMb)); + /* @phpstan-ignore-next-line */ + $maxSizeInMb = floatval(config('telegraph.attachments.photo.max_size_mb', 10)); if (($size = $telegraph->fileSizeInMb($path)) > $maxSizeInMb) { throw FileException::photoSizeExceeded($size, $maxSizeInMb); @@ -313,9 +310,8 @@ protected function attachPhoto(self $telegraph, string $path, ?string $filename) throw FileException::invalidPhotoSize($totalLength, $heightWidthSumPx); } - $maxRatio = config('telegraph.attachments.photo.max_ratio', 20); - - assert(is_float($maxRatio)); + /* @phpstan-ignore-next-line */ + $maxRatio = floatval(config('telegraph.attachments.photo.max_ratio', 20)); if (($ratio = $height / $width) > $maxRatio || $ratio < (1 / $maxRatio)) { throw FileException::invalidPhotoRatio($ratio, $maxRatio); @@ -331,9 +327,8 @@ protected function attachPhoto(self $telegraph, string $path, ?string $filename) protected function attachAnimation(self $telegraph, string $path, ?string $filename): void { if (File::exists($path)) { - $maxSizeMb = config('telegraph.attachments.animation.max_size_mb', 50); - - assert(is_float($maxSizeMb)); + /* @phpstan-ignore-next-line */ + $maxSizeMb = floatval(config('telegraph.attachments.animation.max_size_mb', 50)); if (($size = $telegraph->fileSizeInMb($path)) > $maxSizeMb) { throw FileException::documentSizeExceeded($size, $maxSizeMb); @@ -352,9 +347,8 @@ protected function attachAnimation(self $telegraph, string $path, ?string $filen protected function attachVideo(self $telegraph, string $path, ?string $filename): void { if (File::exists($path)) { - $maxSizeMb = config('telegraph.attachments.video.max_size_mb', 50); - - assert(is_float($maxSizeMb)); + /* @phpstan-ignore-next-line */ + $maxSizeMb = floatval(config('telegraph.attachments.video.max_size_mb', 50)); if (($size = $telegraph->fileSizeInMb($path)) > $maxSizeMb) { throw FileException::documentSizeExceeded($size, $maxSizeMb); @@ -380,10 +374,8 @@ protected function attachVideo(self $telegraph, string $path, ?string $filename) protected function attachAudio(self $telegraph, string $path, ?string $filename): void { if (File::exists($path)) { - - $maxSizeMb = config('telegraph.attachments.audio.max_size_mb', 50); - - assert(is_float($maxSizeMb)); + /* @phpstan-ignore-next-line */ + $maxSizeMb = floatval(config('telegraph.attachments.audio.max_size_mb', 50)); if (($size = $telegraph->fileSizeInMb($path)) > $maxSizeMb) { throw FileException::documentSizeExceeded($size, $maxSizeMb); @@ -407,9 +399,8 @@ protected function attachDocument(self $telegraph, string $path, ?string $filena { if (File::exists($path)) { - $maxSizeMb = config('telegraph.attachments.document.max_size_mb', 50); - - assert(is_float($maxSizeMb)); + /* @phpstan-ignore-next-line */ + $maxSizeMb = floatval(config('telegraph.attachments.document.max_size_mb', 50)); if (($size = $telegraph->fileSizeInMb($path)) > $maxSizeMb) { throw FileException::documentSizeExceeded($size, $maxSizeMb);