From 25c67ff7ad7e47fba83c7946350ada76d5f0ea98 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Tue, 1 Aug 2023 20:30:47 +1000 Subject: [PATCH] Static analysis cleanup --- app/Models/BankTransaction.php | 30 +------ app/Models/BaseModel.php | 3 +- app/Models/Company.php | 1 + app/Models/CompanyToken.php | 2 +- app/Models/Invoice.php | 13 ++-- app/Models/Payment.php | 2 +- app/Models/Presenters/CompanyPresenter.php | 5 +- app/Models/Presenters/EntityPresenter.php | 4 + app/Models/Presenters/InvoicePresenter.php | 2 + .../Admin/EntitySentNotification.php | 2 +- .../Admin/EntityViewedNotification.php | 46 +++++------ .../Admin/NewPaymentNotification.php | 2 +- .../ClientContactRequestCancellation.php | 2 +- .../ClientContactResetPassword.php | 2 +- app/Notifications/NewAccountCreated.php | 2 +- .../Ninja/ClientAccountNotFound.php | 2 +- .../Ninja/DomainFailureNotification.php | 2 +- .../DomainRenewalFailureNotification.php | 2 +- .../Ninja/EmailBounceNotification.php | 2 +- .../Ninja/EmailQuotaNotification.php | 2 +- .../Ninja/GmailCredentialNotification.php | 2 +- app/Notifications/Ninja/NewAccountCreated.php | 2 +- .../Ninja/NewAccountNotification.php | 2 +- .../Ninja/RenewalFailureNotification.php | 2 +- app/Notifications/Ninja/SpamNotification.php | 2 +- .../Ninja/UserQualityNotification.php | 2 +- app/Notifications/Ninja/VerifyUser.php | 78 ------------------- .../Ninja/WePayFailureNotification.php | 2 +- .../ResetPasswordNotification.php | 2 +- 29 files changed, 65 insertions(+), 157 deletions(-) delete mode 100644 app/Notifications/Ninja/VerifyUser.php diff --git a/app/Models/BankTransaction.php b/app/Models/BankTransaction.php index c702c8428c..ed030f0a13 100644 --- a/app/Models/BankTransaction.php +++ b/app/Models/BankTransaction.php @@ -59,33 +59,7 @@ use Illuminate\Database\Eloquent\SoftDeletes; * @method static \Illuminate\Database\Eloquent\Builder|BankTransaction onlyTrashed() * @method static \Illuminate\Database\Eloquent\Builder|BankTransaction query() * @method static \Illuminate\Database\Eloquent\Builder|BaseModel scope() - * @method static \Illuminate\Database\Eloquent\Builder|BankTransaction whereAccountType($value) - * @method static \Illuminate\Database\Eloquent\Builder|BankTransaction whereAmount($value) - * @method static \Illuminate\Database\Eloquent\Builder|BankTransaction whereBankAccountId($value) - * @method static \Illuminate\Database\Eloquent\Builder|BankTransaction whereBankIntegrationId($value) - * @method static \Illuminate\Database\Eloquent\Builder|BankTransaction whereBankTransactionRuleId($value) - * @method static \Illuminate\Database\Eloquent\Builder|BankTransaction whereBaseType($value) - * @method static \Illuminate\Database\Eloquent\Builder|BankTransaction whereCategoryId($value) - * @method static \Illuminate\Database\Eloquent\Builder|BankTransaction whereCategoryType($value) - * @method static \Illuminate\Database\Eloquent\Builder|BankTransaction whereCompanyId($value) - * @method static \Illuminate\Database\Eloquent\Builder|BankTransaction whereCreatedAt($value) - * @method static \Illuminate\Database\Eloquent\Builder|BankTransaction whereCurrencyCode($value) - * @method static \Illuminate\Database\Eloquent\Builder|BankTransaction whereCurrencyId($value) - * @method static \Illuminate\Database\Eloquent\Builder|BankTransaction whereDate($value) - * @method static \Illuminate\Database\Eloquent\Builder|BankTransaction whereDeletedAt($value) - * @method static \Illuminate\Database\Eloquent\Builder|BankTransaction whereDescription($value) - * @method static \Illuminate\Database\Eloquent\Builder|BankTransaction whereExpenseId($value) - * @method static \Illuminate\Database\Eloquent\Builder|BankTransaction whereId($value) - * @method static \Illuminate\Database\Eloquent\Builder|BankTransaction whereInvoiceIds($value) - * @method static \Illuminate\Database\Eloquent\Builder|BankTransaction whereIsDeleted($value) - * @method static \Illuminate\Database\Eloquent\Builder|BankTransaction whereNinjaCategoryId($value) - * @method static \Illuminate\Database\Eloquent\Builder|BankTransaction wherePaymentId($value) - * @method static \Illuminate\Database\Eloquent\Builder|BankTransaction whereStatusId($value) - * @method static \Illuminate\Database\Eloquent\Builder|BankTransaction whereTransactionId($value) - * @method static \Illuminate\Database\Eloquent\Builder|BankTransaction whereUpdatedAt($value) - * @method static \Illuminate\Database\Eloquent\Builder|BankTransaction whereUserId($value) - * @method static \Illuminate\Database\Eloquent\Builder|BankTransaction whereVendorId($value) - * @method static \Illuminate\Database\Eloquent\Builder|BankTransaction withTrashed() + * @method static \Illuminate\Database\Eloquent\Account withTrashed() * @method static \Illuminate\Database\Eloquent\Builder|BankTransaction withoutTrashed() * @property-read \App\Models\Payment|null $payment * @mixin \Eloquent @@ -176,7 +150,7 @@ class BankTransaction extends BaseModel return $this->belongsTo(BankIntegration::class)->withTrashed(); } - public function account() + public function account(): \Illuminate\Database\Eloquent\Relations\BelongsTo { return $this->belongsTo(Account::class)->withTrashed(); } diff --git a/app/Models/BaseModel.php b/app/Models/BaseModel.php index 62bcabefa8..cbafe0ab96 100644 --- a/app/Models/BaseModel.php +++ b/app/Models/BaseModel.php @@ -41,7 +41,7 @@ use Illuminate\Database\Eloquent\ModelNotFoundException as ModelNotFoundExceptio * @method static \Illuminate\Database\Eloquent\Builder|BaseModel newQuery($query) * @method static \Illuminate\Database\Eloquent\Builder|BaseModel query() * @method static \Illuminate\Database\Eloquent\Builder|BaseModel exclude(array $excludeable) - * @method static \Illuminate\Database\Eloquent\Builder|BaseModel withTrashed() + * @method static \Illuminate\Database\Eloquent\BaseModel withTrashed() * @method static \Illuminate\Database\Eloquent\Builder|BaseModel scopeExclude($query) * @method static \Illuminate\Database\Eloquent\Builder|BaseModel find($value) * @method static \Illuminate\Database\Eloquent\Builder|BaseModel whereIn($query) @@ -52,7 +52,6 @@ use Illuminate\Database\Eloquent\ModelNotFoundException as ModelNotFoundExceptio * @method static \Illuminate\Database\Eloquent\Builder|BaseModel service() * @method static \Illuminate\Database\Eloquent\Builder|BaseModel orderBy($column, $direction) * @method static \Illuminate\Database\Eloquent\Builder|BaseModel invitations() - * @method static \Illuminate\Database\Eloquent\Builder|BaseModel createInvitations() * @method static \Illuminate\Database\Eloquent\Builder|BaseModel whereHas($query) * @property-read \Illuminate\Database\Eloquent\Collection $invitations * @property-read int|null $invitations_count diff --git a/app/Models/Company.php b/app/Models/Company.php index d8c0c9172a..11de4e8b9f 100644 --- a/app/Models/Company.php +++ b/app/Models/Company.php @@ -237,6 +237,7 @@ class Company extends BaseModel // const ENTITY_RECURRING_QUOTE = 'recurring_quote'; + /** @var CompanyPresenter */ protected $presenter = CompanyPresenter::class; protected array $tax_coverage_countries = [ diff --git a/app/Models/CompanyToken.php b/app/Models/CompanyToken.php index 9366310cb7..f37bf10e3e 100644 --- a/app/Models/CompanyToken.php +++ b/app/Models/CompanyToken.php @@ -76,7 +76,7 @@ class CompanyToken extends BaseModel return $this->belongsTo(User::class); } - public function company() + public function company(): \Illuminate\Database\Eloquent\Relations\BelongsTo { return $this->belongsTo(Company::class); } diff --git a/app/Models/Invoice.php b/app/Models/Invoice.php index 57660005f6..0c917d93a1 100644 --- a/app/Models/Invoice.php +++ b/app/Models/Invoice.php @@ -71,10 +71,10 @@ use App\Events\Invoice\InvoiceReminderWasEmailed; * @property string|null $custom_value3 * @property string|null $custom_value4 * @property string|null $next_send_date - * @property string|null $custom_surcharge1 - * @property string|null $custom_surcharge2 - * @property string|null $custom_surcharge3 - * @property string|null $custom_surcharge4 + * @property float|null $custom_surcharge1 + * @property float|null $custom_surcharge2 + * @property float|null $custom_surcharge3 + * @property float|null $custom_surcharge4 * @property bool $custom_surcharge_tax1 * @property bool $custom_surcharge_tax2 * @property bool $custom_surcharge_tax3 @@ -155,7 +155,7 @@ class Invoice extends BaseModel use MakesReminders; use ActionsInvoice; - protected $presenter = InvoicePresenter::class; + // protected $presenter = InvoicePresenter::class; protected $touches = []; @@ -720,6 +720,8 @@ class Invoice extends BaseModel public function taxTypeString($id) { + $tax_type = false; + match(intval($id)){ Product::PRODUCT_TYPE_PHYSICAL => $tax_type = ctrans('texts.physical_goods'), Product::PRODUCT_TYPE_SERVICE => $tax_type = ctrans('texts.services'), @@ -738,6 +740,7 @@ class Invoice extends BaseModel public function typeIdString($id) { + $type = ''; match($id) { '1' => $type = ctrans('texts.product'), '2' => $type = ctrans('texts.service'), diff --git a/app/Models/Payment.php b/app/Models/Payment.php index cbcbc1171f..d2922d0365 100644 --- a/app/Models/Payment.php +++ b/app/Models/Payment.php @@ -252,7 +252,7 @@ class Payment extends BaseModel return $this->belongsTo(Currency::class); } - public function transaction(): BelongsTo + public function transaction() { return $this->belongsTo(BankTransaction::class); } diff --git a/app/Models/Presenters/CompanyPresenter.php b/app/Models/Presenters/CompanyPresenter.php index c836091dc4..8de23d31ce 100644 --- a/app/Models/Presenters/CompanyPresenter.php +++ b/app/Models/Presenters/CompanyPresenter.php @@ -17,13 +17,16 @@ use Illuminate\Support\Str; /** * Class CompanyPresenter. + * @property \App\DataMapper\CompanySettings $settings */ class CompanyPresenter extends EntityPresenter { + + /** * @return string */ - public function name() + public function name(): string { return $this->settings->name ?: ctrans('texts.untitled_account'); } diff --git a/app/Models/Presenters/EntityPresenter.php b/app/Models/Presenters/EntityPresenter.php index ccfe0ca364..01cfbc3063 100644 --- a/app/Models/Presenters/EntityPresenter.php +++ b/app/Models/Presenters/EntityPresenter.php @@ -16,6 +16,10 @@ use Laracasts\Presenter\Presenter; /** * Class EntityPresenter. + * + * @property \App\Models\Company | \App\Models\Client | \App\Models\ClientContact | \App\Models\Vendor | \App\Models\VendorContact $entity + * @property \App\Models\Client $client + * @property \App\Models\Company $company */ class EntityPresenter extends Presenter { diff --git a/app/Models/Presenters/InvoicePresenter.php b/app/Models/Presenters/InvoicePresenter.php index a7ce9222e3..d2d806f976 100644 --- a/app/Models/Presenters/InvoicePresenter.php +++ b/app/Models/Presenters/InvoicePresenter.php @@ -23,6 +23,8 @@ use App\Utils\Traits\MakesDates; * * Shortcuts to other presenters are here to facilitate * a clean UI / UX + * + * @property \App\Models\Invoice $entity */ class InvoicePresenter extends EntityPresenter { diff --git a/app/Notifications/Admin/EntitySentNotification.php b/app/Notifications/Admin/EntitySentNotification.php index 11b40dbb86..5033d813d1 100644 --- a/app/Notifications/Admin/EntitySentNotification.php +++ b/app/Notifications/Admin/EntitySentNotification.php @@ -67,7 +67,7 @@ class EntitySentNotification extends Notification * Get the mail representation of the notification. * * @param mixed $notifiable - * @return MailMessage + * */ public function toMail($notifiable) { diff --git a/app/Notifications/Admin/EntityViewedNotification.php b/app/Notifications/Admin/EntityViewedNotification.php index 8014aa9045..69f7b7e003 100644 --- a/app/Notifications/Admin/EntityViewedNotification.php +++ b/app/Notifications/Admin/EntityViewedNotification.php @@ -67,7 +67,7 @@ class EntityViewedNotification extends Notification * Get the mail representation of the notification. * * @param mixed $notifiable - * @return MailMessage + * */ public function toMail($notifiable) { @@ -103,7 +103,7 @@ class EntityViewedNotification extends Notification $this->entity_name => $this->entity->number, ] )) - ->attachment(function ($attachment) use ($amount) { + ->attachment(function ($attachment) { $attachment->title(ctrans('texts.entity_number_placeholder', ['entity' => ucfirst($this->entity_name), 'entity_number' => $this->entity->number]), $this->invitation->getAdminLink()) ->fields([ ctrans('texts.client') => $this->contact->present()->name(), @@ -112,30 +112,30 @@ class EntityViewedNotification extends Notification }); } - private function buildDataArray() - { - $amount = Number::formatMoney($this->entity->amount, $this->entity->client); + // private function buildDataArray() + // { + // $amount = Number::formatMoney($this->entity->amount, $this->entity->client); - $data = [ - 'title' => $this->buildSubject(), - 'message' => ctrans( - "texts.notification_{$this->entity_name}_viewed", - [ - 'amount' => $amount, - 'client' => $this->contact->present()->name(), - $this->entity_name => $this->entity->number, - ] - ), - 'url' => $this->invitation->getAdminLink(), - 'button' => ctrans("texts.view_{$this->entity_name}"), - 'signature' => $this->settings->email_signature, - 'logo' => $this->company->present()->logo(), - 'settings' => $this->settings, + // $data = [ + // 'title' => $this->buildSubject(), + // 'message' => ctrans( + // "texts.notification_{$this->entity_name}_viewed", + // [ + // 'amount' => $amount, + // 'client' => $this->contact->present()->name(), + // $this->entity_name => $this->entity->number, + // ] + // ), + // 'url' => $this->invitation->getAdminLink(), + // 'button' => ctrans("texts.view_{$this->entity_name}"), + // 'signature' => $this->settings->email_signature, + // 'logo' => $this->company->present()->logo(), + // 'settings' => $this->settings, - ]; + // ]; - return $data; - } + // return $data; + // } private function buildSubject() { diff --git a/app/Notifications/Admin/NewPaymentNotification.php b/app/Notifications/Admin/NewPaymentNotification.php index 082f70b7fe..70694ccc0d 100644 --- a/app/Notifications/Admin/NewPaymentNotification.php +++ b/app/Notifications/Admin/NewPaymentNotification.php @@ -57,7 +57,7 @@ class NewPaymentNotification extends Notification * Get the mail representation of the notification. * * @param mixed $notifiable - * @return MailMessage + * */ public function toMail($notifiable) { diff --git a/app/Notifications/ClientContactRequestCancellation.php b/app/Notifications/ClientContactRequestCancellation.php index 69ea4b2ef5..618dee1890 100644 --- a/app/Notifications/ClientContactRequestCancellation.php +++ b/app/Notifications/ClientContactRequestCancellation.php @@ -63,7 +63,7 @@ class ClientContactRequestCancellation extends Notification * Get the mail representation of the notification. * * @param mixed $notifiable - * @return MailMessage + * */ public function toMail($notifiable) { diff --git a/app/Notifications/ClientContactResetPassword.php b/app/Notifications/ClientContactResetPassword.php index 01f549980a..2ba6593fb3 100644 --- a/app/Notifications/ClientContactResetPassword.php +++ b/app/Notifications/ClientContactResetPassword.php @@ -63,7 +63,7 @@ class ClientContactResetPassword extends Notification * Build the mail representation of the notification. * * @param mixed $notifiable - * @return MailMessage + * */ public function toMail($notifiable) { diff --git a/app/Notifications/NewAccountCreated.php b/app/Notifications/NewAccountCreated.php index 997b8ab0e5..845aecad8c 100644 --- a/app/Notifications/NewAccountCreated.php +++ b/app/Notifications/NewAccountCreated.php @@ -57,7 +57,7 @@ class NewAccountCreated extends Notification * Get the mail representation of the notification. * * @param mixed $notifiable - * @return MailMessage + * */ public function toMail($notifiable) { diff --git a/app/Notifications/Ninja/ClientAccountNotFound.php b/app/Notifications/Ninja/ClientAccountNotFound.php index d913d9c4f0..84087991f6 100644 --- a/app/Notifications/Ninja/ClientAccountNotFound.php +++ b/app/Notifications/Ninja/ClientAccountNotFound.php @@ -42,7 +42,7 @@ class ClientAccountNotFound extends Notification * Get the mail representation of the notification. * * @param mixed $notifiable - * @return MailMessage + * */ public function toMail($notifiable) { diff --git a/app/Notifications/Ninja/DomainFailureNotification.php b/app/Notifications/Ninja/DomainFailureNotification.php index f22f089265..2e4dc99059 100644 --- a/app/Notifications/Ninja/DomainFailureNotification.php +++ b/app/Notifications/Ninja/DomainFailureNotification.php @@ -45,7 +45,7 @@ class DomainFailureNotification extends Notification * Get the mail representation of the notification. * * @param mixed $notifiable - * @return MailMessage + * */ public function toMail($notifiable) { diff --git a/app/Notifications/Ninja/DomainRenewalFailureNotification.php b/app/Notifications/Ninja/DomainRenewalFailureNotification.php index 860c6ae8b6..719a93d5e1 100644 --- a/app/Notifications/Ninja/DomainRenewalFailureNotification.php +++ b/app/Notifications/Ninja/DomainRenewalFailureNotification.php @@ -45,7 +45,7 @@ class DomainRenewalFailureNotification extends Notification * Get the mail representation of the notification. * * @param mixed $notifiable - * @return MailMessage + * */ public function toMail($notifiable) { diff --git a/app/Notifications/Ninja/EmailBounceNotification.php b/app/Notifications/Ninja/EmailBounceNotification.php index 9af33db980..796a1f6368 100644 --- a/app/Notifications/Ninja/EmailBounceNotification.php +++ b/app/Notifications/Ninja/EmailBounceNotification.php @@ -44,7 +44,7 @@ class EmailBounceNotification extends Notification * Get the mail representation of the notification. * * @param mixed $notifiable - * @return MailMessage + * */ public function toMail($notifiable) { diff --git a/app/Notifications/Ninja/EmailQuotaNotification.php b/app/Notifications/Ninja/EmailQuotaNotification.php index 24eab8d216..8ef6cbf6ac 100644 --- a/app/Notifications/Ninja/EmailQuotaNotification.php +++ b/app/Notifications/Ninja/EmailQuotaNotification.php @@ -44,7 +44,7 @@ class EmailQuotaNotification extends Notification * Get the mail representation of the notification. * * @param mixed $notifiable - * @return MailMessage + * */ public function toMail($notifiable) { diff --git a/app/Notifications/Ninja/GmailCredentialNotification.php b/app/Notifications/Ninja/GmailCredentialNotification.php index df9aee792f..0bc8226e1e 100644 --- a/app/Notifications/Ninja/GmailCredentialNotification.php +++ b/app/Notifications/Ninja/GmailCredentialNotification.php @@ -44,7 +44,7 @@ class GmailCredentialNotification extends Notification * Get the mail representation of the notification. * * @param mixed $notifiable - * @return MailMessage + * */ public function toMail($notifiable) { diff --git a/app/Notifications/Ninja/NewAccountCreated.php b/app/Notifications/Ninja/NewAccountCreated.php index f0e47d8cbd..77d570caa4 100644 --- a/app/Notifications/Ninja/NewAccountCreated.php +++ b/app/Notifications/Ninja/NewAccountCreated.php @@ -57,7 +57,7 @@ class NewAccountCreated extends Notification * Get the mail representation of the notification. * * @param mixed $notifiable - * @return MailMessage + * */ public function toMail($notifiable) { diff --git a/app/Notifications/Ninja/NewAccountNotification.php b/app/Notifications/Ninja/NewAccountNotification.php index 6c32ef5824..2b21589768 100644 --- a/app/Notifications/Ninja/NewAccountNotification.php +++ b/app/Notifications/Ninja/NewAccountNotification.php @@ -50,7 +50,7 @@ class NewAccountNotification extends Notification * Get the mail representation of the notification. * * @param mixed $notifiable - * @return MailMessage + * */ public function toMail($notifiable) { diff --git a/app/Notifications/Ninja/RenewalFailureNotification.php b/app/Notifications/Ninja/RenewalFailureNotification.php index 34a5942feb..6d9adfc865 100644 --- a/app/Notifications/Ninja/RenewalFailureNotification.php +++ b/app/Notifications/Ninja/RenewalFailureNotification.php @@ -42,7 +42,7 @@ class RenewalFailureNotification extends Notification * Get the mail representation of the notification. * * @param mixed $notifiable - * @return MailMessage + * */ public function toMail($notifiable) { diff --git a/app/Notifications/Ninja/SpamNotification.php b/app/Notifications/Ninja/SpamNotification.php index 27569488cd..d81e790971 100644 --- a/app/Notifications/Ninja/SpamNotification.php +++ b/app/Notifications/Ninja/SpamNotification.php @@ -45,7 +45,7 @@ class SpamNotification extends Notification * Get the mail representation of the notification. * * @param mixed $notifiable - * @return MailMessage + * */ public function toMail($notifiable) { diff --git a/app/Notifications/Ninja/UserQualityNotification.php b/app/Notifications/Ninja/UserQualityNotification.php index 385f1c0ca9..4e1780665e 100644 --- a/app/Notifications/Ninja/UserQualityNotification.php +++ b/app/Notifications/Ninja/UserQualityNotification.php @@ -49,7 +49,7 @@ class UserQualityNotification extends Notification * Get the mail representation of the notification. * * @param mixed $notifiable - * @return MailMessage + * */ public function toMail($notifiable) { diff --git a/app/Notifications/Ninja/VerifyUser.php b/app/Notifications/Ninja/VerifyUser.php deleted file mode 100644 index c1311fba5d..0000000000 --- a/app/Notifications/Ninja/VerifyUser.php +++ /dev/null @@ -1,78 +0,0 @@ -user = $user; - $this->company = $company; - } - - /** - * Get the notification's delivery channels. - * - * @param mixed $notifiable - * @return array - */ - public function via($notifiable) - { - return ['']; - } - - /** - * Get the mail representation of the notification. - * - * @param mixed $notifiable - * @return MailMessage - */ - public function toMail($notifiable) - { - } - - /** - * Get the array representation of the notification. - * - * @param mixed $notifiable - * @return array - */ - public function toArray($notifiable) - { - return [ - // - ]; - } - - public function toSlack($notifiable) - { - } -} diff --git a/app/Notifications/Ninja/WePayFailureNotification.php b/app/Notifications/Ninja/WePayFailureNotification.php index 1cbf759d5a..e11e321c46 100644 --- a/app/Notifications/Ninja/WePayFailureNotification.php +++ b/app/Notifications/Ninja/WePayFailureNotification.php @@ -44,7 +44,7 @@ class WePayFailureNotification extends Notification * Get the mail representation of the notification. * * @param mixed $notifiable - * @return MailMessage + * */ public function toMail($notifiable) { diff --git a/app/Notifications/ResetPasswordNotification.php b/app/Notifications/ResetPasswordNotification.php index 34b7f4ad69..f3fc5497d4 100644 --- a/app/Notifications/ResetPasswordNotification.php +++ b/app/Notifications/ResetPasswordNotification.php @@ -38,7 +38,7 @@ class ResetPasswordNotification extends Notification * Get the mail representation of the notification. * * @param mixed $notifiable - * @return MailMessage + * */ public function toMail($notifiable) {