From b37045acca61b79c8e14ed62d6866f6c0ea98c6d Mon Sep 17 00:00:00 2001 From: Deon George Date: Thu, 22 May 2025 18:37:04 +1000 Subject: [PATCH] PHP deprecation fixes, assigning null arguments in methods --- app/Http/Controllers/InvoiceController.php | 2 +- app/Http/Controllers/SupplierController.php | 2 +- app/Mail/CancelRequest.php | 2 +- app/Mail/ChangeRequest.php | 2 +- app/Models/Account.php | 14 +++++++------- app/Models/Product.php | 4 ++-- app/Models/Service.php | 2 +- app/Models/Supplier.php | 2 +- app/Models/Supplier/Broadband.php | 2 +- app/Models/User.php | 2 +- app/Traits/ScopeAccountUserAuthorised.php | 10 +++++----- 11 files changed, 22 insertions(+), 22 deletions(-) diff --git a/app/Http/Controllers/InvoiceController.php b/app/Http/Controllers/InvoiceController.php index ba2ead7..5b4e0f6 100644 --- a/app/Http/Controllers/InvoiceController.php +++ b/app/Http/Controllers/InvoiceController.php @@ -54,7 +54,7 @@ class InvoiceController extends Controller * @param string|null $code * @return View */ - public function view(Invoice $o,string $code=NULL): View + public function view(Invoice $o,?string $code=NULL): View { if ($code) { try { diff --git a/app/Http/Controllers/SupplierController.php b/app/Http/Controllers/SupplierController.php index bad5b77..9100cb2 100644 --- a/app/Http/Controllers/SupplierController.php +++ b/app/Http/Controllers/SupplierController.php @@ -159,7 +159,7 @@ class SupplierController extends Controller * @param int|null $id * @return \Illuminate\Contracts\Foundation\Application|\Illuminate\Contracts\View\Factory|\Illuminate\Contracts\View\View */ - public function product_view_type(Request $request,string $type,int $id=NULL) + public function product_view_type(Request $request,string $type,?int $id=NULL) { $o = $id ? Supplier::offeringTypeClass($type)->findOrFail($id) : NULL; diff --git a/app/Mail/CancelRequest.php b/app/Mail/CancelRequest.php index 46daea8..d97bdc0 100644 --- a/app/Mail/CancelRequest.php +++ b/app/Mail/CancelRequest.php @@ -23,7 +23,7 @@ class CancelRequest extends Mailable * @param Service $o * @param string|NULL $notes */ - public function __construct(Service $o,string $notes=NULL) + public function __construct(Service $o,?string $notes=NULL) { $this->service = $o; $this->notes = $notes; diff --git a/app/Mail/ChangeRequest.php b/app/Mail/ChangeRequest.php index 44f5bd1..0646c63 100644 --- a/app/Mail/ChangeRequest.php +++ b/app/Mail/ChangeRequest.php @@ -23,7 +23,7 @@ class ChangeRequest extends Mailable * @param Service $o * @param string|NULL $notes */ - public function __construct(Service $o,string $notes=NULL) + public function __construct(Service $o,?string $notes=NULL) { $this->service = $o; $this->notes = $notes; diff --git a/app/Models/Account.php b/app/Models/Account.php index 68274d1..d073a4e 100644 --- a/app/Models/Account.php +++ b/app/Models/Account.php @@ -44,7 +44,7 @@ class Account extends Model * @param Collection|NULL $invoices * @return Collection */ - public static function InvoicesCredit(Collection $invoices=NULL): Collection + public static function InvoicesCredit(?Collection $invoices=NULL): Collection { return (new self) ->invoiceSummaryCredit($invoices,TRUE) @@ -57,7 +57,7 @@ class Account extends Model * @param Collection|NULL $invoices * @return Collection */ - public static function InvoicesDue(Collection $invoices=NULL): Collection + public static function InvoicesDue(?Collection $invoices=NULL): Collection { return (new self) ->invoiceSummaryDue($invoices,TRUE) @@ -251,7 +251,7 @@ class Account extends Model /* METHODS */ - public function invoice_next(Carbon $date=NULL): Collection + public function invoice_next(?Carbon $date=NULL): Collection { $svs = $this ->services_active @@ -307,7 +307,7 @@ class Account extends Model * @param bool $all * @return Builder */ - public function invoiceSummary(Collection $invoices=NULL,bool $all=FALSE): Builder + public function invoiceSummary(?Collection $invoices=NULL,bool $all=FALSE): Builder { return (new Invoice) ->select([ @@ -355,19 +355,19 @@ class Account extends Model ->with(['account']); } - public function invoiceSummaryDue(Collection $invoices=NULL,bool $all=FALSE): Builder + public function invoiceSummaryDue(?Collection $invoices=NULL,bool $all=FALSE): Builder { return $this->invoiceSummary($invoices,$all) ->havingRaw('ROUND(CAST(SUM(item_total)-COALESCE(invoices.discount_amt,0)-SUM(payments) AS NUMERIC),2) > 0'); } - public function invoiceSummaryCredit(Collection $invoices=NULL,bool $all=FALSE): Builder + public function invoiceSummaryCredit(?Collection $invoices=NULL,bool $all=FALSE): Builder { return $this->invoiceSummary($invoices,$all) ->havingRaw('ROUND(CAST(SUM(item_total)-COALESCE(invoices.discount_amt,0)-SUM(payments) AS NUMERIC),2) < 0'); } - public function invoiceSummaryPast(Collection $invoices=NULL,bool $all=FALSE): Builder + public function invoiceSummaryPast(?Collection $invoices=NULL,bool $all=FALSE): Builder { return $this->invoiceSummary($invoices,$all) ->join('payment_items',['payment_items.invoice_id'=>'invoices.id']) diff --git a/app/Models/Product.php b/app/Models/Product.php index 4af1008..f0abe6f 100644 --- a/app/Models/Product.php +++ b/app/Models/Product.php @@ -206,7 +206,7 @@ class Product extends Model * @param Group|NULL $go * @return float */ - private function _charge(string $type,int $timeperiod=NULL,Group $go=NULL): float + private function _charge(string $type,?int $timeperiod=NULL,?Group $go=NULL): float { // We'll cache this for performance static $default = NULL; @@ -296,7 +296,7 @@ class Product extends Model * @param Group|null $go * @return float */ - public function min_charge(int $timeperiod=NULL,Group $go=NULL): float + public function min_charge(?int $timeperiod=NULL,?Group $go=NULL): float { return $this->setup_charge($timeperiod,$go) + $this->base_charge($timeperiod,$go)*Invoice::billing_change($this->billing_interval,$this->type->billing_interval)*$this->contract_term; diff --git a/app/Models/Service.php b/app/Models/Service.php index 70bf2af..7192824 100644 --- a/app/Models/Service.php +++ b/app/Models/Service.php @@ -1028,7 +1028,7 @@ class Service extends Model * @return Collection * @throws Exception */ - public function next_invoice_items(Carbon $billdate=NULL): Collection + public function next_invoice_items(?Carbon $billdate=NULL): Collection { if ($this->is_cancelled || (! $this->is_billed)) return collect(); diff --git a/app/Models/Supplier.php b/app/Models/Supplier.php index 22a157c..0ad13f2 100644 --- a/app/Models/Supplier.php +++ b/app/Models/Supplier.php @@ -40,7 +40,7 @@ class Supplier extends Model * @param Supplier|null $so * @return Collection */ - public static function offeringTypes(self $so=NULL): Collection + public static function offeringTypes(?self $so=NULL): Collection { $result = collect(); diff --git a/app/Models/Supplier/Broadband.php b/app/Models/Supplier/Broadband.php index fa06c02..ac71e74 100644 --- a/app/Models/Supplier/Broadband.php +++ b/app/Models/Supplier/Broadband.php @@ -73,7 +73,7 @@ class Broadband extends Type * @param bool $ceil Round the numbers to integers * @return array|string */ - public function allowance(Collection $config=NULL,array $data=[],bool $ceil=TRUE) + public function allowance(?Collection $config=NULL,array $data=[],bool $ceil=TRUE) { $map = collect(self::traffic_map); $merge = collect(self::traffic_merge); diff --git a/app/Models/User.php b/app/Models/User.php index 1a53f40..4df8e2b 100644 --- a/app/Models/User.php +++ b/app/Models/User.php @@ -240,7 +240,7 @@ class User extends Authenticatable * @param User|null $user * @return bool */ - public function isAdmin(User $user=NULL): bool + public function isAdmin(?User $user=NULL): bool { return $user->exists && $this->isReseller() diff --git a/app/Traits/ScopeAccountUserAuthorised.php b/app/Traits/ScopeAccountUserAuthorised.php index 5a964e3..5c69452 100644 --- a/app/Traits/ScopeAccountUserAuthorised.php +++ b/app/Traits/ScopeAccountUserAuthorised.php @@ -1,21 +1,21 @@