From f68d1d30537698ef60199e34117d516c66a71060 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Tue, 18 Jun 2024 09:41:22 +1000 Subject: [PATCH] Static Analysis --- app/Http/Requests/Preview/PreviewInvoiceRequest.php | 4 +++- app/PaymentDrivers/CheckoutCom/CheckoutWebhook.php | 1 + app/PaymentDrivers/PayPal/PayPalBasePaymentDriver.php | 1 + app/PaymentDrivers/PayPal/PayPalWebhook.php | 2 +- app/PaymentDrivers/Stripe/BankTransfer.php | 6 +++--- app/Services/Pdf/PdfBuilder.php | 1 + app/Services/Pdf/PdfMock.php | 3 ++- app/Services/Template/TemplateAction.php | 2 ++ 8 files changed, 14 insertions(+), 6 deletions(-) diff --git a/app/Http/Requests/Preview/PreviewInvoiceRequest.php b/app/Http/Requests/Preview/PreviewInvoiceRequest.php index 2c8cc682f953..4a8d82e57b15 100644 --- a/app/Http/Requests/Preview/PreviewInvoiceRequest.php +++ b/app/Http/Requests/Preview/PreviewInvoiceRequest.php @@ -88,7 +88,8 @@ class PreviewInvoiceRequest extends Request public function resolveInvitation() { $invitation = false; - + + /** @phpstan-ignore-next-line */ if(! $this->entity_id ?? false) { return $this->stubInvitation(); } @@ -98,6 +99,7 @@ class PreviewInvoiceRequest extends Request 'quote' => $invitation = QuoteInvitation::withTrashed()->where('quote_id', $this->entity_id)->first(), 'credit' => $invitation = CreditInvitation::withTrashed()->where('credit_id', $this->entity_id)->first(), 'recurring_invoice' => $invitation = RecurringInvoiceInvitation::withTrashed()->where('recurring_invoice_id', $this->entity_id)->first(), + default => $invitation = false, }; if($invitation) { diff --git a/app/PaymentDrivers/CheckoutCom/CheckoutWebhook.php b/app/PaymentDrivers/CheckoutCom/CheckoutWebhook.php index 1004319ee6fa..0873dbcdf94f 100644 --- a/app/PaymentDrivers/CheckoutCom/CheckoutWebhook.php +++ b/app/PaymentDrivers/CheckoutCom/CheckoutWebhook.php @@ -56,6 +56,7 @@ class CheckoutWebhook implements ShouldQueue nlog("Checkout Webhook type not set"); } + /** @phpstan-ignore-next-line */ match($this->webhook_array['type']) { 'payment_approved' => $this->paymentApproved(), }; diff --git a/app/PaymentDrivers/PayPal/PayPalBasePaymentDriver.php b/app/PaymentDrivers/PayPal/PayPalBasePaymentDriver.php index 15b74889778c..4e01c7582c0b 100644 --- a/app/PaymentDrivers/PayPal/PayPalBasePaymentDriver.php +++ b/app/PaymentDrivers/PayPal/PayPalBasePaymentDriver.php @@ -103,6 +103,7 @@ class PayPalBasePaymentDriver extends BaseDriver "25" => $method = PaymentType::VENMO, "28" => $method = PaymentType::PAY_LATER, "29" => $method = PaymentType::CREDIT_CARD_OTHER, + default => $method = PaymentType::PAYPAL, }; return $method; diff --git a/app/PaymentDrivers/PayPal/PayPalWebhook.php b/app/PaymentDrivers/PayPal/PayPalWebhook.php index 2840e5ccb4ce..701f2817c315 100644 --- a/app/PaymentDrivers/PayPal/PayPalWebhook.php +++ b/app/PaymentDrivers/PayPal/PayPalWebhook.php @@ -63,7 +63,7 @@ class PayPalWebhook implements ShouldQueue if($this->verifyWebhook()) { nlog('verified'); - match($this->webhook_request['event_type']) { + match($this->webhook_request['event_type']) {//@phpstan-ignore-line 'CHECKOUT.ORDER.COMPLETED' => $this->checkoutOrderCompleted(), }; diff --git a/app/PaymentDrivers/Stripe/BankTransfer.php b/app/PaymentDrivers/Stripe/BankTransfer.php index d5f02d085878..4f7a1bac4392 100644 --- a/app/PaymentDrivers/Stripe/BankTransfer.php +++ b/app/PaymentDrivers/Stripe/BankTransfer.php @@ -80,7 +80,7 @@ class BankTransfer */ private function resolveBankType() { - return match ($this->stripe->client->currency()->code) { + return match ($this->stripe->client->currency()->code) { //@phpstan-ignore-line 'GBP' => ['type' => 'gb_bank_transfer'], 'EUR' => ['type' => 'eu_bank_transfer', 'eu_bank_transfer' => ['country' => $this->stripe->client->country->iso_3166_2]], 'JPY' => ['type' => 'jp_bank_transfer'], @@ -128,8 +128,8 @@ class BankTransfer } /* Create a pending payment */ - if ($pi->status == 'requires_action' && $pi->next_action->type == 'display_bank_transfer_instructions') { - match ($pi->next_action->display_bank_transfer_instructions->currency) { + if ($pi->status == 'requires_action' && $pi->next_action->type == 'display_bank_transfer_instructions') { //@phpstan-ignore-line + match ($pi->next_action->display_bank_transfer_instructions->currency) { //@phpstan-ignore-line 'mxn' => $data['bank_details'] = $this->formatDataforMx($pi), 'gbp' => $data['bank_details'] = $this->formatDataforUk($pi), 'eur' => $data['bank_details'] = $this->formatDataforEur($pi), diff --git a/app/Services/Pdf/PdfBuilder.php b/app/Services/Pdf/PdfBuilder.php index 601bf2229d35..5af214dbd30a 100644 --- a/app/Services/Pdf/PdfBuilder.php +++ b/app/Services/Pdf/PdfBuilder.php @@ -993,6 +993,7 @@ class PdfBuilder PdfService::DELIVERY_NOTE => $this->getDeliveryNoteSections(), PdfService::STATEMENT => $this->getStatementSections(), PdfService::PURCHASE_ORDER => $this->getPurchaseOrderSections(), + default => $this->getProductSections(), }; } diff --git a/app/Services/Pdf/PdfMock.php b/app/Services/Pdf/PdfMock.php index 0173ab8c624e..7bc40ec22006 100644 --- a/app/Services/Pdf/PdfMock.php +++ b/app/Services/Pdf/PdfMock.php @@ -174,7 +174,8 @@ class PdfMock match ($this->request['settings_type']) { 'group' => $settings = ClientSettings::buildClientSettings($this->company->settings, $this->request['settings']), 'client' => $settings = ClientSettings::buildClientSettings($this->company->settings, $this->request['settings']), - 'company' => $settings = (object)$this->request['settings'] + 'company' => $settings = (object)$this->request['settings'], + default => $settings = (object)$this->request['settings'], }; $settings = CompanySettings::setProperties($settings); diff --git a/app/Services/Template/TemplateAction.php b/app/Services/Template/TemplateAction.php index 170b0cef7701..2a892ad2b0b2 100644 --- a/app/Services/Template/TemplateAction.php +++ b/app/Services/Template/TemplateAction.php @@ -102,6 +102,7 @@ class TemplateAction implements ShouldQueue Expense::class => $resource->with('client'), Payment::class => $resource->with('invoices', 'client'), Client::class => $resource, + default => $resource, }; $result = $resource->withTrashed() @@ -219,6 +220,7 @@ class TemplateAction implements ShouldQueue Project::class => 'projects', Client::class => 'clients', Vendor::class => 'vendors', + default =>'invoices', }; }