Add PHP8.2 support to the application

This commit is contained in:
Alex Tselegidis 2023-01-26 09:17:45 +01:00
parent ed9b2e8c55
commit abcc46db94
10 changed files with 117 additions and 10 deletions

View file

@ -77,6 +77,8 @@ class EA_Controller extends CI_Controller {
$this->configure_language();
$this->load_common_html_vars();
$this->load_common_script_vars();
rate_limit($this->input->ip_address());
@ -97,6 +99,20 @@ class EA_Controller extends CI_Controller {
$this->lang->load('translations');
}
/**
* Load common script vars for all requests.
*/
private function load_common_html_vars()
{
html_vars([
'base_url' => config('base_url'),
'index_page' => config('index_page'),
'available_languages' => config('available_languages'),
'language' => $this->lang->language,
'csrf_token' => $this->security->get_csrf_hash(),
]);
}
/**
* Load common script vars for all requests.
*/

View file

@ -55,7 +55,7 @@ class EA_Input extends CI_Input {
/** @var EA_Controller $CI */
$CI = &get_instance();
if (strpos($CI->input->get_request_header('Content-Type'), 'application/json') === false)
if (strpos((string)$CI->input->get_request_header('Content-Type'), 'application/json') === false)
{
return NULL;
}

View file

@ -1,6 +1,6 @@
<script>
window.lang = (function () {
const lang = <?= json_encode($this->lang->language) ?>;
const lang = <?= json_encode(html_vars('language')) ?>;
return (key) => {
if (!key) {

View file

@ -65,6 +65,23 @@ class CI_Controller {
*/
public $load;
/**
* Dynamic Class Props
*
* @var array
*/
public $props = [];
public function __get(string $name): mixed
{
return $this->props[$name] ?? NULL;
}
public function __set(string $name, mixed $value): void
{
$this->props[$name] = $value;
}
/**
* Class constructor
*
@ -79,7 +96,7 @@ class CI_Controller {
// so that CI can run as one big super object.
foreach (is_loaded() as $var => $class)
{
$this->$var =& load_class($class);
$this->$var = load_class($class);
}
$this->load =& load_class('Loader', 'core');

View file

@ -50,6 +50,23 @@ defined('BASEPATH') OR exit('No direct script access allowed');
*/
class CI_Loader {
/**
* Dynamic Class Props
*
* @var array
*/
public $props = [];
public function __get(string $name): mixed
{
return $this->props[$name] ?? NULL;
}
public function __set(string $name, mixed $value): void
{
$this->props[$name] = $value;
}
// All these are set automatically. Don't mess with them.
/**
* Nesting level of the output buffering mechanism
@ -397,7 +414,7 @@ class CI_Loader {
$CI->db = '';
// Load the DB class
$CI->db =& DB($params, $query_builder);
$CI->db = DB($params, $query_builder);
return $this;
}
@ -929,7 +946,7 @@ class CI_Loader {
{
if ( ! isset($this->$_ci_key))
{
$this->$_ci_key =& $_ci_CI->$_ci_key;
$this->$_ci_key = $_ci_CI->$_ci_key;
}
}

View file

@ -49,6 +49,8 @@ defined('BASEPATH') OR exit('No direct script access allowed');
* @link https://codeigniter.com/userguide3/general/routing.html
*/
class CI_Router {
public $uri;
/**
* CI_Config class object

View file

@ -50,6 +50,23 @@ defined('BASEPATH') OR exit('No direct script access allowed');
*/
class CI_URI {
/**
* Dynamic Class Props
*
* @var array
*/
public $props = [];
public function __get(string $name): mixed
{
return $this->props[$name] ?? NULL;
}
public function __set(string $name, mixed $value): void
{
$this->props[$name] = $value;
}
/**
* List of cached URI segments
*

View file

@ -52,6 +52,23 @@ defined('BASEPATH') OR exit('No direct script access allowed');
*/
abstract class CI_DB_driver {
/**
* Dynamic Class Props
*
* @var array
*/
public $props = [];
public function __get(string $name): mixed
{
return $this->props[$name] ?? NULL;
}
public function __set(string $name, mixed $value): void
{
$this->props[$name] = $value;
}
/**
* Data Source Name / Connect string
*

View file

@ -248,6 +248,8 @@ class CI_Cache extends CI_Driver_Library {
if ( ! isset($support, $support[$driver]))
{
$this->load_driver($driver);
$support[$driver] = $this->{$driver}->is_supported();
}

View file

@ -65,6 +65,25 @@ class CI_Driver_Library {
*/
protected $lib_name;
/**
* Dynamic Class Props
*
* @var array
*/
public $props = [];
public function __get(string $name): mixed
{
// $this->load_driver($name);
return $this->props[$name] ?? NULL;
}
public function __set(string $name, mixed $value): void
{
$this->props[$name] = $value;
}
/**
* Get magic method
*
@ -74,11 +93,11 @@ class CI_Driver_Library {
* @param string Child class name
* @return object Child class
*/
public function __get($child)
{
// Try to load the driver
return $this->load_driver($child);
}
// public function __get($child)
// {
// // Try to load the driver
// return $this->load_driver($child);
// }
/**
* Load driver