From 908161eae76d52bd89e001760519a86d0a71b703 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Tue, 1 Aug 2023 22:36:04 +1000 Subject: [PATCH] Static analysis cleanup --- app/Export/CSV/BaseExport.php | 3 -- .../Requests/Payment/RefundPaymentRequest.php | 4 +- .../ValidRefundableInvoices.php | 2 +- app/Models/Activity.php | 32 +--------------- app/Models/BankIntegration.php | 38 ++----------------- app/Models/BaseModel.php | 4 +- app/Models/CompanyGateway.php | 35 ++++++++--------- app/Models/CompanyToken.php | 6 +-- app/Models/Invoice.php | 2 +- phpstan.neon | 3 +- 10 files changed, 34 insertions(+), 95 deletions(-) diff --git a/app/Export/CSV/BaseExport.php b/app/Export/CSV/BaseExport.php index 4650b990f7..cbaab0aa2d 100644 --- a/app/Export/CSV/BaseExport.php +++ b/app/Export/CSV/BaseExport.php @@ -623,9 +623,6 @@ class BaseExport } elseif ($transformed_invoice && array_key_exists(str_replace("invoice.", "", $column), $transformed_invoice)) { return $transformed_invoice[$column]; } - - // if($column == 'status') - // return $entity->stringStatus($entity->status_id); return ''; } diff --git a/app/Http/Requests/Payment/RefundPaymentRequest.php b/app/Http/Requests/Payment/RefundPaymentRequest.php index 2371405290..67ad4a7f7a 100644 --- a/app/Http/Requests/Payment/RefundPaymentRequest.php +++ b/app/Http/Requests/Payment/RefundPaymentRequest.php @@ -28,7 +28,9 @@ class RefundPaymentRequest extends Request */ public function authorize() : bool { - return auth()->user()->isAdmin(); + /** @var \App\Models\User $user */ + $user = auth()->user(); + return $user->isAdmin(); } public function prepareForValidation() diff --git a/app/Http/ValidationRules/ValidRefundableInvoices.php b/app/Http/ValidationRules/ValidRefundableInvoices.php index d14b378446..3c10bf71a9 100644 --- a/app/Http/ValidationRules/ValidRefundableInvoices.php +++ b/app/Http/ValidationRules/ValidRefundableInvoices.php @@ -45,6 +45,7 @@ class ValidRefundableInvoices implements Rule return false; } + /**@var \App\Models\Payment $payment */ $payment = Payment::whereId($this->input['id'])->first(); if (! $payment) { @@ -71,7 +72,6 @@ class ValidRefundableInvoices implements Rule foreach ($this->input['invoices'] as $val) { if ($val['invoice_id'] == $invoice->id) { - //$pivot_record = $invoice->payments->where('id', $invoice->id)->first(); $pivot_record = $payment->paymentables->where('paymentable_id', $invoice->id)->first(); if ($val['amount'] > ($pivot_record->amount - $pivot_record->refunded)) { diff --git a/app/Models/Activity.php b/app/Models/Activity.php index 17cfcb872d..84d9bbda5e 100644 --- a/app/Models/Activity.php +++ b/app/Models/Activity.php @@ -67,37 +67,7 @@ use Illuminate\Database\Eloquent\Relations\BelongsTo; * @property-read \App\Models\VendorContact|null $vendor_contact * @method static \Illuminate\Database\Eloquent\Builder|StaticModel company() * @method static \Illuminate\Database\Eloquent\Builder|StaticModel exclude($columns) - * @method static \Illuminate\Database\Eloquent\Builder|Activity newModelQuery() - * @method static \Illuminate\Database\Eloquent\Builder|Activity newQuery() - * @method static \Illuminate\Database\Eloquent\Builder|Activity query() - * @method static \Illuminate\Database\Eloquent\Builder|Activity whereAccountId($value) - * @method static \Illuminate\Database\Eloquent\Builder|Activity whereActivityTypeId($value) - * @method static \Illuminate\Database\Eloquent\Builder|Activity whereClientContactId($value) - * @method static \Illuminate\Database\Eloquent\Builder|Activity whereClientId($value) - * @method static \Illuminate\Database\Eloquent\Builder|Activity whereCompanyId($value) - * @method static \Illuminate\Database\Eloquent\Builder|Activity whereCreatedAt($value) - * @method static \Illuminate\Database\Eloquent\Builder|Activity whereCreditId($value) - * @method static \Illuminate\Database\Eloquent\Builder|Activity whereExpenseId($value) - * @method static \Illuminate\Database\Eloquent\Builder|Activity whereId($value) - * @method static \Illuminate\Database\Eloquent\Builder|Activity whereInvitationId($value) - * @method static \Illuminate\Database\Eloquent\Builder|Activity whereInvoiceId($value) - * @method static \Illuminate\Database\Eloquent\Builder|Activity whereIp($value) - * @method static \Illuminate\Database\Eloquent\Builder|Activity whereIsSystem($value) - * @method static \Illuminate\Database\Eloquent\Builder|Activity whereNotes($value) - * @method static \Illuminate\Database\Eloquent\Builder|Activity wherePaymentId($value) - * @method static \Illuminate\Database\Eloquent\Builder|Activity whereProjectId($value) - * @method static \Illuminate\Database\Eloquent\Builder|Activity wherePurchaseOrderId($value) - * @method static \Illuminate\Database\Eloquent\Builder|Activity whereQuoteId($value) - * @method static \Illuminate\Database\Eloquent\Builder|Activity whereRecurringExpenseId($value) - * @method static \Illuminate\Database\Eloquent\Builder|Activity whereRecurringInvoiceId($value) - * @method static \Illuminate\Database\Eloquent\Builder|Activity whereRecurringQuoteId($value) - * @method static \Illuminate\Database\Eloquent\Builder|Activity whereSubscriptionId($value) - * @method static \Illuminate\Database\Eloquent\Builder|Activity whereTaskId($value) - * @method static \Illuminate\Database\Eloquent\Builder|Activity whereTokenId($value) - * @method static \Illuminate\Database\Eloquent\Builder|Activity whereUpdatedAt($value) - * @method static \Illuminate\Database\Eloquent\Builder|Activity whereUserId($value) - * @method static \Illuminate\Database\Eloquent\Builder|Activity whereVendorContactId($value) - * @method static \Illuminate\Database\Eloquent\Builder|Activity whereVendorId($value) + * @mixin \Eloquent */ class Activity extends StaticModel diff --git a/app/Models/BankIntegration.php b/app/Models/BankIntegration.php index 17ac1eec48..c701831b16 100644 --- a/app/Models/BankIntegration.php +++ b/app/Models/BankIntegration.php @@ -27,11 +27,11 @@ use Illuminate\Database\Eloquent\SoftDeletes; * @property string|null $bank_account_number * @property string|null $bank_account_status * @property string|null $bank_account_type - * @property string $balance - * @property string|null $currency + * @property float $balance + * @property int|null $currency * @property string $nickname * @property string|null $from_date - * @property int $is_deleted + * @property bool $is_deleted * @property int|null $created_at * @property int|null $updated_at * @property int|null $deleted_at @@ -52,41 +52,9 @@ use Illuminate\Database\Eloquent\SoftDeletes; * @method static \Illuminate\Database\Eloquent\Builder|BankIntegration onlyTrashed() * @method static \Illuminate\Database\Eloquent\Builder|BankIntegration query() * @method static \Illuminate\Database\Eloquent\Builder|BaseModel scope() - * @method static \Illuminate\Database\Eloquent\Builder|BankIntegration whereAccountId($value) - * @method static \Illuminate\Database\Eloquent\Builder|BankIntegration whereAutoSync($value) - * @method static \Illuminate\Database\Eloquent\Builder|BankIntegration whereBalance($value) - * @method static \Illuminate\Database\Eloquent\Builder|BankIntegration whereBankAccountId($value) - * @method static \Illuminate\Database\Eloquent\Builder|BankIntegration whereBankAccountName($value) - * @method static \Illuminate\Database\Eloquent\Builder|BankIntegration whereBankAccountNumber($value) - * @method static \Illuminate\Database\Eloquent\Builder|BankIntegration whereBankAccountStatus($value) - * @method static \Illuminate\Database\Eloquent\Builder|BankIntegration whereBankAccountType($value) - * @method static \Illuminate\Database\Eloquent\Builder|BankIntegration whereCompanyId($value) - * @method static \Illuminate\Database\Eloquent\Builder|BankIntegration whereCreatedAt($value) - * @method static \Illuminate\Database\Eloquent\Builder|BankIntegration whereCurrency($value) - * @method static \Illuminate\Database\Eloquent\Builder|BankIntegration whereDeletedAt($value) - * @method static \Illuminate\Database\Eloquent\Builder|BankIntegration whereDisabledUpstream($value) - * @method static \Illuminate\Database\Eloquent\Builder|BankIntegration whereFromDate($value) - * @method static \Illuminate\Database\Eloquent\Builder|BankIntegration whereId($value) - * @method static \Illuminate\Database\Eloquent\Builder|BankIntegration whereIsDeleted($value) - * @method static \Illuminate\Database\Eloquent\Builder|BankIntegration whereNickname($value) - * @method static \Illuminate\Database\Eloquent\Builder|BankIntegration whereProviderId($value) - * @method static \Illuminate\Database\Eloquent\Builder|BankIntegration whereProviderName($value) - * @method static \Illuminate\Database\Eloquent\Builder|BankIntegration whereUpdatedAt($value) - * @method static \Illuminate\Database\Eloquent\Builder|BankIntegration whereUserId($value) * @method static \Illuminate\Database\Eloquent\Builder|BankIntegration withTrashed() * @method static \Illuminate\Database\Eloquent\Builder|BankIntegration withoutTrashed() * @property-read \Illuminate\Database\Eloquent\Collection $transactions - * @property-read \Illuminate\Database\Eloquent\Collection $transactions - * @property-read \Illuminate\Database\Eloquent\Collection $transactions - * @property-read \Illuminate\Database\Eloquent\Collection $transactions - * @property-read \Illuminate\Database\Eloquent\Collection $transactions - * @property-read \Illuminate\Database\Eloquent\Collection $transactions - * @property-read \Illuminate\Database\Eloquent\Collection $transactions - * @property-read \Illuminate\Database\Eloquent\Collection $transactions - * @property-read \Illuminate\Database\Eloquent\Collection $transactions - * @property-read \Illuminate\Database\Eloquent\Collection $transactions - * @property-read \Illuminate\Database\Eloquent\Collection $transactions - * @property-read \Illuminate\Database\Eloquent\Collection $transactions * @mixin \Eloquent */ class BankIntegration extends BaseModel diff --git a/app/Models/BaseModel.php b/app/Models/BaseModel.php index cbafe0ab96..74c483a522 100644 --- a/app/Models/BaseModel.php +++ b/app/Models/BaseModel.php @@ -41,9 +41,9 @@ 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\BaseModel withTrashed() + * @method static \Illuminate\Database\Eloquent\Builder withTrashed() * @method static \Illuminate\Database\Eloquent\Builder|BaseModel scopeExclude($query) - * @method static \Illuminate\Database\Eloquent\Builder|BaseModel find($value) + * @method static BaseModel find($value) * @method static \Illuminate\Database\Eloquent\Builder|BaseModel whereIn($query) * @method static \Illuminate\Database\Eloquent\Builder|BaseModel where($query) * @method static \Illuminate\Database\Eloquent\Builder|BaseModel count() diff --git a/app/Models/CompanyGateway.php b/app/Models/CompanyGateway.php index 79d5b13379..fd5a1dce00 100644 --- a/app/Models/CompanyGateway.php +++ b/app/Models/CompanyGateway.php @@ -21,14 +21,15 @@ use Illuminate\Database\Eloquent\SoftDeletes; * @property int $company_id * @property int $user_id * @property string $gateway_key - * @property int $accepted_credit_cards - * @property int $require_cvv - * @property int|null $require_billing_address - * @property int|null $require_shipping_address - * @property int|null $update_details - * @property int $is_deleted + * @property bool $accepted_credit_cards + * @property bool $require_cvv + * @property bool $require_billing_address + * @property bool $require_shipping_address + * @property bool $update_details + * @property bool $is_deleted * @property string $config - * @property object $fees_and_limits + * @property mixed $fees_and_limits + * @property-write mixed $fees_and_limits * @property string|null $custom_value1 * @property string|null $custom_value2 * @property string|null $custom_value3 @@ -38,15 +39,15 @@ use Illuminate\Database\Eloquent\SoftDeletes; * @property int|null $deleted_at * @property string $token_billing * @property string|null $label - * @property int $require_client_name - * @property int $require_postal_code - * @property int $require_client_phone - * @property int $require_contact_name - * @property int $require_contact_email - * @property int $require_custom_value1 - * @property int $require_custom_value2 - * @property int $require_custom_value3 - * @property int $require_custom_value4 + * @property bool $require_client_name + * @property bool $require_postal_code + * @property bool $require_client_phone + * @property bool $require_contact_name + * @property bool $require_contact_email + * @property bool $require_custom_value1 + * @property bool $require_custom_value2 + * @property bool $require_custom_value3 + * @property bool $require_custom_value4 * @property-read int|null $client_gateway_tokens_count * @property-read \App\Models\Company $company * @property-read \App\Models\Gateway $gateway @@ -61,7 +62,7 @@ use Illuminate\Database\Eloquent\SoftDeletes; * @method static \Illuminate\Database\Eloquent\Builder|BaseModel scope() * @method static \Illuminate\Database\Eloquent\Builder|CompanyGateway withTrashed() * @method static \Illuminate\Database\Eloquent\Builder|CompanyGateway withoutTrashed() - * @method static \Illuminate\Database\Eloquent\Builder|CompanyGateway find() + * @method static CompanyGateway find() * @property-read \Illuminate\Database\Eloquent\Collection $client_gateway_tokens * @mixin \Eloquent */ diff --git a/app/Models/CompanyToken.php b/app/Models/CompanyToken.php index f37bf10e3e..dff64d9902 100644 --- a/app/Models/CompanyToken.php +++ b/app/Models/CompanyToken.php @@ -66,12 +66,12 @@ class CompanyToken extends BaseModel return self::class; } - public function account() + public function account(): \Illuminate\Database\Eloquent\Relations\BelongsTo { return $this->belongsTo(Account::class); } - public function user() + public function user(): \Illuminate\Database\Eloquent\Relations\BelongsTo { return $this->belongsTo(User::class); } @@ -81,7 +81,7 @@ class CompanyToken extends BaseModel return $this->belongsTo(Company::class); } - public function company_user() + public function company_user(): \Illuminate\Database\Eloquent\Relations\HasOne { return $this->hasOne(CompanyUser::class, 'user_id', 'user_id') ->where('company_id', $this->company_id) diff --git a/app/Models/Invoice.php b/app/Models/Invoice.php index 1a9088c272..e7ff74fdc9 100644 --- a/app/Models/Invoice.php +++ b/app/Models/Invoice.php @@ -122,7 +122,7 @@ use App\Events\Invoice\InvoiceReminderWasEmailed; * @property-read int|null $tasks_count * @property-read \App\Models\User $user * @property-read \App\Models\Vendor|null $vendor - * @method static \Illuminate\Database\Eloquent\Builder|BaseModel company() + * @method static \Illuminate\Database\Eloquent\Builder company() * @method static \Illuminate\Database\Eloquent\Builder|BaseModel exclude($columns) * @method static \Database\Factories\InvoiceFactory factory($count = null, $state = []) * @method static \Illuminate\Database\Eloquent\Builder|Invoice filter(\App\Filters\QueryFilters $filters) diff --git a/phpstan.neon b/phpstan.neon index cdfa3b25d9..dba885569b 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -10,4 +10,5 @@ parameters: - 'app/Console/Commands/*' - 'app/DataMapper/Analytics/*' universalObjectCratesClasses: - - App\DataMapper\Tax\RuleInterface \ No newline at end of file + - App\DataMapper\Tax\RuleInterface + - App\DataMapper\FeesAndLimits \ No newline at end of file