From 9aec0b45ac0a4bd093fa66e64a8e7f0f08ed73f7 Mon Sep 17 00:00:00 2001 From: objecttothis Date: Fri, 10 Feb 2023 22:07:52 +0400 Subject: [PATCH] Fix incorrect function calls - Fixed return type in function call to make it nullable. - Added form helper to autoload since it's used in all the views. - Fix typo in memory stored OSPOS settings reference. --- app/Config/Autoload.php | 4 +++- app/Helpers/locale_helper.php | 6 +++--- app/Libraries/Receiving_lib.php | 4 ++-- app/Views/receivings/receiving.php | 4 ++-- 4 files changed, 10 insertions(+), 8 deletions(-) diff --git a/app/Config/Autoload.php b/app/Config/Autoload.php index d329f9d05..e56972940 100644 --- a/app/Config/Autoload.php +++ b/app/Config/Autoload.php @@ -202,5 +202,7 @@ class Autoload extends AutoloadConfig * @var string[] * @phpstan-var list */ - public $helpers = []; + public $helpers = [ + 'form' + ]; } diff --git a/app/Helpers/locale_helper.php b/app/Helpers/locale_helper.php index 09d139294..de1f39882 100644 --- a/app/Helpers/locale_helper.php +++ b/app/Helpers/locale_helper.php @@ -381,8 +381,8 @@ function to_decimals(float $number, string $decimals = NULL, int $type = NumberF } $fmt = new NumberFormatter(config('OSPOS')->settings['number_locale'], $type); - $fmt->setAttribute(NumberFormatter::MIN_FRACTION_DIGITS, empty($decimals) ? DEFAULT_PRECISION : config('OSPOS')->settings['$decimals']); - $fmt->setAttribute(NumberFormatter::MAX_FRACTION_DIGITS, empty($decimals) ? DEFAULT_PRECISION : config('OSPOS')->settings['$decimals']); + $fmt->setAttribute(NumberFormatter::MIN_FRACTION_DIGITS, empty($decimals) ? DEFAULT_PRECISION : config('OSPOS')->settings[$decimals]); + $fmt->setAttribute(NumberFormatter::MAX_FRACTION_DIGITS, empty($decimals) ? DEFAULT_PRECISION : config('OSPOS')->settings[$decimals]); if(empty(config('OSPOS')->settings['thousands_separator'])) { @@ -592,4 +592,4 @@ function valid_date(string $date): bool //TODO: need a better name for $date. P function valid_decimal(string $decimal): bool //TODO: need a better name for $decimal. Perhaps $candidate. Also the function name would be better as is_valid_decimal() { return (preg_match('/^(\d*\.)?\d+$/', $decimal) === 1); -} \ No newline at end of file +} diff --git a/app/Libraries/Receiving_lib.php b/app/Libraries/Receiving_lib.php index 025c532c2..e605b66b6 100644 --- a/app/Libraries/Receiving_lib.php +++ b/app/Libraries/Receiving_lib.php @@ -127,7 +127,7 @@ class Receiving_lib $this->session->remove('recv_comment'); } - public function get_reference(): string + public function get_reference(): ?string { return $this->session->get('recv_reference'); } @@ -423,4 +423,4 @@ class Receiving_lib return $total; } -} \ No newline at end of file +} diff --git a/app/Views/receivings/receiving.php b/app/Views/receivings/receiving.php index ef0771312..515c1df47 100644 --- a/app/Views/receivings/receiving.php +++ b/app/Views/receivings/receiving.php @@ -16,7 +16,7 @@ * @var array $payment_options */ ?> - + - 'mode_form', 'class' => 'form-horizontal panel panel-default']) ?> + 'mode_form', 'class' => 'form-horizontal panel panel-default']) ?>