From 745c594f3b908e50baab27ec981e77d737df5022 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Mon, 15 Jul 2024 13:35:21 +1000 Subject: [PATCH] Static analysis --- app/Jobs/Util/Import.php | 1 - app/Listeners/Mail/MailSentListener.php | 2 +- app/Mail/Ninja/StripeConnectFailed.php | 2 +- app/Models/Document.php | 4 ++-- app/PaymentDrivers/PayPal/PayPalWebhook.php | 2 +- app/Services/EDocument/Standards/RoEInvoice.php | 2 +- app/Services/Pdf/PdfConfiguration.php | 4 ++-- app/Services/PdfMaker/Designs/Utilities/DesignHelpers.php | 2 +- app/Services/Subscription/SubscriptionService.php | 2 +- app/Services/Template/TemplateService.php | 2 +- app/Utils/Number.php | 6 +++--- app/Utils/TempFile.php | 2 +- 12 files changed, 15 insertions(+), 16 deletions(-) diff --git a/app/Jobs/Util/Import.php b/app/Jobs/Util/Import.php index f422c4014c..f4961b19fc 100644 --- a/app/Jobs/Util/Import.php +++ b/app/Jobs/Util/Import.php @@ -1545,7 +1545,6 @@ class Import implements ShouldQueue $file_path, $file_name, $file_info, - filesize($file_path), 0, false ); diff --git a/app/Listeners/Mail/MailSentListener.php b/app/Listeners/Mail/MailSentListener.php index 3db2aba09b..18a01585b8 100644 --- a/app/Listeners/Mail/MailSentListener.php +++ b/app/Listeners/Mail/MailSentListener.php @@ -46,7 +46,7 @@ class MailSentListener implements ShouldQueue try { $message_id = $event->sent->getMessageId(); - $message = MessageConverter::toEmail($event->sent->getOriginalMessage()); + $message = MessageConverter::toEmail($event->sent->getOriginalMessage()); //@phpstan-ignore-line if (!$message->getHeaders()->get('x-invitation')) { return; diff --git a/app/Mail/Ninja/StripeConnectFailed.php b/app/Mail/Ninja/StripeConnectFailed.php index 3508fbc9ed..bee93bd114 100644 --- a/app/Mail/Ninja/StripeConnectFailed.php +++ b/app/Mail/Ninja/StripeConnectFailed.php @@ -39,7 +39,7 @@ class StripeConnectFailed extends Mailable return new Envelope( subject: "Stripe Connect not configured, please login and connect.", from: config('ninja.contact.email'), - to: $this->user->email, + to: $this->user->email, //@phpstan-ignore-line ); } diff --git a/app/Models/Document.php b/app/Models/Document.php index 73e5a22ca5..140c98cdf6 100644 --- a/app/Models/Document.php +++ b/app/Models/Document.php @@ -245,9 +245,9 @@ class Document extends BaseModel try { $file = base64_encode($image); - $img = new \Imagick(); + $img = new \Imagick(); //@phpstan-ignore-line $img->readImageBlob($file); - $img->setImageCompression(true); + $img->setImageCompression(true); //@phpstan-ignore-line $img->setImageCompressionQuality(40); return $img->getImageBlob(); diff --git a/app/PaymentDrivers/PayPal/PayPalWebhook.php b/app/PaymentDrivers/PayPal/PayPalWebhook.php index 744230dee6..3a42bdf97c 100644 --- a/app/PaymentDrivers/PayPal/PayPalWebhook.php +++ b/app/PaymentDrivers/PayPal/PayPalWebhook.php @@ -297,7 +297,7 @@ class PayPalWebhook implements ShouldQueue $gateway = CompanyGateway::query() ->where('company_id', $company->id) ->where('gateway_key', $this->gateway_key) - ->first(function ($cg) use ($merchant_id) { + ->first(function ($cg) use ($merchant_id) { //@phpstan-ignore-line $config = $cg->getConfig(); if($config->merchantId == $merchant_id) { diff --git a/app/Services/EDocument/Standards/RoEInvoice.php b/app/Services/EDocument/Standards/RoEInvoice.php index 016f810d4e..a82f45224a 100644 --- a/app/Services/EDocument/Standards/RoEInvoice.php +++ b/app/Services/EDocument/Standards/RoEInvoice.php @@ -188,7 +188,7 @@ class RoEInvoice extends AbstractService $ubl_invoice->setCustomizationID("urn:cen.eu:en16931:2017#compliant#urn:efactura.mfinante.ro:CIUS-RO:1.0.1"); // invoice - $ubl_invoice->setId($invoice->number); + $ubl_invoice->setId($invoice->number); //@phpstan-ignore-line $ubl_invoice->setIssueDate(date_create($invoice->date)); $ubl_invoice->setDueDate(date_create($invoice->due_date)); $ubl_invoice->setInvoiceTypeCode("380"); diff --git a/app/Services/Pdf/PdfConfiguration.php b/app/Services/Pdf/PdfConfiguration.php index f639a01892..2adc2d1105 100644 --- a/app/Services/Pdf/PdfConfiguration.php +++ b/app/Services/Pdf/PdfConfiguration.php @@ -410,7 +410,7 @@ class PdfConfiguration $precision = 0; } - $value = number_format($v, $precision, $decimal, $thousand); + $value = number_format($v, $precision, $decimal, $thousand); //@phpstan-ignore-line $symbol = $this->currency->symbol; if ($this->settings->show_currency_code === true && $this->currency->code == 'CHF') { @@ -427,7 +427,7 @@ class PdfConfiguration return "{$symbol}{$value}"; } else { - return $this->formatValue($value); + return $this->formatValue($value); // @phpstan-ignore-line } } diff --git a/app/Services/PdfMaker/Designs/Utilities/DesignHelpers.php b/app/Services/PdfMaker/Designs/Utilities/DesignHelpers.php index 7c00cfb187..9a8fece5de 100644 --- a/app/Services/PdfMaker/Designs/Utilities/DesignHelpers.php +++ b/app/Services/PdfMaker/Designs/Utilities/DesignHelpers.php @@ -174,7 +174,7 @@ trait DesignHelpers // evaluating the variable. if (in_array(sprintf('%s%s.tax', '$', $type), (array) $this->context['pdf_variables']["{$column_type}_columns"])) { - $line_items = collect($this->entity->line_items)->filter(function ($item) use ($type_id) { + $line_items = collect($this->entity->line_items)->filter(function ($item) use ($type_id) { //@phpstan-ignore-line return $item->type_id = $type_id; }); diff --git a/app/Services/Subscription/SubscriptionService.php b/app/Services/Subscription/SubscriptionService.php index 9e97aee3c9..da88156c8d 100644 --- a/app/Services/Subscription/SubscriptionService.php +++ b/app/Services/Subscription/SubscriptionService.php @@ -428,7 +428,7 @@ class SubscriptionService /** * We refund unused days left. * - * @param Invoice $invoice + * @param \App\Models\Invoice | \App\Models\Credit $invoice * @return float */ private function calculateProRataRefund($invoice, $subscription = null): float diff --git a/app/Services/Template/TemplateService.php b/app/Services/Template/TemplateService.php index a286d05bbb..196e3c5f2c 100644 --- a/app/Services/Template/TemplateService.php +++ b/app/Services/Template/TemplateService.php @@ -654,7 +654,7 @@ class TemplateService 'updated_at' => $this->translateDate($invoice->pivot->updated_at, $payment->client->date_format(), $payment->client->locale()), 'timestamp' => $invoice->pivot->created_at->timestamp, ]; - })->merge($credits)->sortBy('timestamp')->toArray(); + })->concat($credits)->sortBy('timestamp')->toArray(); return [ 'status' => $payment->stringStatus($payment->status_id), diff --git a/app/Utils/Number.php b/app/Utils/Number.php index c1d601a80e..84394be04e 100644 --- a/app/Utils/Number.php +++ b/app/Utils/Number.php @@ -277,7 +277,7 @@ class Number return "{$symbol}{$value}"; } else { - return self::formatValue($value, $currency); + return self::formatValue($value, $currency); //@phpstan-ignore-line } } @@ -339,7 +339,7 @@ class Number $precision = 0; } - $value = number_format($v, $precision, $decimal, $thousand); + $value = number_format($v, $precision, $decimal, $thousand);//@phpstan-ignore-line $symbol = $currency->symbol; if ($entity->getSetting('show_currency_code') === true && $currency->code == 'CHF') { @@ -356,7 +356,7 @@ class Number return "{$symbol}{$value}"; } else { - return self::formatValue($value, $currency); + return self::formatValue($value, $currency); //@phpstan-ignore-line } } } diff --git a/app/Utils/TempFile.php b/app/Utils/TempFile.php index 16b1dc1a93..58cd8a942c 100644 --- a/app/Utils/TempFile.php +++ b/app/Utils/TempFile.php @@ -17,7 +17,7 @@ class TempFile { public static function path($url): string { - $temp_path = @tempnam(sys_get_temp_dir().'/'.sha1(time()), basename($url)); + $temp_path = @tempnam(sys_get_temp_dir().'/'.sha1((string)time()), basename($url)); copy($url, $temp_path); return $temp_path;