Static analysis cleanup

This commit is contained in:
David Bomba 2023-07-25 20:04:04 +10:00
parent 8e22cff9ae
commit 90fdfedacb
33 changed files with 115 additions and 153 deletions

View File

@ -37,7 +37,6 @@ class AccountCreated extends GenericCounter
*
* date("Y-m-d H:i:s")
*
* @var \DateTime
*/
public $datetime;

View File

@ -37,7 +37,6 @@ class AccountDeleted extends GenericCounter
*
* date("Y-m-d H:i:s")
*
* @var \DateTime
*/
public $datetime;

View File

@ -37,7 +37,6 @@ class AccountPlatform extends GenericMixedMetric
*
* date("Y-m-d H:i:s")
*
* @var \DateTime
*/
public $datetime;

View File

@ -37,7 +37,6 @@ class AccountSignup extends GenericMixedMetric
*
* date("Y-m-d H:i:s")
*
* @var \DateTime
*/
public $datetime;
@ -61,7 +60,7 @@ class AccountSignup extends GenericMixedMetric
* The counter
* set to 1.
*
* @var string
* @var int
*/
public $int_metric1 = 1;

View File

@ -37,7 +37,6 @@ class BankAccountsCreated extends GenericMixedMetric
*
* date("Y-m-d H:i:s")
*
* @var \DateTime
*/
public $datetime;

View File

@ -37,7 +37,6 @@ class DbQuery extends GenericMixedMetric
*
* date("Y-m-d H:i:s")
*
* @var \DateTime
*/
public $datetime;
@ -57,7 +56,7 @@ class DbQuery extends GenericMixedMetric
* The counter
* set to 1.
*
* @var string
* @var int
*/
public $int_metric1 = 1;

View File

@ -37,7 +37,6 @@ class EmailCount extends GenericMixedMetric
*
* date("Y-m-d H:i:s")
*
* @var \DateTime
*/
public $datetime;

View File

@ -37,7 +37,6 @@ class EmailFailure extends GenericMixedMetric
*
* date("Y-m-d H:i:s")
*
* @var \DateTime
*/
public $datetime;
@ -61,7 +60,6 @@ class EmailFailure extends GenericMixedMetric
* The counter
* set to 1.
*
* @var string
*/
public $int_metric1 = 1;

View File

@ -37,7 +37,6 @@ class EmailInvoiceFailure extends GenericMixedMetric
*
* date("Y-m-d H:i:s")
*
* @var \DateTime
*/
public $datetime;

View File

@ -37,7 +37,6 @@ class EmailSuccess extends GenericMixedMetric
*
* date("Y-m-d H:i:s")
*
* @var \DateTime
*/
public $datetime;
@ -61,7 +60,6 @@ class EmailSuccess extends GenericMixedMetric
* The counter
* set to 1.
*
* @var string
*/
public $int_metric1 = 1;

View File

@ -37,7 +37,6 @@ class LivePreview extends GenericCounter
*
* date("Y-m-d H:i:s")
*
* @var \DateTime
*/
public $datetime;

View File

@ -37,7 +37,6 @@ class LoginFailure extends GenericCounter
*
* date("Y-m-d H:i:s")
*
* @var \DateTime
*/
public $datetime;

View File

@ -37,7 +37,6 @@ class LoginSuccess extends GenericCounter
*
* date("Y-m-d H:i:s")
*
* @var \DateTime
*/
public $datetime;

View File

@ -37,7 +37,6 @@ class EmailBounce extends GenericMixedMetric
*
* date("Y-m-d H:i:s")
*
* @var \DateTime
*/
public $datetime;
@ -67,7 +66,6 @@ class EmailBounce extends GenericMixedMetric
* The counter
* set to 1.
*
* @var string
*/
public $int_metric1 = 1;

View File

@ -16,13 +16,13 @@ namespace App\DataMapper;
*/
class BaseSettings
{
//@deprecated
public function __construct($obj)
{
// foreach ($obj as $key => $value) {
// $obj->{$key} = $value;
// }
}
// //@deprecated
// public function __construct($obj)
// {
// // foreach ($obj as $key => $value) {
// // $obj->{$key} = $value;
// // }
// }
public static function setCasts($obj, $casts)
{

View File

@ -47,17 +47,17 @@ class ClientSettings extends BaseSettings
'send_reminders' => 'bool',
];
/**
* Cast object values and return entire class
* prevents missing properties from not being returned
* and always ensure an up to date class is returned.
*
* @param $obj
*/
public function __construct($obj)
{
parent::__construct($obj);
}
// /**
// * Cast object values and return entire class
// * prevents missing properties from not being returned
// * and always ensure an up to date class is returned.
// *
// * @param $obj
// */
// public function __construct($obj)
// {
// // parent::__construct($obj);
// }
/**
* Default Client Settings scaffold.
@ -78,8 +78,8 @@ class ClientSettings extends BaseSettings
/**
* Merges settings from Company to Client.
*
* @param stdClass $company_settings
* @param stdClass $client_settings
* @param $company_settings
* @param $client_settings
* @return stdClass of merged settings
*/
public static function buildClientSettings($company_settings, $client_settings)

View File

@ -767,18 +767,18 @@ class CompanySettings extends BaseSettings
'purchase_order_design_id',
];
/**
* Cast object values and return entire class
* prevents missing properties from not being returned
* and always ensure an up to date class is returned.
*
* @param $obj
* @deprecated
*/
public function __construct()
{
// parent::__construct($obj);
}
// /**
// * Cast object values and return entire class
// * prevents missing properties from not being returned
// * and always ensure an up to date class is returned.
// *
// * @param $obj
// * @deprecated
// */
// public function __construct()
// {
// // parent::__construct($obj);
// }
/**
* Provides class defaults on init.

View File

@ -34,13 +34,4 @@ class DefaultSettings extends BaseSettings
];
}
/**
* @return stdClass
*/
private static function userSettingsObject() : stdClass
{
return (object) [
// 'per_page' => self::$per_page,
];
}
}
}

View File

@ -24,92 +24,78 @@ class EmailTemplateDefaults
case 'email_template_invoice':
return self::emailInvoiceTemplate();
break;
case 'email_template_quote':
return self::emailQuoteTemplate();
break;
case 'email_template_credit':
return self::emailCreditTemplate();
break;
case 'email_template_payment':
return self::emailPaymentTemplate();
break;
case 'email_template_payment_partial':
return self::emailPaymentPartialTemplate();
break;
case 'email_template_statement':
return self::emailStatementTemplate();
break;
case 'email_template_reminder1':
return self::emailReminder1Template();
break;
case 'email_template_reminder2':
return self::emailReminder2Template();
break;
case 'email_template_reminder3':
return self::emailReminder3Template();
break;
case 'email_template_reminder_endless':
return self::emailReminderEndlessTemplate();
break;
case 'email_template_custom1':
return self::emailInvoiceTemplate();
break;
case 'email_template_custom2':
return self::emailInvoiceTemplate();
break;
case 'email_template_custom3':
return self::emailInvoiceTemplate();
case 'email_template_purchase_order':
return self::emailPurchaseOrderTemplate();
break;
/* Subject */
case 'email_subject_purchase_order':
return self::emailPurchaseOrderSubject();
case 'email_subject_invoice':
return self::emailInvoiceSubject();
break;
case 'email_subject_quote':
return self::emailQuoteSubject();
break;
case 'email_subject_credit':
return self::emailCreditSubject();
break;
case 'email_subject_payment':
return self::emailPaymentSubject();
break;
case 'email_subject_payment_partial':
return self::emailPaymentPartialSubject();
break;
case 'email_subject_statement':
return self::emailStatementSubject();
break;
case 'email_subject_reminder1':
return self::emailReminder1Subject();
break;
case 'email_subject_reminder2':
return self::emailReminder2Subject();
break;
case 'email_subject_reminder3':
return self::emailReminder3Subject();
break;
case 'email_subject_reminder_endless':
return self::emailReminderEndlessSubject();
break;
case 'email_subject_custom1':
return self::emailInvoiceSubject();
break;
case 'email_subject_custom2':
return self::emailInvoiceSubject();
break;
case 'email_subject_custom3':
return self::emailInvoiceSubject();
break;
default:
return self::emailInvoiceTemplate();
break;
}
}

View File

@ -141,7 +141,6 @@ class FreeCompanySettings extends BaseSettings
public static $casts = [
'portal_design_id' => 'string',
'currency_id' => 'string',
'task_number_pattern' => 'string',
'task_number_counter' => 'int',
'expense_number_pattern' => 'string',
@ -191,16 +190,16 @@ class FreeCompanySettings extends BaseSettings
'website' => 'string',
];
/**
* Cast object values and return entire class
* prevents missing properties from not being returned
* and always ensure an up to date class is returned.
*
* @param $obj
*/
public function __construct($obj)
{
}
// /**
// * Cast object values and return entire class
// * prevents missing properties from not being returned
// * and always ensure an up to date class is returned.
// *
// * @param $obj
// */
// public function __construct($obj)
// {
// }
/**
* Provides class defaults on init.
@ -223,7 +222,7 @@ class FreeCompanySettings extends BaseSettings
$data->date_format_id = (string) config('ninja.i18n.date_format_id');
$data->country_id = (string) config('ninja.i18n.country_id');
$data->translations = (object) [];
$data->pdf_variables = (object) self::getEntityVariableDefaults();
// $data->pdf_variables = (object) self::getEntityVariableDefaults();
return self::setCasts($data, self::$casts);
}

View File

@ -197,7 +197,7 @@ class BaseRule implements RuleInterface
}
/** If we are in a Origin based state, force the company tax here */
if($company->origin_tax_data?->originDestination == 'O' && ($company->tax_data?->seller_subregion == $this->client_subregion)) {
if($company->origin_tax_data->originDestination == 'O' && ($company->tax_data?->seller_subregion == $this->client_subregion)) {
$tax_data = $company->origin_tax_data;

View File

@ -33859,8 +33859,6 @@ class USStates
'99926' => 'AK',
'99927' => 'AK',
'99929' => 'AK',
'13021' => 'NY',
'13024' => 'NY',
];
public static function get(): array

View File

@ -30,7 +30,7 @@ class DesignWasCreated
/**
* Get the channels the event should broadcast on.
*
* @return PrivateChannel
* @return PrivateChannel|array
*/
public function broadcastOn()
{

View File

@ -30,7 +30,7 @@ class DesignWasDeleted
/**
* Get the channels the event should broadcast on.
*
* @return PrivateChannel
* @return PrivateChannel|array
*/
public function broadcastOn()
{

View File

@ -30,7 +30,7 @@ class DesignWasRestored
/**
* Get the channels the event should broadcast on.
*
* @return PrivateChannel
* @return PrivateChannel|array
*/
public function broadcastOn()
{

View File

@ -30,7 +30,7 @@ class DesignWasUpdated
/**
* Get the channels the event should broadcast on.
*
* @return PrivateChannel
* @return PrivateChannel|array
*/
public function broadcastOn()
{

View File

@ -17,8 +17,10 @@ use App\Utils\Ninja;
use Sentry\State\Scope;
use Illuminate\Support\Arr;
use Illuminate\Http\Request;
use InvalidArgumentException;
use Sentry\Laravel\Integration;
use Illuminate\Support\Facades\Schema;
use Aws\Exception\CredentialsException;
use GuzzleHttp\Exception\ConnectException;
use Illuminate\Auth\AuthenticationException;
use League\Flysystem\UnableToCreateDirectory;
@ -34,7 +36,6 @@ use Symfony\Component\Console\Exception\CommandNotFoundException;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
use Symfony\Component\HttpKernel\Exception\MethodNotAllowedHttpException;
use Illuminate\Database\Eloquent\ModelNotFoundException as ModelNotFoundException;
use InvalidArgumentException;
class Handler extends ExceptionHandler
{
@ -64,7 +65,7 @@ class Handler extends ExceptionHandler
ConnectException::class,
RuntimeException::class,
InvalidArgumentException::class,
Aws\Exception\CredentialsException::class,
CredentialsException::class,
];
protected $hostedDontReport = [

View File

@ -14,7 +14,7 @@ namespace App\Exceptions;
use Exception;
use Illuminate\Http\Request;
use Illuminate\Http\Response;
use Illuminate\Http\JsonResponse;
class PaymentRefundFailed extends Exception
{
@ -32,14 +32,14 @@ class PaymentRefundFailed extends Exception
* Render the exception into an HTTP response.
*
* @param Request $request
* @return Response
* @return JsonResponse
*/
public function render($request)
{
// $msg = 'Unable to refund the transaction';
$msg = ctrans('texts.warning_local_refund');
if ($this->getMessage() && strlen($this->getMessage()) >= 1) {
if ($this->getMessage() && strlen($this->getMessage()) > 1) {
$msg = $this->getMessage();
}

View File

@ -14,7 +14,7 @@ namespace App\Exceptions;
use Exception;
use Illuminate\Http\Request;
use Illuminate\Http\Response;
use Illuminate\Http\JsonResponse;
class QuoteConversion extends Exception
{
@ -32,7 +32,7 @@ class QuoteConversion extends Exception
* Render the exception into an HTTP response.
*
* @param Request $request
* @return Response
* @return JsonResponse
*/
public function render($request)
{

View File

@ -14,7 +14,7 @@ namespace App\Exceptions;
use Exception;
use Illuminate\Http\Request;
use Illuminate\Http\Response;
use Illuminate\Http\JsonResponse;
class YodleeApiException extends Exception
{
@ -32,14 +32,14 @@ class YodleeApiException extends Exception
* Render the exception into an HTTP response.
*
* @param Request $request
* @return Response
* @return JsonResponse
*/
public function render($request)
{
// $msg = 'Unable to refund the transaction';
$msg = ctrans('texts.error');
if ($this->getMessage() && strlen($this->getMessage()) >= 1) {
if ($this->getMessage() && strlen($this->getMessage()) > 1) {
$msg = $this->getMessage();
}

View File

@ -131,8 +131,8 @@ class TaskFilters extends QueryFilters
$status_parameters = explode(',', $value);
if(count($status_parameters) > 0)
return $this->builder->whereIn('status_id', $this->transformKeys($status_parameters));
if(count($status_parameters) >= 1)
$this->builder->whereIn('status_id', $this->transformKeys($status_parameters));
return $this->builder;
}

View File

@ -11,6 +11,7 @@
namespace App\Models;
use App\Models\GatewayType;
use App\Utils\Traits\AppSetup;
use App\Utils\Traits\MakesHash;
use App\Utils\Traits\MakesDates;
@ -26,6 +27,9 @@ use App\Models\Presenters\ClientPresenter;
use Illuminate\Database\Eloquent\SoftDeletes;
use App\Utils\Traits\ClientGroupSettingsSaver;
use App\Libraries\Currency\Conversion\CurrencyApi;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\MorphMany;
use Illuminate\Contracts\Translation\HasLocalePreference;
/**
@ -303,62 +307,62 @@ class Client extends BaseModel implements HasLocalePreference
return $this->hasMany(Activity::class)->take(50)->orderBy('id', 'desc');
}
public function contacts()
public function contacts() :HasMany
{
return $this->hasMany(ClientContact::class)->orderBy('is_primary', 'desc');
}
public function primary_contact()
public function primary_contact():HasMany
{
return $this->hasMany(ClientContact::class)->where('is_primary', true);
}
public function company()
public function company() :BelongsTo
{
return $this->belongsTo(Company::class);
}
public function user()
public function user() :BelongsTo
{
return $this->belongsTo(User::class)->withTrashed();
}
public function assigned_user()
public function assigned_user() :BelongsTo
{
return $this->belongsTo(User::class, 'assigned_user_id', 'id')->withTrashed();
}
public function country()
public function country() :BelongsTo
{
return $this->belongsTo(Country::class);
}
public function invoices()
public function invoices() :HasMany
{
return $this->hasMany(Invoice::class)->withTrashed();
}
public function quotes()
public function quotes() :HasMany
{
return $this->hasMany(Quote::class)->withTrashed();
}
public function tasks()
public function tasks() :HasMany
{
return $this->hasMany(Task::class)->withTrashed();
}
public function payments()
public function payments() :HasMany
{
return $this->hasMany(Payment::class)->withTrashed();
}
public function recurring_invoices()
public function recurring_invoices() :HasMany
{
return $this->hasMany(RecurringInvoice::class)->withTrashed();
}
public function recurring_expenses()
public function recurring_expenses() :HasMany
{
return $this->hasMany(RecurringExpense::class)->withTrashed();
}
@ -368,12 +372,12 @@ class Client extends BaseModel implements HasLocalePreference
return $this->belongsTo(Country::class, 'shipping_country_id', 'id');
}
public function system_logs()
public function system_logs() :HasMany
{
return $this->hasMany(SystemLog::class)->take(50)->orderBy('id', 'desc');
}
public function timezone()
public function timezone() :TimeZone
{
return Timezone::find($this->getSetting('timezone_id'));
}
@ -391,17 +395,17 @@ class Client extends BaseModel implements HasLocalePreference
})->first();
}
public function industry()
public function industry() :BelongsTo
{
return $this->belongsTo(Industry::class);
}
public function size()
public function size() :BelongsTo
{
return $this->belongsTo(Size::class);
}
public function locale()
public function locale() :string
{
if (! $this->language()) {
return 'en';
@ -472,7 +476,7 @@ class Client extends BaseModel implements HasLocalePreference
* @param string $setting The Setting parameter
* @return mixed The setting requested
*/
public function getSetting($setting)
public function getSetting($setting) :mixed
{
/*Client Settings*/
if ($this->settings && property_exists($this->settings, $setting) && isset($this->settings->{$setting})) {
@ -502,7 +506,6 @@ class Client extends BaseModel implements HasLocalePreference
return '';
// throw new \Exception("Settings corrupted", 1);
}
public function getSettingEntity($setting)
@ -528,12 +531,12 @@ class Client extends BaseModel implements HasLocalePreference
throw new \Exception('Could not find a settings object', 1);
}
public function documents()
public function documents() :MorphMany
{
return $this->morphMany(Document::class, 'documentable');
}
public function group_settings()
public function group_settings() :BelongsTo
{
return $this->belongsTo(GroupSetting::class);
}
@ -656,7 +659,7 @@ class Client extends BaseModel implements HasLocalePreference
}
}
public function getCurrencyCode()
public function getCurrencyCode(): string
{
if ($this->currency()) {
return $this->currency()->code;
@ -697,51 +700,51 @@ class Client extends BaseModel implements HasLocalePreference
})->first()->locale;
}
public function backup_path()
public function backup_path() :string
{
return $this->company->company_key.'/'.$this->client_hash.'/backups';
}
public function invoice_filepath($invitation)
public function invoice_filepath($invitation) :string
{
$contact_key = $invitation->contact->contact_key;
return $this->company->company_key.'/'.$this->client_hash.'/'.$contact_key.'/invoices/';
}
public function e_invoice_filepath($invitation)
public function e_invoice_filepath($invitation) :string
{
$contact_key = $invitation->contact->contact_key;
return $this->company->company_key.'/'.$this->client_hash.'/'.$contact_key.'/e_invoice/';
}
public function quote_filepath($invitation)
public function quote_filepath($invitation) :string
{
$contact_key = $invitation->contact->contact_key;
return $this->company->company_key.'/'.$this->client_hash.'/'.$contact_key.'/quotes/';
}
public function credit_filepath($invitation)
public function credit_filepath($invitation) :string
{
$contact_key = $invitation->contact->contact_key;
return $this->company->company_key.'/'.$this->client_hash.'/'.$contact_key.'/credits/';
}
public function recurring_invoice_filepath($invitation)
public function recurring_invoice_filepath($invitation) :string
{
$contact_key = $invitation->contact->contact_key;
return $this->company->company_key.'/'.$this->client_hash.'/'.$contact_key.'/recurring_invoices/';
}
public function company_filepath()
public function company_filepath() :string
{
return $this->company->company_key.'/';
}
public function document_filepath()
public function document_filepath() :string
{
return $this->company->company_key.'/documents/';
}
@ -772,7 +775,7 @@ class Client extends BaseModel implements HasLocalePreference
return $defaults;
}
public function timezone_offset()
public function timezone_offset() :int
{
$offset = 0;
@ -802,7 +805,7 @@ class Client extends BaseModel implements HasLocalePreference
];
}
public function translate_entity()
public function translate_entity() :string
{
return ctrans('texts.client');
}

View File

@ -8,5 +8,6 @@ parameters:
- 'vendor/'
- 'app/Jobs/Ninja/*'
- 'app/Console/Commands/*'
- 'app/DataMapper/Analytics/*'
universalObjectCratesClasses:
- App\DataMapper\Tax\RuleInterface
- App\DataMapper\Tax\RuleInterface