1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-09 20:52:56 +01:00

Static analysis cleanup

This commit is contained in:
David Bomba 2023-08-01 23:28:30 +10:00
parent 82784582f0
commit 0792638e90
8 changed files with 47 additions and 42 deletions

View File

@ -13,35 +13,35 @@ namespace App\DataMapper;
class FeesAndLimits class FeesAndLimits
{ {
public $min_limit = -1; //equivalent to null public float $min_limit = -1; //equivalent to null
public $max_limit = -1; //equivalent to null public float $max_limit = -1; //equivalent to null
public $fee_amount = 0; public float $fee_amount = 0;
public $fee_percent = 0; public float $fee_percent = 0;
public $fee_tax_name1 = ''; public string $fee_tax_name1 = '';
public $fee_tax_name2 = ''; public string $fee_tax_name2 = '';
public $fee_tax_name3 = ''; public string $fee_tax_name3 = '';
public $fee_tax_rate1 = 0; public float $fee_tax_rate1 = 0;
public $fee_tax_rate2 = 0; public float $fee_tax_rate2 = 0;
public $fee_tax_rate3 = 0; public float $fee_tax_rate3 = 0;
public $fee_cap = 0; public float $fee_cap = 0;
public $adjust_fee_percent = false; public bool $adjust_fee_percent = false;
public $is_enabled = true; public bool $is_enabled = true;
//public $gateway_type_id = 1; //public $gateway_type_id = 1;
public static $casts = [ public static array $casts = [
'is_enabled' => 'bool', 'is_enabled' => 'bool',
'gateway_type_id' => 'int', 'gateway_type_id' => 'int',
'min_limit' => 'float', 'min_limit' => 'float',

View File

@ -22,7 +22,9 @@ class UploadMigrationFileRequest extends Request
*/ */
public function authorize() public function authorize()
{ {
return auth()->user()->isAdmin(); /** @var \App\Models\User $user */
$user = auth()->user();
return $user->isAdmin();
} }
/** /**
@ -30,7 +32,7 @@ class UploadMigrationFileRequest extends Request
* *
* @return array * @return array
*/ */
public function rules() public function rules(): array
{ {
$rules = [ $rules = [
'migration' => [], 'migration' => [],

View File

@ -64,12 +64,12 @@ class RefundPaymentRequest extends Request
$this->replace($input); $this->replace($input);
} }
public function rules() public function rules(): array
{ {
$input = $this->all(); $input = $this->all();
$rules = [ $rules = [
'id' => 'bail|required', 'id' => 'bail|required', //@phpstan-ignore-line
'id' => new ValidRefundableRequest($input), 'id' => new ValidRefundableRequest($input),
'amount' => 'numeric', 'amount' => 'numeric',
'date' => 'required', 'date' => 'required',

View File

@ -46,8 +46,8 @@ class ValidRefundableRequest implements Rule
return false; return false;
} }
/**@var \App\Models\Payment $payment */ /**@var \App\Models\Payment $payment **/
$payment = Payment::whereId($this->input['id'])->withTrashed()->first(); $payment = Payment::where('id', $this->input['id'])->withTrashed()->first();
if (! $payment) { if (! $payment) {
$this->error_msg = ctrans('texts.unable_to_retrieve_payment'); $this->error_msg = ctrans('texts.unable_to_retrieve_payment');
@ -56,7 +56,6 @@ class ValidRefundableRequest implements Rule
} }
$request_invoices = request()->has('invoices') ? $this->input['invoices'] : []; $request_invoices = request()->has('invoices') ? $this->input['invoices'] : [];
// $request_credits = request()->has('credits') ? $this->input['credits'] : [];
if ($payment->invoices()->exists()) { if ($payment->invoices()->exists()) {
foreach ($payment->invoices as $paymentable_invoice) { foreach ($payment->invoices as $paymentable_invoice) {
@ -77,8 +76,8 @@ class ValidRefundableRequest implements Rule
private function checkInvoiceIsPaymentable($invoice, $payment) private function checkInvoiceIsPaymentable($invoice, $payment)
{ {
/**@var \App\Models\Invoice $invoice */ /**@var \App\Models\Invoice $invoice **/
$invoice = Invoice::whereId($invoice['invoice_id'])->whereCompanyId($payment->company_id)->withTrashed()->first(); $invoice = Invoice::where('id', $invoice['invoice_id'])->where('company_id', $payment->company_id)->withTrashed()->first();
if (! $invoice) { if (! $invoice) {
$this->error_msg = 'Invoice not found for refund'; $this->error_msg = 'Invoice not found for refund';

View File

@ -35,25 +35,26 @@ use Illuminate\Database\Eloquent\ModelNotFoundException as ModelNotFoundExceptio
* @property \App\Models\Company $company * @property \App\Models\Company $company
* @method static \Illuminate\Database\Eloquent\Builder|BaseModel|Illuminate\Database\Eloquent\Relations\BelongsTo|\Awobaz\Compoships\Database\Eloquent\Relations\BelongsTo|\App\Models\Company company() * @method static \Illuminate\Database\Eloquent\Builder|BaseModel|Illuminate\Database\Eloquent\Relations\BelongsTo|\Awobaz\Compoships\Database\Eloquent\Relations\BelongsTo|\App\Models\Company company()
* @method static \Illuminate\Database\Eloquent\Builder|BaseModel|Illuminate\Database\Eloquent\Relations\HasMany|BaseModel orderBy() * @method static \Illuminate\Database\Eloquent\Builder|BaseModel|Illuminate\Database\Eloquent\Relations\HasMany|BaseModel orderBy()
* @method static \Illuminate\Database\Eloquent\Builder exclude($columns) * @method static \Illuminate\Database\Eloquent\Builder|BaseModel exclude($columns)
* @method static \Illuminate\Database\Eloquent\Builder company() * @method static \Illuminate\Database\Eloquent\Builder|BaseModel company()
* @method static \Illuminate\Database\Eloquent\Builder with($value) * @method static \Illuminate\Database\Eloquent\Builder|BaseModel with($value)
* @method static \Illuminate\Database\Eloquent\Builder newModelQuery($query) * @method static \Illuminate\Database\Eloquent\Builder|BaseModel newModelQuery($query)
* @method static \Illuminate\Database\Eloquent\Builder newQuery($query) * @method static \Illuminate\Database\Eloquent\Builder|BaseModel newQuery($query)
* @method static \Illuminate\Database\Eloquent\Builder query() * @method static \Illuminate\Database\Eloquent\Builder|BaseModel query()
* @method static \Illuminate\Database\Eloquent\Builder exclude(array $excludeable) * @method static \Illuminate\Database\Eloquent\Builder|BaseModel exclude(array $excludeable)
* @method static \Illuminate\Database\Eloquent\Builder withTrashed() * @method static \Illuminate\Database\Eloquent\Builder|BaseModel|\Illuminate\Database\Query\Builder withTrashed(bool $withTrashed = true)
* @method static \Illuminate\Database\Eloquent\Builder scopeExclude($query) * @method static \Illuminate\Database\Eloquent\Builder|BaseModel scopeExclude($query)
* @method static BaseModel find($value) * @method static BaseModel find($value)
* @method static \Illuminate\Database\Eloquent\Builder whereIn($query) * @method static \Illuminate\Database\Eloquent\Builder|BaseModel whereId($query)
* @method static \Illuminate\Database\Eloquent\Builder where($query) * @method static \Illuminate\Database\Eloquent\Builder|BaseModel whereIn($query)
* @method static \Illuminate\Database\Eloquent\Builder count() * @method static \Illuminate\Database\Eloquent\Builder|BaseModel where($query)
* @method static \Illuminate\Database\Eloquent\Builder create($query) * @method static \Illuminate\Database\Eloquent\Builder|BaseModel count()
* @method static \Illuminate\Database\Eloquent\Builder insert($query) * @method static \Illuminate\Database\Eloquent\Builder|BaseModel create($query)
* @method static \Illuminate\Database\Eloquent\Builder service() * @method static \Illuminate\Database\Eloquent\Builder|BaseModel insert($query)
* @method static \Illuminate\Database\Eloquent\Builder orderBy($column, $direction) * @method static \Illuminate\Database\Eloquent\Builder|BaseModel service()
* @method static \Illuminate\Database\Eloquent\Builder invitations() * @method static \Illuminate\Database\Eloquent\Builder|BaseModel orderBy($column, $direction)
* @method static \Illuminate\Database\Eloquent\Builder whereHas($query) * @method static \Illuminate\Database\Eloquent\Builder|BaseModel invitations()
* @method static \Illuminate\Database\Eloquent\Builder|BaseModel whereHas($query)
* @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\InvoiceInvitation | \App\Models\CreditInvitation | \App\Models\QuoteInvitation | \App\Models\RecurringInvoiceInvitation> $invitations * @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\InvoiceInvitation | \App\Models\CreditInvitation | \App\Models\QuoteInvitation | \App\Models\RecurringInvoiceInvitation> $invitations
* @property-read int|null $invitations_count * @property-read int|null $invitations_count
* *

View File

@ -132,6 +132,8 @@ use App\Events\Invoice\InvoiceReminderWasEmailed;
* @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\Payment> $payments * @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\Payment> $payments
* @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\Task> $tasks * @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\Task> $tasks
* @property object|null $tax_data * @property object|null $tax_data
* @method static \Illuminate\Database\Eloquent\Builder company()
* @method static \Illuminate\Database\Eloquent\Builder|\Illuminate\Database\Query\Builder withTrashed(bool $withTrashed = true)
* @mixin \Eloquent * @mixin \Eloquent
*/ */
class Invoice extends BaseModel class Invoice extends BaseModel

View File

@ -92,6 +92,7 @@ use Illuminate\Database\Eloquent\SoftDeletes;
* @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\Document> $documents * @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\Document> $documents
* @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\Invoice> $invoices * @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\Invoice> $invoices
* @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\Paymentable> $paymentables * @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\Paymentable> $paymentables
* @method static \Illuminate\Database\Eloquent\Builder|\Illuminate\Database\Query\Builder withTrashed(bool $withTrashed = true)
* @mixin \Eloquent * @mixin \Eloquent
*/ */
class Payment extends BaseModel class Payment extends BaseModel

View File

@ -1,7 +1,7 @@
includes: includes:
- ./vendor/nunomaduro/larastan/extension.neon - ./vendor/nunomaduro/larastan/extension.neon
parameters: parameters:
level: 4 level: 2
paths: paths:
- 'app/' - 'app/'
excludePaths: excludePaths: