diff --git a/app/Export/CSV/CreditExport.php b/app/Export/CSV/CreditExport.php index 1295d8ec2b6d..5f1e8b56d19d 100644 --- a/app/Export/CSV/CreditExport.php +++ b/app/Export/CSV/CreditExport.php @@ -241,7 +241,7 @@ class CreditExport extends BaseExport } if (in_array('credit.user_id', $this->input['report_keys'])) { - $entity['credit.user_id'] = $credit->user ? $credit->user->present()->name() : ''; + $entity['credit.user_id'] = $credit->user ? $credit->user->present()->name() : ''; //@phpstan-ignore-line } return $entity; diff --git a/app/Export/CSV/ExpenseExport.php b/app/Export/CSV/ExpenseExport.php index dfcc554b8891..76f49d997b5b 100644 --- a/app/Export/CSV/ExpenseExport.php +++ b/app/Export/CSV/ExpenseExport.php @@ -85,7 +85,7 @@ class ExpenseExport extends BaseExport ->where('company_id', $this->company->id); - if(!$this->input['include_deleted'] ?? false) { + if(!$this->input['include_deleted'] ?? false) { // @phpstan-ignore-line $query->where('is_deleted', 0); } diff --git a/app/Export/CSV/InvoiceExport.php b/app/Export/CSV/InvoiceExport.php index b4e00d42b8b7..d0839d03d6fb 100644 --- a/app/Export/CSV/InvoiceExport.php +++ b/app/Export/CSV/InvoiceExport.php @@ -63,7 +63,7 @@ class InvoiceExport extends BaseExport ->where('company_id', $this->company->id); - if(!$this->input['include_deleted'] ?? false) { + if(!$this->input['include_deleted'] ?? false) {// @phpstan-ignore-line $query->where('is_deleted', 0); } @@ -166,7 +166,8 @@ class InvoiceExport extends BaseExport } if (in_array('invoice.user_id', $this->input['report_keys'])) { - $entity['invoice.user_id'] = $invoice->user ? $invoice->user->present()->name() : ''; + $entity['invoice.user_id'] = $invoice->user ? $invoice->user->present()->name() : ''; // @phpstan-ignore-line + } return $entity; diff --git a/app/Export/CSV/InvoiceItemExport.php b/app/Export/CSV/InvoiceItemExport.php index f6d5d814a763..0e5efcac0b6d 100644 --- a/app/Export/CSV/InvoiceItemExport.php +++ b/app/Export/CSV/InvoiceItemExport.php @@ -75,7 +75,7 @@ class InvoiceItemExport extends BaseExport }) ->where('company_id', $this->company->id); - if(!$this->input['include_deleted'] ?? false) { + if(!$this->input['include_deleted'] ?? false) {// @phpstan-ignore-line $query->where('is_deleted', 0); } @@ -258,7 +258,7 @@ class InvoiceItemExport extends BaseExport } if (in_array('invoice.user_id', $this->input['report_keys'])) { - $entity['invoice.user_id'] = $invoice->user ? $invoice->user->present()->name() : ''; + $entity['invoice.user_id'] = $invoice->user ? $invoice->user->present()->name() : '';// @phpstan-ignore-line } return $entity; diff --git a/app/Export/CSV/PurchaseOrderExport.php b/app/Export/CSV/PurchaseOrderExport.php index 2f83844a4186..e1091dd6672f 100644 --- a/app/Export/CSV/PurchaseOrderExport.php +++ b/app/Export/CSV/PurchaseOrderExport.php @@ -63,7 +63,7 @@ class PurchaseOrderExport extends BaseExport }) ->where('company_id', $this->company->id); - if(!$this->input['include_deleted'] ?? false) { + if(!$this->input['include_deleted'] ?? false) { // @phpstan-ignore-line $query->where('is_deleted', 0); } @@ -167,7 +167,8 @@ class PurchaseOrderExport extends BaseExport } if (in_array('purchase_order.user_id', $this->input['report_keys'])) { - $entity['purchase_order.user_id'] = $purchase_order->user ? $purchase_order->user->present()->name() : ''; + $entity['purchase_order.user_id'] = $purchase_order->user ? $purchase_order->user->present()->name() : ''; // @phpstan-ignore-line + } if (in_array('purchase_order.assigned_user_id', $this->input['report_keys'])) { diff --git a/app/Http/Controllers/ClientController.php b/app/Http/Controllers/ClientController.php index 76fe6c661abd..2401fab5b381 100644 --- a/app/Http/Controllers/ClientController.php +++ b/app/Http/Controllers/ClientController.php @@ -429,7 +429,7 @@ class ClientController extends BaseController /** @var ?\Postmark\Models\DynamicResponseModel $response */ $response = $postmark->activateBounce((int)$bounce_id); - if($response && $response?->Message == 'OK' && !$response->Bounce->Inactive && $response->Bounce->Email) { + if($response && $response?->Message == 'OK' && !$response->Bounce->Inactive && $response->Bounce->Email) { // @phpstan-ignore-line $email = $response->Bounce->Email; //remove email from quarantine. //@TODO diff --git a/app/Http/Controllers/ClientPortal/ContactHashLoginController.php b/app/Http/Controllers/ClientPortal/ContactHashLoginController.php index d03e4cba3ab5..70c7d3404923 100644 --- a/app/Http/Controllers/ClientPortal/ContactHashLoginController.php +++ b/app/Http/Controllers/ClientPortal/ContactHashLoginController.php @@ -57,8 +57,9 @@ class ContactHashLoginController extends Controller return render('generic.error', [ 'title' => session()->get('title'), 'notification' => session()->get('notification'), - 'account' => auth()->guard('contact')?->user()?->user?->account, - 'company' => auth()->guard('contact')?->user()?->user?->company + 'account' => auth()->guard('contact')?->user()?->user?->account,// @phpstan-ignore-line + 'company' => auth()->guard('contact')?->user()?->user?->company // @phpstan-ignore-line + ]); } diff --git a/app/Http/Controllers/MailgunWebhookController.php b/app/Http/Controllers/MailgunWebhookController.php index 8a382836597e..0585ebc02d97 100644 --- a/app/Http/Controllers/MailgunWebhookController.php +++ b/app/Http/Controllers/MailgunWebhookController.php @@ -20,7 +20,6 @@ use Illuminate\Http\Request; */ class MailgunWebhookController extends BaseController { - private $invitation; public function __construct() { diff --git a/app/Http/Controllers/Reports/ReportExportController.php b/app/Http/Controllers/Reports/ReportExportController.php index 67a73e9b210a..ae3752a9e3e4 100644 --- a/app/Http/Controllers/Reports/ReportExportController.php +++ b/app/Http/Controllers/Reports/ReportExportController.php @@ -36,21 +36,16 @@ class ReportExportController extends BaseController return response()->json(['message' => 'Still working.....'], 409); } - if($report) { + Cache::forget($hash); - Cache::forget($hash); - - $headers = [ - 'Content-Disposition' => 'attachment', - 'Content-Type' => 'text/csv', - ]; - - return response()->streamDownload(function () use ($report) { - echo $report; - }, $this->filename, $headers); - - } + $headers = [ + 'Content-Disposition' => 'attachment', + 'Content-Type' => 'text/csv', + ]; + return response()->streamDownload(function () use ($report) { + echo $report; + }, $this->filename, $headers); } } diff --git a/app/Http/Controllers/Reports/ReportPreviewController.php b/app/Http/Controllers/Reports/ReportPreviewController.php index 1f33ecd413ef..2eb4eea34514 100644 --- a/app/Http/Controllers/Reports/ReportPreviewController.php +++ b/app/Http/Controllers/Reports/ReportPreviewController.php @@ -34,12 +34,9 @@ class ReportPreviewController extends BaseController return response()->json(['message' => 'Still working.....'], 409); } - if($report) { + Cache::forget($hash); - Cache::forget($hash); - - return response()->json($report, 200); - } + return response()->json($report, 200); } diff --git a/app/Http/Controllers/SelfUpdateController.php b/app/Http/Controllers/SelfUpdateController.php index 77c1e07bf2c7..d25b056a0e1a 100644 --- a/app/Http/Controllers/SelfUpdateController.php +++ b/app/Http/Controllers/SelfUpdateController.php @@ -122,26 +122,26 @@ class SelfUpdateController extends BaseController return response()->json(['message' => 'Update completed'], 200); } - private function runModelChecks() - { - Company::query() - ->cursor() - ->each(function ($company) { + // private function runModelChecks() + // { + // Company::query() + // ->cursor() + // ->each(function ($company) { - $settings = $company->settings; + // $settings = $company->settings; - if(property_exists($settings->pdf_variables, 'purchase_order_details')) { - return; - } + // if(property_exists($settings->pdf_variables, 'purchase_order_details')) { + // return; + // } - $pdf_variables = $settings->pdf_variables; - $pdf_variables->purchase_order_details = []; - $settings->pdf_variables = $pdf_variables; - $company->settings = $settings; - $company->save(); + // $pdf_variables = $settings->pdf_variables; + // $pdf_variables->purchase_order_details = []; + // $settings->pdf_variables = $pdf_variables; + // $company->settings = $settings; + // $company->save(); - }); - } + // }); + // } private function clearCacheDir() { diff --git a/app/Http/Controllers/TwilioController.php b/app/Http/Controllers/TwilioController.php index 126ce23ea0fe..f7366d0b8f65 100644 --- a/app/Http/Controllers/TwilioController.php +++ b/app/Http/Controllers/TwilioController.php @@ -164,7 +164,7 @@ class TwilioController extends BaseController return response()->json(['message' => 'Please update your first and/or last name in the User Details before verifying your number.'], 400); } - if (!$user->phone || $user->phone == '') { + if (!$user->phone || empty($user->phone)) { return response()->json(['message' => 'User found, but no valid phone number on file, please contact support.'], 400); } diff --git a/app/Http/Requests/Client/UpdateClientRequest.php b/app/Http/Requests/Client/UpdateClientRequest.php index 8933954de922..81da5af205f0 100644 --- a/app/Http/Requests/Client/UpdateClientRequest.php +++ b/app/Http/Requests/Client/UpdateClientRequest.php @@ -170,7 +170,7 @@ class UpdateClientRequest extends Request * down to the free plan setting properties which * are saveable * - * @param \stdClass $settings + * @param mixed $settings * @return \stdClass $settings */ private function filterSaveableSettings($settings) diff --git a/app/Http/Requests/Email/ClientEmailHistoryRequest.php b/app/Http/Requests/Email/ClientEmailHistoryRequest.php index 50dd772e39d6..2f0efc233f1d 100644 --- a/app/Http/Requests/Email/ClientEmailHistoryRequest.php +++ b/app/Http/Requests/Email/ClientEmailHistoryRequest.php @@ -18,7 +18,6 @@ class ClientEmailHistoryRequest extends Request { use MakesHash; - private string $error_message = ''; /** * Determine if the user is authorized to make this request. * diff --git a/app/Http/Requests/Email/EntityEmailHistoryRequest.php b/app/Http/Requests/Email/EntityEmailHistoryRequest.php index 180496e979be..5f08442a88b3 100644 --- a/app/Http/Requests/Email/EntityEmailHistoryRequest.php +++ b/app/Http/Requests/Email/EntityEmailHistoryRequest.php @@ -20,7 +20,6 @@ class EntityEmailHistoryRequest extends Request { use MakesHash; - private string $error_message = ''; private string $entity_plural = ''; /** * Determine if the user is authorized to make this request. diff --git a/app/Http/Requests/RecurringInvoice/UpdateRecurringInvoiceRequest.php b/app/Http/Requests/RecurringInvoice/UpdateRecurringInvoiceRequest.php index db70ca922927..a89baa8d2cf9 100644 --- a/app/Http/Requests/RecurringInvoice/UpdateRecurringInvoiceRequest.php +++ b/app/Http/Requests/RecurringInvoice/UpdateRecurringInvoiceRequest.php @@ -126,7 +126,7 @@ class UpdateRecurringInvoiceRequest extends Request } if (isset($input['line_items'])) { - $input['line_items'] = isset($input['line_items']) ? $this->cleanItems($input['line_items']) : []; + $input['line_items'] = $this->cleanItems($input['line_items']); $input['amount'] = $this->entityTotalAmount($input['line_items']); } diff --git a/app/Http/Requests/Report/GenericReportRequest.php b/app/Http/Requests/Report/GenericReportRequest.php index c9d467423fca..085de868efb3 100644 --- a/app/Http/Requests/Report/GenericReportRequest.php +++ b/app/Http/Requests/Report/GenericReportRequest.php @@ -17,7 +17,6 @@ use Illuminate\Auth\Access\AuthorizationException; class GenericReportRequest extends Request { - private string $error_message = ''; /** * Determine if the user is authorized to make this request. diff --git a/app/Http/Requests/User/UpdateUserRequest.php b/app/Http/Requests/User/UpdateUserRequest.php index 6b5bbf84a859..c95765e9c4ac 100644 --- a/app/Http/Requests/User/UpdateUserRequest.php +++ b/app/Http/Requests/User/UpdateUserRequest.php @@ -77,7 +77,7 @@ class UpdateUserRequest extends Request unset($input['oauth_user_token']); } - if(isset($input['password']) && strlen($input['password'] ?? '') > 1) + if(isset($input['password']) && is_string($input['password'])) { $input['password'] = trim($input['password']); } diff --git a/app/Http/ValidationRules/User/HasValidPhoneNumber.php b/app/Http/ValidationRules/User/HasValidPhoneNumber.php index 4d179b4ad0ee..48cde515fc81 100644 --- a/app/Http/ValidationRules/User/HasValidPhoneNumber.php +++ b/app/Http/ValidationRules/User/HasValidPhoneNumber.php @@ -51,7 +51,7 @@ class HasValidPhoneNumber implements Rule $twilio = new \Twilio\Rest\Client($sid, $token); - $country = auth()->user()->account?->companies()?->first()?->country(); + $country = auth()->user()->account?->companies()?->first()?->country(); //@phpstan-ignore-line if (!$country || strlen(auth()->user()->phone) < 2) { return true; diff --git a/app/Models/Task.php b/app/Models/Task.php index 5106f86bdd31..8479ec26f6f6 100644 --- a/app/Models/Task.php +++ b/app/Models/Task.php @@ -186,7 +186,7 @@ class Task extends BaseModel } if($this->status) { - return '
' . $this->status?->name ?? ''; + return '
' . $this->status?->name ?? ''; //@phpstan-ignore-line } return ''; diff --git a/app/Notifications/Admin/EntityViewedNotification.php b/app/Notifications/Admin/EntityViewedNotification.php index fc70cf7d9e5d..3975a8516ff2 100644 --- a/app/Notifications/Admin/EntityViewedNotification.php +++ b/app/Notifications/Admin/EntityViewedNotification.php @@ -136,16 +136,16 @@ class EntityViewedNotification extends Notification // return $data; // } - private function buildSubject() - { - $subject = ctrans( - "texts.notification_{$this->entity_name}_viewed_subject", - [ - 'client' => $this->contact->present()->name(), - $this->entity_name => $this->entity->number, - ] - ); + // private function buildSubject() + // { + // $subject = ctrans( + // "texts.notification_{$this->entity_name}_viewed_subject", + // [ + // 'client' => $this->contact->present()->name(), + // $this->entity_name => $this->entity->number, + // ] + // ); - return $subject; - } + // return $subject; + // } } diff --git a/app/PaymentDrivers/BaseDriver.php b/app/PaymentDrivers/BaseDriver.php index 86163415ad4e..e3720e0a3db7 100644 --- a/app/PaymentDrivers/BaseDriver.php +++ b/app/PaymentDrivers/BaseDriver.php @@ -559,7 +559,7 @@ class BaseDriver extends AbstractPaymentDriver $error = 'Payment Aborted'; } - if (! is_null($this->payment_hash)) { + if (! is_null($this->payment_hash)) { //@phpstan-ignore-line $this->unWindGatewayFees($this->payment_hash); } @@ -830,7 +830,7 @@ class BaseDriver extends AbstractPaymentDriver } $invoices_string = \implode(', ', collect($this->payment_hash->invoices())->pluck('invoice_number')->toArray()) ?: null; - $amount = Number::formatMoney($this->payment_hash?->amount_with_fee() ?? 0, $this->client); + $amount = Number::formatMoney($this->payment_hash?->amount_with_fee() ?? 0, $this->client); // @phpstan-ignore-line if($abbreviated && $invoices_string) { return $invoices_string; diff --git a/app/PaymentDrivers/CheckoutCom/Webhook.php b/app/PaymentDrivers/CheckoutCom/Webhook.php index 62cbc3039f15..14ac34025633 100644 --- a/app/PaymentDrivers/CheckoutCom/Webhook.php +++ b/app/PaymentDrivers/CheckoutCom/Webhook.php @@ -40,7 +40,7 @@ class Webhook $error_details = $e->error_details; nlog($error_details); - $http_status_code = isset($e->http_metadata) ? $e->http_metadata->getStatusCode() : null; + $http_status_code = isset($e->http_metadata) ? $e->http_metadata->getStatusCode() : null; //@phpstan-ignore-line } catch (CheckoutAuthorizationException $e) { // Bad Invalid authorization } diff --git a/app/PaymentDrivers/Eway/CreditCard.php b/app/PaymentDrivers/Eway/CreditCard.php index 8bd3e1602001..e7f97124566d 100644 --- a/app/PaymentDrivers/Eway/CreditCard.php +++ b/app/PaymentDrivers/Eway/CreditCard.php @@ -78,7 +78,7 @@ class CreditCard $this->logResponse($response); - throw new PaymentFailed($response_status['message'] ?? 'Unknown response from gateway, please contact you merchant.', 400); + throw new PaymentFailed($response_status['message'] ?? 'Unknown response from gateway, please contact you merchant.', 400); //@phpstan-ignore-line } //success @@ -135,7 +135,7 @@ class CreditCard $invoice_numbers = ''; if ($this->eway_driver->payment_hash->data) { - $invoice_numbers = collect($this->eway_driver->payment_hash->data->invoices)->pluck('invoice_number')->implode(','); + $invoice_numbers = collect($this->eway_driver->payment_hash->data->invoices)->pluck('invoice_number')->implode(','); //@phpstan-ignore-line } $amount = array_sum(array_column($this->eway_driver->payment_hash->invoices(), 'amount')) + $this->eway_driver->payment_hash->fee_total; diff --git a/app/PaymentDrivers/GoCardless/ACH.php b/app/PaymentDrivers/GoCardless/ACH.php index 694cac15b9af..e52e8ce54101 100644 --- a/app/PaymentDrivers/GoCardless/ACH.php +++ b/app/PaymentDrivers/GoCardless/ACH.php @@ -173,7 +173,7 @@ class ACH implements MethodInterface $description = "Amount {$request->amount} from client {$this->go_cardless->client->present()->name()}"; } - $amount = $this->go_cardless->convertToGoCardlessAmount($this->go_cardless->payment_hash?->amount_with_fee(), $this->go_cardless->client->currency()->precision); + $amount = $this->go_cardless->convertToGoCardlessAmount($this->go_cardless->payment_hash?->amount_with_fee(), $this->go_cardless->client->currency()->precision); //@phpstan-ignore-line try { $payment = $this->go_cardless->gateway->payments()->create([ diff --git a/app/PaymentDrivers/MolliePaymentDriver.php b/app/PaymentDrivers/MolliePaymentDriver.php index 0f02d33e12f3..d2fd97d53fec 100644 --- a/app/PaymentDrivers/MolliePaymentDriver.php +++ b/app/PaymentDrivers/MolliePaymentDriver.php @@ -156,7 +156,7 @@ class MolliePaymentDriver extends BaseDriver return [ 'transaction_reference' => $refund->id, 'transaction_response' => json_encode($refund), - 'success' => $refund->status === 'refunded' ? true : false, + 'success' => $refund->status === 'refunded' ? true : false, //@phpstan-ignore-line 'description' => $refund->description, 'code' => 200, ]; diff --git a/app/PaymentDrivers/StripePaymentDriver.php b/app/PaymentDrivers/StripePaymentDriver.php index cb3b0584d4e6..69920e31e6b5 100644 --- a/app/PaymentDrivers/StripePaymentDriver.php +++ b/app/PaymentDrivers/StripePaymentDriver.php @@ -489,7 +489,7 @@ class StripePaymentDriver extends BaseDriver { $customer = Customer::retrieve($customer_id, $this->stripe_connect_auth); - return $customer ?? null; + return $customer ?? null; // @phpstan-ignore-line } /** diff --git a/app/Services/EDocument/Imports/ZugferdEDocument.php b/app/Services/EDocument/Imports/ZugferdEDocument.php index 49fb780ffab3..f8ec7a6f7dd9 100644 --- a/app/Services/EDocument/Imports/ZugferdEDocument.php +++ b/app/Services/EDocument/Imports/ZugferdEDocument.php @@ -46,8 +46,9 @@ class ZugferdEDocument extends AbstractService { $this->document->getDocumentInformation($documentno, $documenttypecode, $documentdate, $invoiceCurrency, $taxCurrency, $documentname, $documentlanguage, $effectiveSpecifiedPeriod); $this->document->getDocumentSummation($grandTotalAmount, $duePayableAmount, $lineTotalAmount, $chargeTotalAmount, $allowanceTotalAmount, $taxBasisTotalAmount, $taxTotalAmount, $roundingAmount, $totalPrepaidAmount); - $expense = Expense::where('amount', $grandTotalAmount)->where("transaction_reference", $documentno)->whereDate("date", $documentdate)->first(); - if (empty($expense)) { + /** @var \App\Models\Expense $expense */ + $expense = Expense::where("company_id", $user->company()->id)->where('amount', $grandTotalAmount)->where("transaction_reference", $documentno)->whereDate("date", $documentdate)->first(); + if (!$expense) { // The document does not exist as an expense // Handle accordingly $visualizer = new ZugferdVisualizer($this->document); @@ -59,13 +60,11 @@ class ZugferdEDocument extends AbstractService { $expense = ExpenseFactory::create($user->company()->id, $user->id); $expense->date = $documentdate; - $expense->user_id = $user->id; - $expense->company_id = $user->company->id; $expense->public_notes = $documentno; - $expense->currency_id = Currency::whereCode($invoiceCurrency)->first()->id; + $expense->currency_id = Currency::whereCode($invoiceCurrency)->first()->id ?? $user->company()->settings->currency_id; $expense->save(); - $origin_file = TempFile::UploadedFileFromRaw($this->tempdocument, $this->documentname, "application/xml"); + $origin_file = TempFile::UploadedFileFromRaw($this->tempdocument, $this->documentname, "application/xml"); (new UploadFile($origin_file, UploadFile::DOCUMENT, $user, $expense->company, $expense, null, false))->handle(); $uploaded_file = TempFile::UploadedFileFromRaw($visualizer->renderPdf(), $documentno."_visualiser.pdf", "application/pdf"); (new UploadFile($uploaded_file, UploadFile::DOCUMENT, $user, $expense->company, $expense, null, false))->handle(); diff --git a/app/Services/EDocument/Standards/FatturaPA.php b/app/Services/EDocument/Standards/FatturaPA.php index 626c67d26dc1..455083033ce8 100644 --- a/app/Services/EDocument/Standards/FatturaPA.php +++ b/app/Services/EDocument/Standards/FatturaPA.php @@ -44,7 +44,7 @@ use CleverIt\UBL\Invoice\FatturaPA\common\FatturaElettronicaHeader; */ class FatturaPA extends AbstractService { - private $xml; + // private $xml; //urn:cen.eu:en16931:2017#compliant#urn:fatturapa.gov.it:CIUS-IT:2.0.0 //UFF001 diff --git a/app/Services/Email/AdminEmail.php b/app/Services/Email/AdminEmail.php index 4dc1e1188152..1a1a76513b8b 100644 --- a/app/Services/Email/AdminEmail.php +++ b/app/Services/Email/AdminEmail.php @@ -205,7 +205,7 @@ class AdminEmail implements ShouldQueue $this->entityEmailFailed($message); /* Don't send postmark failures to Sentry */ - if (Ninja::isHosted() && (!$e instanceof ClientException)) { + if (Ninja::isHosted() && (!$e instanceof ClientException)) { //@phpstan-ignore-line app('sentry')->captureException($e); } } diff --git a/app/Services/Payment/RefundPayment.php b/app/Services/Payment/RefundPayment.php index 144abff2068c..a17baa67051e 100644 --- a/app/Services/Payment/RefundPayment.php +++ b/app/Services/Payment/RefundPayment.php @@ -33,9 +33,6 @@ class RefundPayment public function __construct(public Payment $payment, public array $refund_data) { - $this->gateway_refund_status = false; - - $this->activity_repository = new ActivityRepository(); } public function run() diff --git a/app/Services/Pdf/PdfBuilder.php b/app/Services/Pdf/PdfBuilder.php index 5af214dbd30a..fe27b6979af3 100644 --- a/app/Services/Pdf/PdfBuilder.php +++ b/app/Services/Pdf/PdfBuilder.php @@ -1665,7 +1665,7 @@ class PdfBuilder if ($child['element'] !== 'script') { if ($this->service->company->markdown_enabled && array_key_exists('content', $child)) { $child['content'] = str_replace('
', "\r", ($child['content'] ?? '')); - $child['content'] = $this->commonmark->convert($child['content'] ?? ''); + $child['content'] = $this->commonmark->convert($child['content'] ?? ''); //@phpstan-ignore-line } } diff --git a/app/Services/Pdf/PdfMock.php b/app/Services/Pdf/PdfMock.php index 7bc40ec22006..5ef5350e9da2 100644 --- a/app/Services/Pdf/PdfMock.php +++ b/app/Services/Pdf/PdfMock.php @@ -469,7 +469,7 @@ class PdfMock '$country_2' => 'AF', '$firstName' => 'Benedict', '$user.name' => 'Derrick Monahan DDS Erna Wunsch', - '$font_name' => isset($this->settings?->primary_font) ? $this->settings?->primary_font : 'Roboto', + '$font_name' => isset($this->settings?->primary_font) ? $this->settings?->primary_font : 'Roboto', //@phpstan-ignore-line '$auto_bill' => 'This invoice will automatically be billed to your credit card on file on the due date.', '$payments' => '', '$task.tax' => '', diff --git a/app/Services/PdfMaker/Design.php b/app/Services/PdfMaker/Design.php index d674e2c6b696..c9b5bfa94ca5 100644 --- a/app/Services/PdfMaker/Design.php +++ b/app/Services/PdfMaker/Design.php @@ -287,7 +287,7 @@ class Design extends BaseDesign { $elements = []; - if (!$this->client) { + if (!$this->client) {//@phpstan-ignore-line return $elements; } @@ -359,7 +359,7 @@ class Design extends BaseDesign $variables = $this->context['pdf_variables']['credit_details']; } - if ($this->vendor) { + if ($this->vendor) { //@phpstan-ignore-line $variables = $this->context['pdf_variables']['purchase_order_details']; } diff --git a/app/Services/PdfMaker/Designs/Utilities/DesignHelpers.php b/app/Services/PdfMaker/Designs/Utilities/DesignHelpers.php index 0ffdda3e9e17..7c00cfb1871e 100644 --- a/app/Services/PdfMaker/Designs/Utilities/DesignHelpers.php +++ b/app/Services/PdfMaker/Designs/Utilities/DesignHelpers.php @@ -64,9 +64,9 @@ trait DesignHelpers $this->document(); - $this->settings_object = $this->vendor ? $this->vendor->company : $this->client; + $this->settings_object = $this->vendor ? $this->vendor->company : $this->client; //@phpstan-ignore-line - $this->company = $this->vendor ? $this->vendor->company : $this->client->company; + $this->company = $this->vendor ? $this->vendor->company : $this->client->company; //@phpstan-ignore-line return $this; } @@ -387,7 +387,7 @@ trait DesignHelpers return ''; } - if ($this->client->company->custom_fields && ! property_exists($this->client->company->custom_fields, $field)) { + if ($this->client->company->custom_fields && ! property_exists($this->client->company->custom_fields, $field)) { //@phpstan-ignore-line return ''; } diff --git a/app/Services/PdfMaker/PdfMaker.php b/app/Services/PdfMaker/PdfMaker.php index 876500e13309..c251c3a1da43 100644 --- a/app/Services/PdfMaker/PdfMaker.php +++ b/app/Services/PdfMaker/PdfMaker.php @@ -27,16 +27,6 @@ class PdfMaker public $document; - private $xpath; - - private $filters = [ - ' '', - ' '', - ']]]]>]]>' => '', - ']]>' => '', - '' => '', - ]; - private $options; /** @var CommonMarkConverter */ diff --git a/app/Services/PdfMaker/PdfMakerUtilities.php b/app/Services/PdfMaker/PdfMakerUtilities.php index 281f576c0465..b317973a52c4 100644 --- a/app/Services/PdfMaker/PdfMakerUtilities.php +++ b/app/Services/PdfMaker/PdfMakerUtilities.php @@ -94,7 +94,7 @@ trait PdfMakerUtilities if ($child['element'] !== 'script') { if (array_key_exists('process_markdown', $this->data) && array_key_exists('content', $child) && $this->data['process_markdown']) { $child['content'] = str_replace('
', "\r", ($child['content'] ?? '')); - $child['content'] = $this->commonmark->convert($child['content'] ?? ''); + $child['content'] = $this->commonmark->convert($child['content'] ?? ''); //@phpstan-ignore-line } } diff --git a/app/Services/PurchaseOrder/CreateInvitations.php b/app/Services/PurchaseOrder/CreateInvitations.php index 12bdfc60cf01..9813f13ba6a2 100644 --- a/app/Services/PurchaseOrder/CreateInvitations.php +++ b/app/Services/PurchaseOrder/CreateInvitations.php @@ -41,7 +41,11 @@ class CreateInvitations extends AbstractService public function run() { - $contacts = $this->purchase_order?->vendor?->contacts()->get(); + + if(!$this->purchase_order->vendor) + return $this->purchase_order; + + $contacts = $this->purchase_order->vendor->contacts()->get(); if ($contacts->count() == 0) { $this->createBlankContact(); diff --git a/app/Services/PurchaseOrder/MarkSent.php b/app/Services/PurchaseOrder/MarkSent.php index c56b89317302..c357684be697 100644 --- a/app/Services/PurchaseOrder/MarkSent.php +++ b/app/Services/PurchaseOrder/MarkSent.php @@ -11,19 +11,15 @@ namespace App\Services\PurchaseOrder; -use App\Models\PurchaseOrder; +use App\Models\Vendor; use App\Models\Webhook; +use App\Models\PurchaseOrder; class MarkSent { - private $vendor; - - private $purchase_order; - - public function __construct($vendor, $purchase_order) + + public function __construct(public Vendor $vendor, public PurchaseOrder $purchase_order) { - $this->vendor = $vendor; - $this->purchase_order = $purchase_order; } public function run() diff --git a/app/Services/Quote/MarkApproved.php b/app/Services/Quote/MarkApproved.php deleted file mode 100644 index 0bb44115d929..000000000000 --- a/app/Services/Quote/MarkApproved.php +++ /dev/null @@ -1,40 +0,0 @@ -client = $client; - } - - public function run($quote) - { - /* Return immediately if status is not draft */ - if ($quote->status_id != Quote::STATUS_SENT) { - return $quote; - } - - $quote->service()->setStatus(Quote::STATUS_APPROVED)->applyNumber()->save(); - - event(new QuoteWasMarkedApproved($quote, $quote->company, Ninja::eventVars())); - - return $quote; - } -} diff --git a/app/Services/Quote/UpdateReminder.php b/app/Services/Quote/UpdateReminder.php index 9cf39da12871..e4af99b70594 100644 --- a/app/Services/Quote/UpdateReminder.php +++ b/app/Services/Quote/UpdateReminder.php @@ -171,39 +171,39 @@ class UpdateReminder extends AbstractService return $this->quote; } - private function addTimeInterval($date, $endless_reminder_frequency_id): ?Carbon - { - if (! $date) { - return null; - } + // private function addTimeInterval($date, $endless_reminder_frequency_id): ?Carbon + // { + // if (! $date) { + // return null; + // } - switch ($endless_reminder_frequency_id) { - case RecurringInvoice::FREQUENCY_DAILY: - return Carbon::parse($date)->addDay()->startOfDay(); - case RecurringInvoice::FREQUENCY_WEEKLY: - return Carbon::parse($date)->addWeek()->startOfDay(); - case RecurringInvoice::FREQUENCY_TWO_WEEKS: - return Carbon::parse($date)->addWeeks(2)->startOfDay(); - case RecurringInvoice::FREQUENCY_FOUR_WEEKS: - return Carbon::parse($date)->addWeeks(4)->startOfDay(); - case RecurringInvoice::FREQUENCY_MONTHLY: - return Carbon::parse($date)->addMonthNoOverflow()->startOfDay(); - case RecurringInvoice::FREQUENCY_TWO_MONTHS: - return Carbon::parse($date)->addMonthsNoOverflow(2)->startOfDay(); - case RecurringInvoice::FREQUENCY_THREE_MONTHS: - return Carbon::parse($date)->addMonthsNoOverflow(3)->startOfDay(); - case RecurringInvoice::FREQUENCY_FOUR_MONTHS: - return Carbon::parse($date)->addMonthsNoOverflow(4)->startOfDay(); - case RecurringInvoice::FREQUENCY_SIX_MONTHS: - return Carbon::parse($date)->addMonthsNoOverflow(6)->startOfDay(); - case RecurringInvoice::FREQUENCY_ANNUALLY: - return Carbon::parse($date)->addYear()->startOfDay(); - case RecurringInvoice::FREQUENCY_TWO_YEARS: - return Carbon::parse($date)->addYears(2)->startOfDay(); - case RecurringInvoice::FREQUENCY_THREE_YEARS: - return Carbon::parse($date)->addYears(3)->startOfDay(); - default: - return null; - } - } + // switch ($endless_reminder_frequency_id) { + // case RecurringInvoice::FREQUENCY_DAILY: + // return Carbon::parse($date)->addDay()->startOfDay(); + // case RecurringInvoice::FREQUENCY_WEEKLY: + // return Carbon::parse($date)->addWeek()->startOfDay(); + // case RecurringInvoice::FREQUENCY_TWO_WEEKS: + // return Carbon::parse($date)->addWeeks(2)->startOfDay(); + // case RecurringInvoice::FREQUENCY_FOUR_WEEKS: + // return Carbon::parse($date)->addWeeks(4)->startOfDay(); + // case RecurringInvoice::FREQUENCY_MONTHLY: + // return Carbon::parse($date)->addMonthNoOverflow()->startOfDay(); + // case RecurringInvoice::FREQUENCY_TWO_MONTHS: + // return Carbon::parse($date)->addMonthsNoOverflow(2)->startOfDay(); + // case RecurringInvoice::FREQUENCY_THREE_MONTHS: + // return Carbon::parse($date)->addMonthsNoOverflow(3)->startOfDay(); + // case RecurringInvoice::FREQUENCY_FOUR_MONTHS: + // return Carbon::parse($date)->addMonthsNoOverflow(4)->startOfDay(); + // case RecurringInvoice::FREQUENCY_SIX_MONTHS: + // return Carbon::parse($date)->addMonthsNoOverflow(6)->startOfDay(); + // case RecurringInvoice::FREQUENCY_ANNUALLY: + // return Carbon::parse($date)->addYear()->startOfDay(); + // case RecurringInvoice::FREQUENCY_TWO_YEARS: + // return Carbon::parse($date)->addYears(2)->startOfDay(); + // case RecurringInvoice::FREQUENCY_THREE_YEARS: + // return Carbon::parse($date)->addYears(3)->startOfDay(); + // default: + // return null; + // } + // } } diff --git a/app/Services/Recurring/UpdatePrice.php b/app/Services/Recurring/UpdatePrice.php index 6b390eb71297..ddca95bd190c 100644 --- a/app/Services/Recurring/UpdatePrice.php +++ b/app/Services/Recurring/UpdatePrice.php @@ -33,7 +33,7 @@ class UpdatePrice extends AbstractService ->where('is_deleted', 0) ->first(); - if ($product) { + if ($product) { //@phpstan-ignore-line $line_items[$key]->cost = floatval($product->price); } } diff --git a/app/Services/Report/ProfitLoss.php b/app/Services/Report/ProfitLoss.php index e3b9fc4e1db6..09d392435a12 100644 --- a/app/Services/Report/ProfitLoss.php +++ b/app/Services/Report/ProfitLoss.php @@ -183,17 +183,17 @@ class ProfitLoss return $this; } - private function getForeignIncome(): array - { - return $this->foreign_income; - } + // private function getForeignIncome(): array + // { + // return $this->foreign_income; + // } - private function filterPaymentIncome() - { - $payments = $this->paymentIncome(); + // private function filterPaymentIncome() + // { + // $payments = $this->paymentIncome(); - return $this; - } + // return $this; + // } /* //returns an array of objects @@ -427,26 +427,26 @@ class ProfitLoss +"payments_converted": "12260.870000000000", +"currency_id": 1, */ - private function paymentIncome() - { - return \DB::select(' - SELECT - SUM(coalesce(payments.amount - payments.refunded,0)) as payments, - SUM(coalesce(payments.amount - payments.refunded,0)) * IFNULL(payments.exchange_rate ,1) as payments_converted, - payments.currency_id as currency_id - FROM clients - INNER JOIN - payments ON - clients.id=payments.client_id - WHERE payments.status_id IN (1,4,5,6) - AND clients.is_deleted = false - AND payments.is_deleted = false - AND payments.company_id = :company_id - AND (payments.date BETWEEN :start_date AND :end_date) - GROUP BY currency_id - ORDER BY currency_id; - ', ['company_id' => $this->company->id, 'start_date' => $this->start_date, 'end_date' => $this->end_date]); - } + // private function paymentIncome() + // { + // return \DB::select(' + // SELECT + // SUM(coalesce(payments.amount - payments.refunded,0)) as payments, + // SUM(coalesce(payments.amount - payments.refunded,0)) * IFNULL(payments.exchange_rate ,1) as payments_converted, + // payments.currency_id as currency_id + // FROM clients + // INNER JOIN + // payments ON + // clients.id=payments.client_id + // WHERE payments.status_id IN (1,4,5,6) + // AND clients.is_deleted = false + // AND payments.is_deleted = false + // AND payments.company_id = :company_id + // AND (payments.date BETWEEN :start_date AND :end_date) + // GROUP BY currency_id + // ORDER BY currency_id; + // ', ['company_id' => $this->company->id, 'start_date' => $this->start_date, 'end_date' => $this->end_date]); + // } private function expenseData() { @@ -544,18 +544,18 @@ class ProfitLoss return round(($amount * $exchange_rate), 2); } - private function expenseCalcWithTax() - { - return \DB::select(' - SELECT sum(expenses.amount) as amount, - IFNULL(expenses.currency_id, :company_currency) as currency_id - FROM expenses - WHERE expenses.is_deleted = 0 - AND expenses.company_id = :company_id - AND (expenses.date BETWEEN :start_date AND :end_date) - GROUP BY currency_id - ', ['company_currency' => $this->company->settings->currency_id, 'company_id' => $this->company->id, 'start_date' => $this->start_date, 'end_date' => $this->end_date]); - } + // private function expenseCalcWithTax() + // { + // return \DB::select(' + // SELECT sum(expenses.amount) as amount, + // IFNULL(expenses.currency_id, :company_currency) as currency_id + // FROM expenses + // WHERE expenses.is_deleted = 0 + // AND expenses.company_id = :company_id + // AND (expenses.date BETWEEN :start_date AND :end_date) + // GROUP BY currency_id + // ', ['company_currency' => $this->company->settings->currency_id, 'company_id' => $this->company->id, 'start_date' => $this->start_date, 'end_date' => $this->end_date]); + // } private function setBillingReportType() { diff --git a/app/Services/Scheduler/EmailStatementService.php b/app/Services/Scheduler/EmailStatementService.php index 84b5be63ce19..64da20836793 100644 --- a/app/Services/Scheduler/EmailStatementService.php +++ b/app/Services/Scheduler/EmailStatementService.php @@ -23,8 +23,6 @@ class EmailStatementService use MakesHash; use MakesDates; - private Client $client; - public function __construct(public Scheduler $scheduler) { } @@ -45,9 +43,6 @@ class EmailStatementService $query->cursor() ->each(function ($_client) { - /**@var \App\Models\Client $_client */ - $this->client = $_client; - //work out the date range $statement_properties = $this->calculateStatementProperties($_client); diff --git a/app/Services/Subscription/SubscriptionCalculator.php b/app/Services/Subscription/SubscriptionCalculator.php index 0179f35b6147..22b427172ff2 100644 --- a/app/Services/Subscription/SubscriptionCalculator.php +++ b/app/Services/Subscription/SubscriptionCalculator.php @@ -102,7 +102,7 @@ class SubscriptionCalculator $line_item->quantity = (float) $item['quantity']; $line_item->cost = (float) $item['product']['price']; $line_item->notes = $item['product']['notes']; - $line_item->tax_id = (string)$item['product']['tax_id'] ?? '1'; + $line_item->tax_id = (string)$item['product']['tax_id'] ?? '1'; //@phpstan-ignore-line $items[] = $line_item; } diff --git a/app/Services/Subscription/SubscriptionService.php b/app/Services/Subscription/SubscriptionService.php index 1cc177b68573..9e97aee3c990 100644 --- a/app/Services/Subscription/SubscriptionService.php +++ b/app/Services/Subscription/SubscriptionService.php @@ -145,7 +145,7 @@ class SubscriptionService /* 06-04-2022 */ /* We may not be in a state where the user is present */ - if (auth()->guard('contact')) { + if (auth()->guard('contact')->user()) { return $this->handleRedirect('/client/invoices/'.$this->encodePrimaryKey($payment_hash->fee_invoice_id)); } } @@ -200,7 +200,7 @@ class SubscriptionService $license->first_name = $contact ? $contact->first_name : ' '; $license->last_name = $contact ? $contact->last_name : ' '; $license->is_claimed = 1; - $license->transaction_reference = $payment_hash?->payment?->transaction_reference ?: ' '; + $license->transaction_reference = $payment_hash?->payment?->transaction_reference ?: ' '; //@phpstan-ignore-line $license->product_id = self::WHITE_LABEL; $license->recurring_invoice_id = $recurring_invoice->id; diff --git a/app/Services/Template/TemplateService.php b/app/Services/Template/TemplateService.php index 2a7149d6af61..a286d05bbb9b 100644 --- a/app/Services/Template/TemplateService.php +++ b/app/Services/Template/TemplateService.php @@ -1327,6 +1327,7 @@ class TemplateService { $entity_string = ''; + //@phpstan-ignore-next-line match($this->entity) { ($this->entity instanceof Invoice) => $entity_string = 'invoice', ($this->entity instanceof Quote) => $entity_string = 'quote', diff --git a/phpstan.neon b/phpstan.neon index 5066456a20bb..df2082796c5b 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -31,4 +31,10 @@ parameters: - '#Access to protected property#' - '#Call to undefined method .*#' - '#Argument of an invalid type stdClass supplied for foreach, only iterables are supported.#' - - '#Comparison operation ">=" between int<1, max> and 1 is always true#' \ No newline at end of file + - '#Comparison operation ">=" between int<1, max> and 1 is always true#' + - '#Negated boolean expression is always#' + - '#Ternary operator condition#' + - '#Expression on left side of ?? is not nullable.#' + - '#Left side of && is always true.#' + - '#Right side of && is always true.#' + \ No newline at end of file