Skip to content

Commit cb7d878

Browse files
committed
Inspection problems
- Corrected incorrect CSS property used in invoice.php view. - Corrected unknown CSS properties used in register.php view. - Used shorthand CSS in debug.css - Corrected indentation in barcode_sheet.php view. - Corrected indentation in footer.php view. - Corrected indentation in invoice_email.php view. - Replaced obsolete attributes with CSS style attributes in barcode_sheet.php - Replaced obsolete attribute in error_exception.php - Replaced obsolete attribute in invoice_email.php - Replaced obsolete attribute in quote_email.php - Replaced obsolete attributes in work_order_email.php - Fixed indentation in system_info.php - Replaced <strong> tag outside <p> tags, which isn't allowed, with style attributes. - Simplified js return logic and indentation fixes in tax_categories.php - Simplified js return logic in tax_codes.php - Simplified js return logic in tax_jurisdictions.php - Removed unnecessary labels in manage views. - Rewrite JavaScript function and PHP to be more readable in bar.php, hbar.php, line.php and pie.php - Added type declarations, return types and an import to app\Config\Services - Updated Attribute.php parameter type - Updated Receiving_lib.php parameter type - Updated Receivings.php parameter types and updated PHPdocs - Updated tabular_helper.php parameter types and updated PHPdocs - Added type declarations and corrected PHPdocs in url_helper.php - Added return types to functions Signed-off-by: objec <objecttothis@gmail.com>
1 parent ca7384a commit cb7d878

33 files changed

Lines changed: 763 additions & 771 deletions

app/Config/Mimes.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -486,9 +486,10 @@ class Mimes
486486
/**
487487
* Attempts to determine the best mime type for the given file extension.
488488
*
489-
* @return string|null The mime type found, or none if unable to determine.
489+
* @param string $extension
490+
* @return array|string|null The mime type found, or none if unable to determine.
490491
*/
491-
public static function guessTypeFromExtension(string $extension)
492+
public static function guessTypeFromExtension(string $extension): array|string|null
492493
{
493494
$extension = trim(strtolower($extension), '. ');
494495

@@ -506,7 +507,7 @@ public static function guessTypeFromExtension(string $extension)
506507
*
507508
* @return string|null The extension determined, or null if unable to match.
508509
*/
509-
public static function guessExtensionFromType(string $type, ?string $proposedExtension = null)
510+
public static function guessExtensionFromType(string $type, ?string $proposedExtension = null): ?string
510511
{
511512
$type = trim(strtolower($type), '. ');
512513

@@ -522,7 +523,7 @@ public static function guessExtensionFromType(string $type, ?string $proposedExt
522523
}
523524

524525
// Reverse check the mime type list if no extension was proposed.
525-
// This search is order sensitive!
526+
// This search is order-sensitive!
526527
foreach (static::$mimes as $ext => $types) {
527528
if (in_array($type, (array) $types, true)) {
528529
return $ext;

app/Config/Services.php

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace Config;
44

5+
use App\Libraries\MY_Language;
56
use Locale;
67
use HTMLPurifier;
78
use HTMLPurifier_Config;
@@ -38,9 +39,11 @@ class Services extends BaseService
3839
/**
3940
* Responsible for loading the language string translations.
4041
*
42+
* @param string|null $locale
43+
* @param bool $getShared
4144
* @return MY_Language
4245
*/
43-
public static function language(?string $locale = null, bool $getShared = true)
46+
public static function language(?string $locale = null, bool $getShared = true): MY_Language
4447
{
4548
if ($getShared) {
4649
return static::getSharedInstance('language', $locale)->setLocale($locale);
@@ -55,12 +58,12 @@ public static function language(?string $locale = null, bool $getShared = true)
5558
// Use '?:' for empty string check
5659
$locale = $locale ?: $requestLocale;
5760

58-
return new \App\Libraries\MY_Language($locale);
61+
return new MY_Language($locale);
5962
}
6063

61-
private static $htmlPurifier;
64+
private static HTMLPurifier $htmlPurifier;
6265

63-
public static function htmlPurifier($getShared = true)
66+
public static function htmlPurifier($getShared = true): object
6467
{
6568
if ($getShared) {
6669
return static::getSharedInstance('htmlPurifier');

app/Controllers/BaseController.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,12 @@ abstract class BaseController extends Controller
2828
// protected $session;
2929

3030
/**
31+
* @param RequestInterface $request
32+
* @param ResponseInterface $response
33+
* @param LoggerInterface $logger
3134
* @return void
3235
*/
33-
public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger)
36+
public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger): void
3437
{
3538
// Load here all helpers you want to be available in your controllers that extend BaseController.
3639
// Caution: Do not put the this below the parent::initController() call below.

app/Controllers/Home.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,12 @@ public function getLogout(): RedirectResponse
3535
}
3636

3737
/**
38-
* Load "change employee password" form
38+
* Load the "change employee password" form
3939
*
40+
* @param int $employeeId
4041
* @return ResponseInterface|string
41-
* @noinspection PhpUnused
4242
*/
43-
public function getChangePassword(int $employeeId = NEW_ENTRY)
43+
public function getChangePassword(int $employeeId = NEW_ENTRY): ResponseInterface|string
4444
{
4545
$loggedInEmployee = $this->employee->get_logged_in_employee_info();
4646
$currentPersonId = $loggedInEmployee->person_id;

app/Controllers/Receivings.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -190,11 +190,11 @@ public function postAdd(): string
190190
/**
191191
* Edit line item in current receiving. Used in app/Views/receivings/receiving.php
192192
*
193-
* @param string|int|null $item_id
193+
* @param int|string|null $item_id
194194
* @return string
195195
* @noinspection PhpUnused
196196
*/
197-
public function postEditItem($item_id): string
197+
public function postEditItem(int|string|null $item_id): string
198198
{
199199
$data = [];
200200

@@ -242,7 +242,7 @@ public function getEdit($receiving_id): string
242242
}
243243

244244
$receiving_info = $this->receiving->get_info($receiving_id)->getRowArray();
245-
245+
246246
$current_employee_id = $this->employee->get_logged_in_employee_info()->person_id;
247247
$can_assign_employee = $this->employee->has_grant('employees', $current_employee_id);
248248

@@ -280,8 +280,10 @@ public function getDeleteItem($item_number): string
280280
}
281281

282282
/**
283-
* @throws ReflectionException
283+
* @param int $receiving_id
284+
* @param bool $update_inventory
284285
* @return ResponseInterface
286+
* @throws ReflectionException
285287
*/
286288
public function postDelete(int $receiving_id = -1, bool $update_inventory = true): ResponseInterface
287289
{

app/Helpers/tabular_helper.php

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
use App\Models\Item_taxes;
66
use App\Models\Tax_category;
77
use CodeIgniter\Database\ResultInterface;
8+
use CodeIgniter\HTTP\IncomingRequest;
89
use CodeIgniter\Session\Session;
910
use Config\OSPOS;
1011
use Config\Services;
@@ -577,8 +578,8 @@ function item_kit_headers(): array
577578
['item_kit_number' => lang('Item_kits.item_kit_number')],
578579
['name' => lang('Item_kits.name')],
579580
['description' => lang('Item_kits.description')],
580-
['total_cost_price' => lang('Items.cost_price'), 'sortable' => FALSE],
581-
['total_unit_price' => lang('Items.unit_price'), 'sortable' => FALSE]
581+
['total_cost_price' => lang('Items.cost_price'), 'sortable' => false],
582+
['total_unit_price' => lang('Items.unit_price'), 'sortable' => false]
582583
];
583584
}
584585

@@ -654,7 +655,7 @@ function expand_attribute_values(array $definition_names, array $row): array
654655
foreach ($definition_names as $definition_id => $definitionInfo) {
655656
if (isset($indexed_values[$definition_id])) {
656657
$raw_value = $indexed_values[$definition_id];
657-
658+
658659
// Format DECIMAL attributes according to locale
659660
if (is_array($definitionInfo) && isset($definitionInfo['type']) && $definitionInfo['type'] === DECIMAL) {
660661
$attribute_values["$definition_id"] = to_decimals($raw_value);
@@ -742,7 +743,7 @@ function get_expense_category_manage_table_headers(): string
742743
}
743744

744745
/**
745-
* Gets the html data row for the expenses category
746+
* Gets the html data row for the expense category
746747
*/
747748
function get_expense_category_data_row(object $expense_category): array
748749
{
@@ -841,7 +842,7 @@ function get_expenses_data_last_row(object $expense): array
841842
}
842843

843844
/**
844-
* Get the expenses payments summary
845+
* Get the expense payments summary
845846
*/
846847
function get_expenses_manage_payments_summary(array $payments, ResultInterface $expenses): string // TODO: $expenses is passed but never used.
847848
{
@@ -933,22 +934,22 @@ function get_controller(): string
933934
}
934935

935936
/**
936-
* Restores filter values from URL query string.
937-
*
938-
* @param CodeIgniter\HTTP\IncomingRequest $request The request object
937+
* Restores filter values from the URL query string.
938+
*
939+
* @param IncomingRequest $request The request object
939940
* @return array Array with 'start_date', 'end_date', and 'selected_filters' keys
940941
*/
941-
function restoreTableFilters($request): array
942+
function restoreTableFilters(IncomingRequest $request): array
942943
{
943944
$startDate = $request->getGet('start_date', FILTER_SANITIZE_FULL_SPECIAL_CHARS);
944945
$endDate = $request->getGet('end_date', FILTER_SANITIZE_FULL_SPECIAL_CHARS);
945946
$urlFilters = $request->getGet('filters', FILTER_SANITIZE_FULL_SPECIAL_CHARS);
946-
947+
947948
return array_filter([
948949
'start_date' => $startDate ?: null,
949950
'end_date' => $endDate ?: null,
950951
'selected_filters' => $urlFilters ?? []
951-
], function($value) {
952+
], function ($value) {
952953
return $value !== null && $value !== [];
953954
});
954955
}

app/Helpers/url_helper.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* @param string $data
88
* @return string
99
*/
10-
function base64url_encode($data)
10+
function base64url_encode(string $data): string
1111
{
1212
return rtrim(strtr(base64_encode($data), '+/', '-_'), '=');
1313
}
@@ -20,12 +20,12 @@ function base64url_encode($data)
2020
* @param string $data
2121
* @return string|false
2222
*/
23-
function base64url_decode($data)
23+
function base64url_decode(string $data): false|string
2424
{
2525
$remainder = strlen($data) % 4;
2626
if ($remainder) {
2727
$data .= str_repeat('=', 4 - $remainder);
2828
}
2929
return base64_decode(strtr($data, '-_', '+/'));
3030
}
31-
}
31+
}

app/Libraries/MY_Language.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@
66

77
class MY_Language extends Language
88
{
9-
10-
public function getLine(string $line, array $args = [])
9+
public function getLine(string $line, array $args = []): array|string
1110
{
1211
// If no file is given, just parse the line
1312
if (! str_contains($line, '.')) {
@@ -20,7 +19,7 @@ public function getLine(string $line, array $args = [])
2019

2120
$output = $this->getTranslationOutput($this->locale, $file, $parsedLine);
2221

23-
if ($output === NULL && strpos($this->locale, '-')) {
22+
if ($output === null && strpos($this->locale, '-')) {
2423
[$locale] = explode('-', $this->locale, 2);
2524

2625
[$file, $parsedLine] = $this->parseLine($line, $locale);
@@ -29,7 +28,7 @@ public function getLine(string $line, array $args = [])
2928
}
3029

3130
// If still not found, try English
32-
if ($output === NULL || $output === "") {
31+
if ($output === null || $output === "") {
3332
[$file, $parsedLine] = $this->parseLine($line, 'en');
3433

3534
$output = $this->getTranslationOutput('en', $file, $parsedLine);

app/Libraries/Receiving_lib.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -394,7 +394,7 @@ public function edit_item($line, string $description, string $serialnumber, floa
394394
/**
395395
* @param $line int|string The item_number or item_id of the item to be removed from the receiving.
396396
*/
397-
public function delete_item($line): void
397+
public function delete_item(int|string $line): void
398398
{
399399
$items = $this->get_cart();
400400
unset($items[$line]);

app/Models/Attribute.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -575,10 +575,10 @@ public function saveDefinition(array &$definitionData, int $definitionId = NO_DE
575575

576576
/**
577577
* @param string $definition_name
578-
* @param $definition_type
578+
* @param string|bool $definition_type
579579
* @return array
580580
*/
581-
public function get_definition_by_name(string $definition_name, $definition_type = false): array
581+
public function get_definition_by_name(string $definition_name, string|bool $definition_type = false): array
582582
{
583583
$builder = $this->db->table('attribute_definitions');
584584
$builder->where('definition_name', $definition_name);

0 commit comments

Comments
 (0)