Static Analysis

This commit is contained in:
David Bomba 2024-06-16 14:35:56 +10:00
parent 78333e332f
commit 52752a8f09
63 changed files with 129 additions and 122 deletions

View File

@ -24,6 +24,7 @@ class TaxData
public function __construct(public Response $origin) public function __construct(public Response $origin)
{ {
// @phpstan-ignore-next-line
foreach($origin as $key => $value) { foreach($origin as $key => $value) {
$this->{$key} = $value; $this->{$key} = $value;
} }

View File

@ -167,17 +167,17 @@ class ContactLoginController extends Controller
{ {
if (auth()->guard('contact')->user()->client->getSetting('enable_client_portal_dashboard') === true) { if (auth()->guard('contact')->user()->client->getSetting('enable_client_portal_dashboard') === true) {
$this->redirectTo = '/client/dashboard'; $this->redirectTo = '/client/dashboard';
} elseif (auth()->guard('contact')->user()->company->enabled_modules & PortalComposer::MODULE_INVOICES) { } elseif ((bool)(auth()->guard('contact')->user()->company->enabled_modules & PortalComposer::MODULE_INVOICES)) {
$this->redirectTo = '/client/invoices'; $this->redirectTo = '/client/invoices';
} elseif (auth()->guard('contact')->user()->company->enabled_modules & PortalComposer::MODULE_RECURRING_INVOICES) { } elseif ((bool)(auth()->guard('contact')->user()->company->enabled_modules & PortalComposer::MODULE_RECURRING_INVOICES)) {
$this->redirectTo = '/client/recurring_invoices'; $this->redirectTo = '/client/recurring_invoices';
} elseif (auth()->guard('contact')->user()->company->enabled_modules & PortalComposer::MODULE_QUOTES) { } elseif ((bool)(auth()->guard('contact')->user()->company->enabled_modules & PortalComposer::MODULE_QUOTES)) {
$this->redirectTo = '/client/quotes'; $this->redirectTo = '/client/quotes';
} elseif (auth()->guard('contact')->user()->company->enabled_modules & PortalComposer::MODULE_CREDITS) { } elseif ((bool)(auth()->guard('contact')->user()->company->enabled_modules & PortalComposer::MODULE_CREDITS)) {
$this->redirectTo = '/client/credits'; $this->redirectTo = '/client/credits';
} elseif (auth()->guard('contact')->user()->company->enabled_modules & PortalComposer::MODULE_TASKS) { } elseif ((bool)(auth()->guard('contact')->user()->company->enabled_modules & PortalComposer::MODULE_TASKS)) {
$this->redirectTo = '/client/tasks'; $this->redirectTo = '/client/tasks';
} elseif (auth()->guard('contact')->user()->company->enabled_modules & PortalComposer::MODULE_EXPENSES) { } elseif ((bool)(auth()->guard('contact')->user()->company->enabled_modules & PortalComposer::MODULE_EXPENSES)) {
$this->redirectTo = '/client/expenses'; $this->redirectTo = '/client/expenses';
} }
} }

View File

@ -66,15 +66,15 @@ class ContactHashLoginController extends Controller
{ {
if (auth()->guard('contact')->user()->company->enabled_modules & PortalComposer::MODULE_INVOICES) { if (auth()->guard('contact')->user()->company->enabled_modules & PortalComposer::MODULE_INVOICES) {
return '/client/invoices'; return '/client/invoices';
} elseif (auth()->guard('contact')->user()->company->enabled_modules & PortalComposer::MODULE_RECURRING_INVOICES) { } elseif ((bool)(auth()->guard('contact')->user()->company->enabled_modules & PortalComposer::MODULE_RECURRING_INVOICES)) {
return '/client/recurring_invoices'; return '/client/recurring_invoices';
} elseif (auth()->guard('contact')->user()->company->enabled_modules & PortalComposer::MODULE_QUOTES) { } elseif ((bool)(auth()->guard('contact')->user()->company->enabled_modules & PortalComposer::MODULE_QUOTES)) {
return '/client/quotes'; return '/client/quotes';
} elseif (auth()->guard('contact')->user()->company->enabled_modules & PortalComposer::MODULE_CREDITS) { } elseif ((bool)(auth()->guard('contact')->user()->company->enabled_modules & PortalComposer::MODULE_CREDITS)) {
return '/client/credits'; return '/client/credits';
} elseif (auth()->guard('contact')->user()->company->enabled_modules & PortalComposer::MODULE_TASKS) { } elseif ((bool)(auth()->guard('contact')->user()->company->enabled_modules & PortalComposer::MODULE_TASKS)) {
return '/client/tasks'; return '/client/tasks';
} elseif (auth()->guard('contact')->user()->company->enabled_modules & PortalComposer::MODULE_EXPENSES) { } elseif ((bool)(auth()->guard('contact')->user()->company->enabled_modules & PortalComposer::MODULE_EXPENSES)) {
return '/client/expenses'; return '/client/expenses';
} }
} }

View File

@ -458,7 +458,7 @@ class CreditController extends BaseController
/** /**
* Perform bulk actions on the list view. * Perform bulk actions on the list view.
* *
* @return \Symfony\Component\HttpFoundation\StreamedResponse | \Illuminate\Http\JsonResponse * @return \Symfony\Component\HttpFoundation\StreamedResponse | \Illuminate\Http\JsonResponse | \Illuminate\Http\Response
* *
* @OA\Post( * @OA\Post(
* path="/api/v1/credits/bulk", * path="/api/v1/credits/bulk",
@ -700,7 +700,7 @@ class CreditController extends BaseController
* ), * ),
* ) * )
* @param $invitation_key * @param $invitation_key
* @return \Symfony\Component\HttpFoundation\StreamedResponse * @return \Symfony\Component\HttpFoundation\StreamedResponse | \Illuminate\Http\JsonResponse | \Illuminate\Http\Response
*/ */
public function downloadPdf($invitation_key) public function downloadPdf($invitation_key)
{ {
@ -768,7 +768,7 @@ class CreditController extends BaseController
* ), * ),
* ) * )
* @param $invitation_key * @param $invitation_key
* @return \Symfony\Component\HttpFoundation\BinaryFileResponse * @return \Symfony\Component\HttpFoundation\StreamedResponse | \Illuminate\Http\JsonResponse | \Illuminate\Http\Response
*/ */
public function downloadECredit($invitation_key) public function downloadECredit($invitation_key)
{ {

View File

@ -24,7 +24,7 @@ class FilterController extends BaseController
/** /**
* Display a listing of the resource. * Display a listing of the resource.
* *
* @return void * @return \Illuminate\Http\JsonResponse
*/ */
public function index(Request $request, string $entity) public function index(Request $request, string $entity)
{ {

View File

@ -800,7 +800,7 @@ class InvoiceController extends BaseController
* ), * ),
* ) * )
* @param $invitation_key * @param $invitation_key
* @return \Symfony\Component\HttpFoundation\BinaryFileResponse * @return \Symfony\Component\HttpFoundation\StreamedResponse | \Illuminate\Http\JsonResponse | \Illuminate\Http\Response
*/ */
public function downloadPdf($invitation_key) public function downloadPdf($invitation_key)
{ {
@ -870,7 +870,7 @@ class InvoiceController extends BaseController
* ), * ),
* ) * )
* @param $invitation_key * @param $invitation_key
* @return \Symfony\Component\HttpFoundation\BinaryFileResponse * @return \Symfony\Component\HttpFoundation\StreamedResponse | \Illuminate\Http\JsonResponse | \Illuminate\Http\Response
*/ */
public function downloadEInvoice($invitation_key) public function downloadEInvoice($invitation_key)
{ {
@ -938,7 +938,7 @@ class InvoiceController extends BaseController
* ), * ),
* ) * )
* @param $invoice * @param $invoice
* @return \Symfony\Component\HttpFoundation\BinaryFileResponse * @return \Symfony\Component\HttpFoundation\StreamedResponse | \Illuminate\Http\JsonResponse | \Illuminate\Http\Response
*/ */
public function deliveryNote(ShowInvoiceRequest $request, Invoice $invoice) public function deliveryNote(ShowInvoiceRequest $request, Invoice $invoice)
{ {

View File

@ -54,7 +54,7 @@ class PreviewPurchaseOrderController extends BaseController
/** /**
* Returns a template filled with entity variables. * Returns a template filled with entity variables.
* *
* @return \Illuminate\Http\Response * @return \Symfony\Component\HttpFoundation\StreamedResponse | \Illuminate\Http\JsonResponse | \Illuminate\Http\Response | \Symfony\Component\HttpFoundation\BinaryFileResponse
* *
* @OA\Post( * @OA\Post(
* path="/api/v1/preview/purchase_order", * path="/api/v1/preview/purchase_order",

View File

@ -434,7 +434,7 @@ class PurchaseOrderController extends BaseController
/** /**
* Perform bulk actions on the list view. * Perform bulk actions on the list view.
* *
* @return \Illuminate\Http\Response|\Illuminate\Http\JsonResponse * @return \Symfony\Component\HttpFoundation\StreamedResponse | \Illuminate\Http\JsonResponse | \Illuminate\Http\Response | \Symfony\Component\HttpFoundation\BinaryFileResponse
* *
* @OA\Post( * @OA\Post(
* path="/api/v1/purchase_orders/bulk", * path="/api/v1/purchase_orders/bulk",
@ -826,7 +826,7 @@ class PurchaseOrderController extends BaseController
* ), * ),
* ) * )
* @param $invitation_key * @param $invitation_key
* @return \Symfony\Component\HttpFoundation\BinaryFileResponse * @return \Symfony\Component\HttpFoundation\StreamedResponse | \Illuminate\Http\JsonResponse | \Illuminate\Http\Response
*/ */
public function downloadPdf($invitation_key) public function downloadPdf($invitation_key)
{ {
@ -891,7 +891,7 @@ class PurchaseOrderController extends BaseController
* ), * ),
* ) * )
* @param $invitation_key * @param $invitation_key
* @return \Symfony\Component\HttpFoundation\BinaryFileResponse * @return \Symfony\Component\HttpFoundation\StreamedResponse | \Illuminate\Http\JsonResponse | \Illuminate\Http\Response
*/ */
public function downloadEPurchaseOrder($invitation_key) public function downloadEPurchaseOrder($invitation_key)
{ {

View File

@ -465,7 +465,7 @@ class QuoteController extends BaseController
/** /**
* Perform bulk actions on the list view. * Perform bulk actions on the list view.
* *
* @return \Illuminate\Http\Response|\Illuminate\Http\JsonResponse * @return \Symfony\Component\HttpFoundation\StreamedResponse | \Illuminate\Http\JsonResponse | \Illuminate\Http\Response
* *
* *
* @OA\Post( * @OA\Post(
@ -832,7 +832,7 @@ class QuoteController extends BaseController
* ), * ),
* ) * )
* @param $invitation_key * @param $invitation_key
* @return \Symfony\Component\HttpFoundation\BinaryFileResponse * @return \Symfony\Component\HttpFoundation\StreamedResponse | \Illuminate\Http\JsonResponse | \Illuminate\Http\Response | \Symfony\Component\HttpFoundation\BinaryFileResponse
*/ */
public function downloadPdf($invitation_key) public function downloadPdf($invitation_key)

View File

@ -28,7 +28,7 @@ trait VerifiesUserEmail
use MakesHash; use MakesHash;
/** /**
* @return \Illuminate\Http\RedirectResponse * @return \Illuminate\View\View
*/ */
public function confirm() public function confirm()
{ {

View File

@ -19,7 +19,7 @@ class VendorContactHashLoginController extends Controller
/** /**
* Logs a user into the client portal using their contact_key * Logs a user into the client portal using their contact_key
* @param string $contact_key The contact key * @param string $contact_key The contact key
* @return Auth|\Illuminate\Support\Facades\Redirect * @return \Illuminate\Http\RedirectResponse
*/ */
public function login(string $contact_key) public function login(string $contact_key)
{ {
@ -27,14 +27,19 @@ class VendorContactHashLoginController extends Controller
} }
/** /**
* @return \Illuminate\Support\Facades\Redirect * @return \Illuminate\Http\RedirectResponse
*/ */
public function magicLink(string $magic_link) public function magicLink(string $magic_link)
{ {
return redirect($this->setRedirectPath()); return redirect($this->setRedirectPath());
} }
/**
* errorPage
*
* @return \Illuminate\View\View
*/
public function errorPage() public function errorPage()
{ {
return render('generic.error', ['title' => session()->get('title'), 'notification' => session()->get('notification')]); return render('generic.error', ['title' => session()->get('title'), 'notification' => session()->get('notification')]);

View File

@ -65,7 +65,7 @@ class Kernel extends HttpKernel
* *
* These middleware are run during every request to your application. * These middleware are run during every request to your application.
* *
* @var array * @var array<int,string>
*/ */
protected $middleware = [ protected $middleware = [
CheckForMaintenanceMode::class, CheckForMaintenanceMode::class,
@ -79,7 +79,7 @@ class Kernel extends HttpKernel
/** /**
* The application's route middleware groups. * The application's route middleware groups.
* *
* @var array * @var array<string, array<int,string>>
*/ */
protected $middlewareGroups = [ protected $middlewareGroups = [
'web' => [ 'web' => [
@ -125,7 +125,7 @@ class Kernel extends HttpKernel
* *
* These middleware may be assigned to groups or used individually. * These middleware may be assigned to groups or used individually.
* *
* @var array * @var array<string,string>
*/ */
protected $middlewareAliases = [ protected $middlewareAliases = [
'auth' => Authenticate::class, 'auth' => Authenticate::class,

View File

@ -18,7 +18,7 @@ class CheckForMaintenanceMode extends Middleware
/** /**
* The URIs that should be reachable while maintenance mode is enabled. * The URIs that should be reachable while maintenance mode is enabled.
* *
* @var array * @var array<int,string>
*/ */
protected $except = [ protected $except = [
// //

View File

@ -163,17 +163,17 @@ class ContactKeyLogin
{ {
if (auth()->guard('contact')->user()->client->getSetting('enable_client_portal_dashboard') === true) { if (auth()->guard('contact')->user()->client->getSetting('enable_client_portal_dashboard') === true) {
return '/client/dashboard'; return '/client/dashboard';
} elseif (auth()->guard('contact')->user()->company->enabled_modules & PortalComposer::MODULE_INVOICES) { } elseif ((bool)(auth()->guard('contact')->user()->company->enabled_modules & PortalComposer::MODULE_INVOICES)) {
return '/client/invoices'; return '/client/invoices';
} elseif (auth()->guard('contact')->user()->company->enabled_modules & PortalComposer::MODULE_RECURRING_INVOICES) { } elseif ((bool)(auth()->guard('contact')->user()->company->enabled_modules & PortalComposer::MODULE_RECURRING_INVOICES)) {
return '/client/recurring_invoices'; return '/client/recurring_invoices';
} elseif (auth()->guard('contact')->user()->company->enabled_modules & PortalComposer::MODULE_QUOTES) { } elseif ((bool)(auth()->guard('contact')->user()->company->enabled_modules & PortalComposer::MODULE_QUOTES)) {
return '/client/quotes'; return '/client/quotes';
} elseif (auth()->guard('contact')->user()->company->enabled_modules & PortalComposer::MODULE_CREDITS) { } elseif ((bool)(auth()->guard('contact')->user()->company->enabled_modules & PortalComposer::MODULE_CREDITS)) {
return '/client/credits'; return '/client/credits';
} elseif (auth()->guard('contact')->user()->company->enabled_modules & PortalComposer::MODULE_TASKS) { } elseif ((bool)(auth()->guard('contact')->user()->company->enabled_modules & PortalComposer::MODULE_TASKS)) {
return '/client/tasks'; return '/client/tasks';
} elseif (auth()->guard('contact')->user()->company->enabled_modules & PortalComposer::MODULE_EXPENSES) { } elseif ((bool)(auth()->guard('contact')->user()->company->enabled_modules & PortalComposer::MODULE_EXPENSES)) {
return '/client/expenses'; return '/client/expenses';
} }
} }

View File

@ -18,7 +18,7 @@ class EncryptCookies extends Middleware
/** /**
* The names of the cookies that should not be encrypted. * The names of the cookies that should not be encrypted.
* *
* @var array * @var array<int,string>
*/ */
protected $except = [ protected $except = [
// //

View File

@ -12,7 +12,7 @@ class ThrottleRequestsWithPredis extends ThrottleRequests
/** /**
* The Redis factory implementation. * The Redis factory implementation.
* *
* @var \Illuminate\Contracts\Redis\Factory * @var \Illuminate\Redis\Connections\Connection
*/ */
protected $redis; protected $redis;

View File

@ -18,7 +18,7 @@ class TrimStrings extends Middleware
/** /**
* The names of the attributes that should not be trimmed. * The names of the attributes that should not be trimmed.
* *
* @var array * @var array<int,string>
*/ */
protected $except = [ protected $except = [
'current_password', 'current_password',

View File

@ -20,7 +20,7 @@ class TrustProxies extends Middleware
/** /**
* The trusted proxies for this application. * The trusted proxies for this application.
* *
* @var array * @var array<int,string>
*/ */
protected $proxies; protected $proxies;

View File

@ -25,7 +25,7 @@ class VerifyCsrfToken extends Middleware
/** /**
* The URIs that should be excluded from CSRF verification. * The URIs that should be excluded from CSRF verification.
* *
* @var array * @var array<int,string>
*/ */
protected $except = [ protected $except = [
'setup/*', 'setup/*',

View File

@ -17,7 +17,7 @@ class ShowCreditRequest extends FormRequest
auth()->guard('contact')->user()->loadMissing(['company']); auth()->guard('contact')->user()->loadMissing(['company']);
return ! $this->credit->is_deleted return ! $this->credit->is_deleted
&& auth()->guard('contact')->user()->company->enabled_modules & PortalComposer::MODULE_CREDITS && (bool)(auth()->guard('contact')->user()->company->enabled_modules & PortalComposer::MODULE_CREDITS)
&& auth()->guard('contact')->user()->client_id === $this->credit->client_id; && auth()->guard('contact')->user()->client_id === $this->credit->client_id;
} }

View File

@ -19,7 +19,7 @@ class ShowCreditsRequest extends FormRequest
{ {
public function authorize() public function authorize()
{ {
return auth()->guard('contact')->user()->company->enabled_modules & PortalComposer::MODULE_CREDITS; return (bool)(auth()->guard('contact')->user()->company->enabled_modules & PortalComposer::MODULE_CREDITS);
} }
public function rules() public function rules()

View File

@ -22,7 +22,7 @@ class ProcessInvoicesInBulkRequest extends FormRequest
auth()->guard('contact')->user()->loadMissing(['company']); auth()->guard('contact')->user()->loadMissing(['company']);
return auth()->guard('contact')->user()->company->enabled_modules & PortalComposer::MODULE_INVOICES; return (bool)(auth()->guard('contact')->user()->company->enabled_modules & PortalComposer::MODULE_INVOICES);
} }
public function rules() public function rules()

View File

@ -27,6 +27,6 @@ class ShowInvoiceRequest extends Request
auth()->guard('contact')->user()->loadMissing(['company']); auth()->guard('contact')->user()->loadMissing(['company']);
return (int) auth()->guard('contact')->user()->client_id === (int) $this->invoice->client_id return (int) auth()->guard('contact')->user()->client_id === (int) $this->invoice->client_id
&& auth()->guard('contact')->user()->company->enabled_modules & PortalComposer::MODULE_INVOICES; && (bool)(auth()->guard('contact')->user()->company->enabled_modules & PortalComposer::MODULE_INVOICES);
} }
} }

View File

@ -22,7 +22,7 @@ class ShowInvoicesRequest extends FormRequest
auth()->guard('contact')->user()->loadMissing(['company']); auth()->guard('contact')->user()->loadMissing(['company']);
return auth()->guard('contact')->user()->company->enabled_modules & PortalComposer::MODULE_INVOICES; return (bool)(auth()->guard('contact')->user()->company->enabled_modules & PortalComposer::MODULE_INVOICES);
} }
public function rules() public function rules()

View File

@ -22,7 +22,7 @@ class StorePrePaymentRequest extends FormRequest
$query->without('gateway_tokens', 'documents', 'contacts.company', 'contacts'); // Exclude 'grandchildren' relation of 'client' $query->without('gateway_tokens', 'documents', 'contacts.company', 'contacts'); // Exclude 'grandchildren' relation of 'client'
}]); }]);
return auth()->guard('contact')->user()->company->enabled_modules & PortalComposer::MODULE_INVOICES; return (bool)(auth()->guard('contact')->user()->company->enabled_modules & PortalComposer::MODULE_INVOICES);
} }
/** /**

View File

@ -24,7 +24,7 @@ class ProcessQuotesInBulkRequest extends FormRequest
auth()->guard('contact')->user()->loadMissing(['company']); auth()->guard('contact')->user()->loadMissing(['company']);
return auth()->guard('contact')->user()->company->enabled_modules & PortalComposer::MODULE_QUOTES; return (bool)(auth()->guard('contact')->user()->company->enabled_modules & PortalComposer::MODULE_QUOTES);
} }
public function rules() public function rules()

View File

@ -22,8 +22,8 @@ class ShowQuoteRequest extends FormRequest
auth()->guard('contact')->user()->loadMissing(['company']); auth()->guard('contact')->user()->loadMissing(['company']);
return auth()->guard('contact')->user()->client->id === (int) $this->quote->client_id return (int)auth()->guard('contact')->user()->client->id === (int) $this->quote->client_id
&& auth()->guard('contact')->user()->company->enabled_modules & PortalComposer::MODULE_QUOTES; && (bool)(auth()->guard('contact')->user()->company->enabled_modules & PortalComposer::MODULE_QUOTES);
} }
public function rules() public function rules()

View File

@ -22,7 +22,7 @@ class ShowQuotesRequest extends FormRequest
auth()->guard('contact')->user()->loadMissing(['company']); auth()->guard('contact')->user()->loadMissing(['company']);
return auth()->guard('contact')->user()->company->enabled_modules & PortalComposer::MODULE_QUOTES; return (bool)(auth()->guard('contact')->user()->company->enabled_modules & PortalComposer::MODULE_QUOTES);
} }
public function rules() public function rules()

View File

@ -12,7 +12,7 @@ class RequestCancellationRequest extends FormRequest
auth()->guard('contact')->user()->loadMissing(['company']); auth()->guard('contact')->user()->loadMissing(['company']);
return auth()->guard('contact')->user()->company->enabled_modules & PortalComposer::MODULE_RECURRING_INVOICES; return (bool)(auth()->guard('contact')->user()->company->enabled_modules & PortalComposer::MODULE_RECURRING_INVOICES);
} }
public function rules() public function rules()

View File

@ -20,8 +20,8 @@ class ShowRecurringInvoiceRequest extends Request
{ {
auth()->guard('contact')->user()->loadMissing(['company']); auth()->guard('contact')->user()->loadMissing(['company']);
return auth()->guard('contact')->user()->client->id == $this->recurring_invoice->client_id return (int)auth()->guard('contact')->user()->client->id == $this->recurring_invoice->client_id
&& auth()->guard('contact')->user()->company->enabled_modules & PortalComposer::MODULE_RECURRING_INVOICES; && (bool)(auth()->guard('contact')->user()->company->enabled_modules & PortalComposer::MODULE_RECURRING_INVOICES);
} }
public function rules() public function rules()

View File

@ -21,7 +21,7 @@ class ShowRecurringInvoicesRequest extends FormRequest
{ {
auth()->guard('contact')->user()->loadMissing(['company']); auth()->guard('contact')->user()->loadMissing(['company']);
return auth()->guard('contact')->user()->company->enabled_modules & PortalComposer::MODULE_RECURRING_INVOICES; return (bool)(auth()->guard('contact')->user()->company->enabled_modules & PortalComposer::MODULE_RECURRING_INVOICES);
} }
public function rules() public function rules()

View File

@ -50,21 +50,25 @@ class IbpRequest extends FormRequest
public function getCompany(): ?Company public function getCompany(): ?Company
{ {
/** @var \App\Models\Company */
return Company::where('company_key', $this->company_key)->first(); return Company::where('company_key', $this->company_key)->first();
} }
public function getCompanyGateway(): ?CompanyGateway public function getCompanyGateway(): ?CompanyGateway
{ {
/** @var \App\Models\CompanyGateway */
return CompanyGateway::find($this->decodePrimaryKey($this->company_gateway_id)); return CompanyGateway::find($this->decodePrimaryKey($this->company_gateway_id));
} }
public function getPaymentHash(): ?PaymentHash public function getPaymentHash(): ?PaymentHash
{ {
/** @var \App\Models\PaymentHash */
return PaymentHash::where('hash', $this->hash)->firstOrFail(); return PaymentHash::where('hash', $this->hash)->firstOrFail();
} }
public function getClient(): ?Client public function getClient(): ?Client
{ {
/** @var \App\Models\Client */
return Client::find($this->getPaymentHash()->data->client_id); return Client::find($this->getPaymentHash()->data->client_id);
} }
} }

View File

@ -47,21 +47,25 @@ class Mollie3dsRequest extends FormRequest
public function getCompany(): ?Company public function getCompany(): ?Company
{ {
/** @var \App\Models\Company */
return Company::where('company_key', $this->company_key)->first(); return Company::where('company_key', $this->company_key)->first();
} }
public function getCompanyGateway(): ?CompanyGateway public function getCompanyGateway(): ?CompanyGateway
{ {
/** @var \App\Models\CompanyGateway */
return CompanyGateway::find($this->decodePrimaryKey($this->company_gateway_id)); return CompanyGateway::find($this->decodePrimaryKey($this->company_gateway_id));
} }
public function getPaymentHash(): ?PaymentHash public function getPaymentHash(): ?PaymentHash
{ {
/** @var \App\Models\PaymentHash */
return PaymentHash::where('hash', $this->hash)->first(); return PaymentHash::where('hash', $this->hash)->first();
} }
public function getClient(): ?Client public function getClient(): ?Client
{ {
/** @var \App\Models\Client */
return Client::find($this->getPaymentHash()->data->client_id); return Client::find($this->getPaymentHash()->data->client_id);
} }

View File

@ -81,7 +81,7 @@ class RefundPaymentRequest extends Request
public function payment(): ?\App\Models\Payment public function payment(): ?\App\Models\Payment
{ {
$input = $this->all(); $input = $this->all();
/** @var \App\Models\Payment */
return Payment::whereId($input['id'])->first(); return Payment::find($input['id']);
} }
} }

View File

@ -45,19 +45,21 @@ class PaymentWebhookRequest extends Request
{ {
MultiDB::findAndSetDbByCompanyKey($this->company_key); MultiDB::findAndSetDbByCompanyKey($this->company_key);
/** @var \App\Models\CompanyGateway */
return CompanyGateway::withTrashed()->find($this->decodePrimaryKey($this->company_gateway_id)); return CompanyGateway::withTrashed()->find($this->decodePrimaryKey($this->company_gateway_id));
} }
/** /**
* Resolve payment hash. * Resolve payment hash.
* *
* @return null|\App\Models\PaymentHash * @return null|bool|\App\Models\PaymentHash
*/ */
public function getPaymentHash() public function getPaymentHash()
{ {
if ($this->query('hash')) { if ($this->query('hash')) {
MultiDB::findAndSetDbByCompanyKey($this->company_key); MultiDB::findAndSetDbByCompanyKey($this->company_key);
/** @var \App\Models\PaymentHash */
return PaymentHash::where('hash', $this->query('hash'))->firstOrFail(); return PaymentHash::where('hash', $this->query('hash'))->firstOrFail();
} }
@ -72,7 +74,8 @@ class PaymentWebhookRequest extends Request
public function getCompany(): ?Company public function getCompany(): ?Company
{ {
MultiDB::findAndSetDbByCompanyKey($this->company_key); MultiDB::findAndSetDbByCompanyKey($this->company_key);
/** @var \App\Models\Company */
return Company::where('company_key', $this->company_key)->firstOrFail(); return Company::where('company_key', $this->company_key)->firstOrFail();
} }
} }

View File

@ -27,9 +27,8 @@ class ShowDocumentRequest extends FormRequest
public function authorize() public function authorize()
{ {
/** @var \App\Models\VendorContact auth()->guard('vendor')->user() */ return (bool) (auth()->guard('vendor')->user()->vendor_id == $this->document->documentable_id
return auth()->guard('vendor')->user()->vendor_id == $this->document->documentable_id || $this->document->company_id == auth()->guard('vendor')->user()->company_id);
|| $this->document->company_id == auth()->guard('vendor')->user()->company_id;
} }
/** /**

View File

@ -19,7 +19,7 @@ class ProcessPurchaseOrdersInBulkRequest extends FormRequest
{ {
public function authorize() public function authorize()
{ {
return auth()->guard('vendor')->user()->vendor->company->enabled_modules & PortalComposer::MODULE_PURCHASE_ORDERS; return (bool)(auth()->guard('vendor')->user()->vendor->company->enabled_modules & PortalComposer::MODULE_PURCHASE_ORDERS);
} }
public function rules() public function rules()

View File

@ -24,6 +24,6 @@ class ShowPurchaseOrderRequest extends Request
public function authorize(): bool public function authorize(): bool
{ {
return (int) auth()->guard('vendor')->user()->vendor_id === (int) $this->purchase_order->vendor_id return (int) auth()->guard('vendor')->user()->vendor_id === (int) $this->purchase_order->vendor_id
&& auth()->guard('vendor')->user()->company->enabled_modules & PortalComposer::MODULE_PURCHASE_ORDERS; && (bool)(auth()->guard('vendor')->user()->company->enabled_modules & PortalComposer::MODULE_PURCHASE_ORDERS);
} }
} }

View File

@ -23,6 +23,6 @@ class ShowPurchaseOrdersRequest extends Request
*/ */
public function authorize(): bool public function authorize(): bool
{ {
return auth()->guard('vendor')->user()->company->enabled_modules & PortalComposer::MODULE_PURCHASE_ORDERS; return (bool)(auth()->guard('vendor')->user()->company->enabled_modules & PortalComposer::MODULE_PURCHASE_ORDERS);
} }
} }

View File

@ -44,13 +44,11 @@ class ValidProjectForClient implements Rule
return true; return true;
} }
$project = Project::withTrashed()->find($this->input['project_id']); $project = Project::withTrashed()->find($this->input['project_id']);
if (! $project) { if (! $project) {
$this->message = 'Project not found'; $this->message = 'Project not found';
return; return false;
} }
if(!isset($this->input['client_id'])) { if(!isset($this->input['client_id'])) {

View File

@ -55,6 +55,8 @@ class ProcessBrevoWebhook implements ShouldQueue
'events' => [], 'events' => [],
]; ];
/** @var ?\App\Models\Company $company*/
private ?Company $company = null; private ?Company $company = null;
/** /**
@ -86,11 +88,12 @@ class ProcessBrevoWebhook implements ShouldQueue
* Execute the job. * Execute the job.
* *
* *
* @return void
*/ */
public function handle() public function handle()
{ {
MultiDB::findAndSetDbByCompanyKey($this->request['tags'][0]); MultiDB::findAndSetDbByCompanyKey($this->request['tags'][0]);
/** @phpstan-ignore-next-line */
$this->company = Company::where('company_key', $this->request['tags'][0])->first(); $this->company = Company::where('company_key', $this->request['tags'][0])->first();
$this->invitation = $this->discoverInvitation($this->request['message-id']); $this->invitation = $this->discoverInvitation($this->request['message-id']);

View File

@ -63,7 +63,6 @@ class CompanyExport implements ShouldQueue
/** /**
* Execute the job. * Execute the job.
* *
* @return void
*/ */
public function handle() public function handle()
{ {
@ -468,10 +467,10 @@ class CompanyExport implements ShouldQueue
$x->addItems($this->export_data['subscriptions']); $x->addItems($this->export_data['subscriptions']);
$this->export_data = null; $this->export_data = null;
$this->export_data['system_logs'] = $this->company->system_logs->map(function ($log) { $this->export_data['system_logs'] = $this->company->system_logs->map(function ($log) {
$log->client_id = $this->encodePrimaryKey($log->client_id); $log->client_id = $this->encodePrimaryKey($log->client_id);/** @phpstan-ignore-line */
$log->company_id = $this->encodePrimaryKey($log->company_id); $log->company_id = $this->encodePrimaryKey($log->company_id);/** @phpstan-ignore-line */
return $log; return $log;
})->makeHidden(['id'])->all(); })->makeHidden(['id'])->all();
@ -496,9 +495,9 @@ class CompanyExport implements ShouldQueue
$this->export_data['task_statuses'] = $this->company->task_statuses->map(function ($status) { $this->export_data['task_statuses'] = $this->company->task_statuses->map(function ($status) {
$status->id = $this->encodePrimaryKey($status->id); $status->id = $this->encodePrimaryKey($status->id); /** @phpstan-ignore-line */
$status->user_id = $this->encodePrimaryKey($status->user_id); $status->user_id = $this->encodePrimaryKey($status->user_id);/** @phpstan-ignore-line */
$status->company_id = $this->encodePrimaryKey($status->company_id); $status->company_id = $this->encodePrimaryKey($status->company_id); /** @phpstan-ignore-line */
return $status; return $status;
})->all(); })->all();
@ -511,8 +510,9 @@ class CompanyExport implements ShouldQueue
$this->export_data['tax_rates'] = $this->company->tax_rates->map(function ($rate) { $this->export_data['tax_rates'] = $this->company->tax_rates->map(function ($rate) {
$rate->company_id = $this->encodePrimaryKey($rate->company_id); $rate->company_id = $this->encodePrimaryKey($rate->company_id); /** @phpstan-ignore-line */
$rate->user_id = $this->encodePrimaryKey($rate->user_id); $rate->user_id = $this->encodePrimaryKey($rate->user_id); /** @phpstan-ignore-line */
return $rate; return $rate;
})->makeHidden(['id'])->all(); })->makeHidden(['id'])->all();
@ -550,9 +550,8 @@ class CompanyExport implements ShouldQueue
$this->export_data['webhooks'] = $this->company->webhooks->map(function ($hook) { $this->export_data['webhooks'] = $this->company->webhooks->map(function ($hook) {
$hook->user_id = $this->encodePrimaryKey($hook->user_id); $hook->user_id = $this->encodePrimaryKey($hook->user_id);/** @phpstan-ignore-line */
$hook->company_id = $this->encodePrimaryKey($hook->company_id); $hook->company_id = $this->encodePrimaryKey($hook->company_id);/** @phpstan-ignore-line */
return $hook; return $hook;
})->makeHidden(['id'])->all(); })->makeHidden(['id'])->all();

View File

@ -417,7 +417,7 @@ class CompanyImport implements ShouldQueue
* import to start if there are users > plan number * import to start if there are users > plan number
* due to entity user_id dependencies * due to entity user_id dependencies
* *
* @return bool * @return self
*/ */
private function checkUserCount() private function checkUserCount()
{ {

View File

@ -96,7 +96,7 @@ class UpdateCalculatedFields
}); });
return round(($duration / 60 / 60), 0); return (int) round(($duration / 60 / 60), 0);
} }
} }

View File

@ -48,8 +48,6 @@ class MarkOpened implements ShouldQueue
/** /**
* Execute the job. * Execute the job.
* *
*
* @return void
*/ */
public function handle() public function handle()
{ {

View File

@ -52,7 +52,6 @@ class CreateUbl implements ShouldQueue
/** /**
* Execute the job * Execute the job
* @return ?string
*/ */
public function handle() public function handle()
{ {

View File

@ -669,7 +669,7 @@ class NinjaMailerJob implements ShouldQueue
* just for this request. * just for this request.
*/ */
$token = $user->oauth_user_token->access_token; $token = $user->oauth_user_token->access_token; /** @phpstan-ignore-line */
if (!$token) { if (!$token) {
$this->company->account->gmailCredentialNotification(); $this->company->account->gmailCredentialNotification();

View File

@ -84,9 +84,6 @@ class ProcessMailgunWebhook implements ShouldQueue
/** /**
* Execute the job. * Execute the job.
*
*
* @return void
*/ */
public function handle() public function handle()
{ {

View File

@ -55,8 +55,6 @@ class EmailRefundPayment implements ShouldQueue
/** /**
* Execute the job. * Execute the job.
* *
*
* @return void
*/ */
public function handle() public function handle()
{ {

View File

@ -83,13 +83,11 @@ class ProcessPostmarkWebhook implements ShouldQueue
/** /**
* Execute the job. * Execute the job.
* *
*
* @return void
*/ */
public function handle() public function handle()
{ {
MultiDB::findAndSetDbByCompanyKey($this->request['Tag']); MultiDB::findAndSetDbByCompanyKey($this->request['Tag']);
$this->company = Company::where('company_key', $this->request['Tag'])->first(); $this->company = Company::where('company_key', $this->request['Tag'])->first(); /** @phpstan-ignore-line */
$this->invitation = $this->discoverInvitation($this->request['MessageID']); $this->invitation = $this->discoverInvitation($this->request['MessageID']);

View File

@ -59,7 +59,7 @@ use Laracasts\Presenter\PresentableTrait;
* @property int|null $trial_duration * @property int|null $trial_duration
* @property int $is_onboarding * @property int $is_onboarding
* @property object|null $onboarding * @property object|null $onboarding
* @property int $is_migrated * @property bool $is_migrated
* @property string|null $platform * @property string|null $platform
* @property int|null $hosted_client_count * @property int|null $hosted_client_count
* @property int|null $hosted_company_count * @property int|null $hosted_company_count

View File

@ -110,7 +110,7 @@ use Laracasts\Presenter\PresentableTrait;
* @property string $payment_balance * @property string $payment_balance
* @property mixed $tax_data * @property mixed $tax_data
* @property int $is_tax_exempt * @property int $is_tax_exempt
* @property int $has_valid_vat_number * @property bool $has_valid_vat_number
* @mixin \Eloquent * @mixin \Eloquent
*/ */
class Client extends BaseModel implements HasLocalePreference class Client extends BaseModel implements HasLocalePreference

View File

@ -20,7 +20,7 @@ use Illuminate\Database\Eloquent\Model;
* @property string $hash 32 char length AlphaNum * @property string $hash 32 char length AlphaNum
* @property float $fee_total * @property float $fee_total
* @property int|null $fee_invoice_id * @property int|null $fee_invoice_id
* @property \stdClass $data * @property \stdClass|array $data
* @property int|null $payment_id * @property int|null $payment_id
* @property \Illuminate\Support\Carbon|null $created_at * @property \Illuminate\Support\Carbon|null $created_at
* @property \Illuminate\Support\Carbon|null $updated_at * @property \Illuminate\Support\Carbon|null $updated_at

View File

@ -41,7 +41,7 @@ use Laracasts\Presenter\PresentableTrait;
* @property string|null $due_date * @property string|null $due_date
* @property bool $is_deleted * @property bool $is_deleted
* @property array $line_items * @property array $line_items
* @property object|null $backup * @property object|string|null $backup
* @property string|null $footer * @property string|null $footer
* @property string|null $public_notes * @property string|null $public_notes
* @property string|null $private_notes * @property string|null $private_notes

View File

@ -43,7 +43,7 @@ use Illuminate\Support\Carbon;
* @property bool $is_running * @property bool $is_running
* @property string|null $time_log * @property string|null $time_log
* @property string|null $number * @property string|null $number
* @property string $rate * @property float $rate
* @property bool $invoice_documents * @property bool $invoice_documents
* @property int $is_date_based * @property int $is_date_based
* @property int|null $status_order * @property int|null $status_order

View File

@ -49,7 +49,7 @@ use Laracasts\Presenter\PresentableTrait;
* @property int|null $failed_logins * @property int|null $failed_logins
* @property string|null $referral_code * @property string|null $referral_code
* @property string|null $oauth_user_id * @property string|null $oauth_user_id
* @property object|null $oauth_user_token * @property object|array|null $oauth_user_token
* @property string|null $oauth_provider_id * @property string|null $oauth_provider_id
* @property string|null $google_2fa_secret * @property string|null $google_2fa_secret
* @property string|null $accepted_terms_version * @property string|null $accepted_terms_version
@ -69,7 +69,7 @@ use Laracasts\Presenter\PresentableTrait;
* @property string|null $custom_value4 * @property string|null $custom_value4
* @property int|null $created_at * @property int|null $created_at
* @property int|null $updated_at * @property int|null $updated_at
* @property int|null $deleted_at * @property int|null|Carbon $deleted_at
* @property string|null $oauth_user_refresh_token * @property string|null $oauth_user_refresh_token
* @property string|null $last_confirmed_email_address * @property string|null $last_confirmed_email_address
* @property bool $has_password * @property bool $has_password

View File

@ -30,7 +30,7 @@ use Laracasts\Presenter\PresentableTrait;
* @property int $user_id * @property int $user_id
* @property int|null $assigned_user_id * @property int|null $assigned_user_id
* @property int $company_id * @property int $company_id
* @property string|null $currency_id * @property int|null $currency_id
* @property string|null $name * @property string|null $name
* @property string|null $address1 * @property string|null $address1
* @property string|null $address2 * @property string|null $address2

View File

@ -126,10 +126,10 @@ class TaskRepository extends BaseRepository
$time_log[count($time_log) - 1][1] = time(); $time_log[count($time_log) - 1][1] = time();
$task->is_running = false; $task->is_running = false;
} elseif ($data['action'] == 'offline') { } elseif ($data['action'] == 'offline') {
$task->is_running = $data['is_running'] ? 1 : 0; $task->is_running = $data['is_running'] ? true : false;
} }
} elseif (isset($data['is_running'])) { } elseif (isset($data['is_running'])) {
$task->is_running = $data['is_running'] ? 1 : 0; $task->is_running = $data['is_running'] ? true : false;
} }
$task->calculated_start_date = $this->harvestStartDate($time_log, $task); $task->calculated_start_date = $this->harvestStartDate($time_log, $task);

View File

@ -114,38 +114,40 @@ class PdfMock
case 'invoice': case 'invoice':
/** @var \App\Models\Invoice | \App\Models\Credit | \App\Models\Quote $entity */ /** @var \App\Models\Invoice | \App\Models\Credit | \App\Models\Quote $entity */
$entity = Invoice::factory()->make(); $entity = Invoice::factory()->make();
$entity->client = Client::factory()->make(['settings' => $settings]); $entity->client = Client::factory()->make(['settings' => $settings]); //@phpstan-ignore-line
$entity->client->setRelation('company', $this->company); $entity->client->setRelation('company', $this->company);
$entity->invitation = InvoiceInvitation::factory()->make(); $entity->invitation = InvoiceInvitation::factory()->make(); //@phpstan-ignore-line
break; break;
case 'quote': case 'quote':
/** @var \App\Models\Invoice | \App\Models\Credit | \App\Models\Quote $entity */ /** @var \App\Models\Invoice | \App\Models\Credit | \App\Models\Quote $entity */
$entity = Quote::factory()->make(); $entity = Quote::factory()->make();
$entity->client = Client::factory()->make(['settings' => $settings]); $entity->client = Client::factory()->make(['settings' => $settings]); //@phpstan-ignore-line
$entity->client->setRelation('company', $this->company); $entity->client->setRelation('company', $this->company);
$entity->invitation = QuoteInvitation::factory()->make(); $entity->invitation = QuoteInvitation::factory()->make(); //@phpstan-ignore-line
break; break;
case 'credit': case 'credit':
/** @var \App\Models\Invoice | \App\Models\Credit | \App\Models\Quote $entity */ /** @var \App\Models\Invoice | \App\Models\Credit | \App\Models\Quote $entity */
$entity = Credit::factory()->make(); $entity = Credit::factory()->make();
$entity->client = Client::factory()->make(['settings' => $settings]); $entity->client = Client::factory()->make(['settings' => $settings]); //@phpstan-ignore-line
$entity->client->setRelation('company', $this->company); $entity->client->setRelation('company', $this->company);
$entity->invitation = CreditInvitation::factory()->make(); $entity->invitation = CreditInvitation::factory()->make(); //@phpstan-ignore-line
break; break;
case 'purchase_order': case 'purchase_order':
/** @var \App\Models\PurchaseOrder $entity */ /** @var \App\Models\PurchaseOrder $entity */
$entity = PurchaseOrder::factory()->make(); $entity = PurchaseOrder::factory()->make();
// $entity->client = Client::factory()->make(['settings' => $settings]); // $entity->client = Client::factory()->make(['settings' => $settings]);
$entity->vendor = Vendor::factory()->make(); $entity->vendor = Vendor::factory()->make(); /** @phpstan-ignore-line */
$entity->vendor->setRelation('company', $this->company); $entity->vendor->setRelation('company', $this->company);
$entity->invitation = PurchaseOrderInvitation::factory()->make(); $entity->invitation = PurchaseOrderInvitation::factory()->make();/** @phpstan-ignore-line */
break; break;
case PurchaseOrder::class: case PurchaseOrder::class:
/** @var \App\Models\PurchaseOrder $entity */ /** @var \App\Models\PurchaseOrder $entity */
$entity = PurchaseOrder::factory()->make(); $entity = PurchaseOrder::factory()->make();
$entity->invitation = PurchaseOrderInvitation::factory()->make(); $entity->invitation = PurchaseOrderInvitation::factory()->make();
$entity->vendor = Vendor::factory()->make(); $entity->vendor = Vendor::factory()->make(); /** @phpstan-ignore-line */
$entity->invitation->setRelation('company', $this->company); $entity->invitation->setRelation('company', $this->company);
break; break;
default: default:
@ -184,7 +186,7 @@ class PdfMock
/** /**
* getTaxMap * getTaxMap
* *
* @return \Illuminate\Http\Response|\Illuminate\Http\JsonResponse * @return \Illuminate\Support\Collection
*/ */
private function getTaxMap(): \Illuminate\Support\Collection private function getTaxMap(): \Illuminate\Support\Collection
{ {

View File

@ -171,7 +171,7 @@ class PaymentLinkService
} }
if (!$this->subscription->trial_enabled) { if (!$this->subscription->trial_enabled) {
return new \Exception("Trials are disabled for this product"); throw new \Exception("Trials are disabled for this product");
} }
//create recurring invoice with start date = trial_duration + 1 day //create recurring invoice with start date = trial_duration + 1 day

View File

@ -57,9 +57,8 @@ class ZipTax implements TaxProviderInterface
* callApi * callApi
* *
* @param array $parameters * @param array $parameters
* @return Response| \Illuminate\Http\JsonResponse
*/ */
private function callApi(array $parameters): Response private function callApi(array $parameters)
{ {
return Http::retry(3, 1000)->withHeaders([])->get($this->endpoint, $parameters); return Http::retry(3, 1000)->withHeaders([])->get($this->endpoint, $parameters);

View File

@ -54,7 +54,7 @@ class ProjectTransformer extends EntityTransformer
return null; return null;
} }
public function includeClient(Project $project): \League\Fractal\Resource\Item public function includeClient(Project $project): ?\League\Fractal\Resource\Item
{ {
if (!$project->client) { if (!$project->client) {

View File

@ -51,7 +51,7 @@ class HtmlEngine
/** @var \App\Models\Company $company */ /** @var \App\Models\Company $company */
public $company; public $company;
/** @var \App\DataMapper\CompanySettings $settings **/ /** @var \App\DataMapper\CompanySettings|\stdClass $settings **/
public $settings; public $settings;
public $entity_calc; public $entity_calc;