Compatibility changes

- Removed `mixed` function return type from some functions for backward compatibility with php 7.4
- Refactored string concatination for readability.
- Added TODO for later
- Corrected PHPdocs
- Removed unneeded TODO
- Refactored function names with mixed snake and pascal case names
This commit is contained in:
objecttothis
2023-12-06 08:57:36 +04:00
committed by jekkos
parent ba9bcd7786
commit cc58cecff0
11 changed files with 26 additions and 19 deletions

View File

@@ -94,7 +94,7 @@ class Receivings extends Secure_Controller
/**
* @return void
*/
public function change_mode(): void
public function postChangeMode(): void
{
$stock_destination = $this->request->getPost('stock_destination', FILTER_SANITIZE_FULL_SPECIAL_CHARS);
$stock_source = $this->request->getPost('stock_source', FILTER_SANITIZE_NUMBER_INT);

View File

@@ -213,9 +213,12 @@ class Sales extends Secure_Controller
}
/**
* Changes the sale mode in the register to carry out different types of sales
*
* @return void
* @noinspection PhpUnused
*/
public function postChange_mode(): void
public function postChangeMode(): void
{
$mode = $this->request->getPost('mode', FILTER_SANITIZE_FULL_SPECIAL_CHARS);
$this->sale_lib->set_mode($mode);
@@ -259,7 +262,9 @@ class Sales extends Secure_Controller
if(!$stock_location || $stock_location == $this->sale_lib->get_sale_location())
{
//TODO: This has an empty body. What to do here?
//TODO: The code below was removed in 2017 by @steveireland. We either need to reinstate some of it or remove this entire if block but we can't leave an empty if block
// $dinner_table = $this->request->getPost('dinner_table');
// $this->sale_lib->set_dinner_table($dinner_table);
}
elseif($this->stock_location->is_allowed_location($stock_location, 'sales'))
{

View File

@@ -45,8 +45,11 @@ class Migration_database_optimizations extends Migration
$builder = $this->db->table('attribute_values');
$builder->delete(['attribute_id' => $attribute_value['attribute_id']]);
$query = 'SELECT links.definition_id, links.item_id, links.attribute_id, defs.definition_type FROM ospos_attribute_links links JOIN ospos_attribute_definitions defs ON defs.definition_id = links.definition_id where attribute_id = ';
$query .= $attribute_value['attribute_id'];
//TODO: This should be converted to using CI4 QueryBuilder
$query = 'SELECT links.definition_id, links.item_id, links.attribute_id, defs.definition_type'
. ' FROM ospos_attribute_links links'
. ' JOIN ospos_attribute_definitions defs ON defs.definition_id = links.definition_id'
. ' WHERE attribute_id = ' . $attribute_value['attribute_id'];
$attribute_links = $this->db->query($query);
$builder = $this->db->table('attribute_links');

View File

@@ -482,7 +482,7 @@ function parse_tax(string $number)
* @param int|null $decimals
* @return false|float|int|mixed|string
*/
function parse_decimals(string $number, int $decimals = null): mixed
function parse_decimals(string $number, int $decimals = null)
{
if(empty($number))
{

View File

@@ -61,7 +61,7 @@ class Barcode_lib
/**
* @param array $item
* @param array $barcode_config
* @return object|Code128|Code39|Ean13|Ean8
* @return object
*/
public static function barcode_instance(array $item, array $barcode_config): object
{
@@ -84,7 +84,7 @@ class Barcode_lib
/**
* @param string $barcode_type
* @return Code128|Code39|Ean13|Ean8
* @return object
*/
private static function get_barcode_instance(string $barcode_type = 'Code128'): object
{

View File

@@ -66,9 +66,7 @@ abstract class BarcodeBase
/**
* Get the data
*
* @param mixed data - (int or string) Data to be encoded
* @return instance of \emberlabs\Barcode\BarcodeInterface
* @throws OverflowException
* @return BarcodeInterface
*/
public function getData()
{

View File

@@ -653,7 +653,7 @@ class Attribute extends Model
/**
* @param int $item_id
* @param int|null $definition_id
* @return object|stdClass|null
* @return object|null
*/
public function get_link_value(int $item_id, ?int $definition_id): ?object
{
@@ -712,7 +712,7 @@ class Attribute extends Model
/**
* @param int $item_id
* @param int $definition_id
* @return object|array|stdClass|null
* @return object|null
*/
public function get_attribute_value(int $item_id, int $definition_id): ?object
{

View File

@@ -77,15 +77,16 @@ class Inventory extends Model
}
/**
* @throws ReflectionException
* @param int $item_id ID number for the item to have quantity reset.
* @return bool|int|string The row id of the inventory table on insert or false on failure
*/
public function reset_quantity(int $item_id): bool
public function reset_quantity(int $item_id)
{
$inventory_sums = $this->get_inventory_sum($item_id);
foreach($inventory_sums as $inventory_sum)
{
if($inventory_sum['sum'] > 0)
{//TODO: Reflection Exception
{
$employee = model(Employee::class);
return $this->insert([

View File

@@ -282,7 +282,7 @@ class Receiving extends Model
/**
* @param int $receiving_id
* @return object|array|\stdClass|null
* @return object
*/
public function get_supplier(int $receiving_id): object
{

View File

@@ -40,7 +40,7 @@ if (isset($success))
<!-- Top register controls -->
<?= form_open(esc("$controller_name/change_mode"), ['id' => 'mode_form', 'class' => 'form-horizontal panel panel-default']) ?>
<?= form_open(esc("$controller_name/changeMode"), ['id' => 'mode_form', 'class' => 'form-horizontal panel panel-default']) ?>
<div class="panel-body form-group">
<ul>
<li class="pull-left first_li">

View File

@@ -64,7 +64,7 @@ if(isset($success))
<div id="register_wrapper">
<!-- Top register controls -->
<?= form_open(esc("$controller_name/change_mode"), ['id' => 'mode_form', 'class' => 'form-horizontal panel panel-default']) ?>
<?= form_open(esc("$controller_name/changeMode"), ['id' => 'mode_form', 'class' => 'form-horizontal panel panel-default']) ?>
<div class="panel-body form-group">
<ul>
<li class="pull-left first_li">