diff --git a/.github/workflows/test-phpunit.yml b/.github/workflows/test-phpunit.yml index c660b937e04..d965765bce7 100644 --- a/.github/workflows/test-phpunit.yml +++ b/.github/workflows/test-phpunit.yml @@ -15,10 +15,28 @@ jobs: strategy: fail-fast: false matrix: - php: [ '8.1', '8.0', '7.4', '7.3', '7.2', '7.1', '7.0', '5.6', '5.5', '5.4'] + php: [ '8.2', '8.1', '8.0', '7.4', '7.3', '7.2', '7.1', '7.0', '5.6', '5.5', '5.4'] DB: [ 'pdo/mysql', 'pdo/pgsql', 'pdo/sqlite', 'mysqli', 'pgsql', 'sqlite' ] compiler: [ default ] include: + - php: '8.2' + DB: 'pdo/mysql' + compiler: jit + - php: '8.2' + DB: 'pdo/pgsql' + compiler: jit + - php: '8.2' + DB: 'pdo/sqlite' + compiler: jit + - php: '8.2' + DB: 'mysqli' + compiler: jit + - php: '8.2' + DB: 'pgsql' + compiler: jit + - php: '8.2' + DB: 'sqlite' + compiler: jit - php: '8.1' DB: 'pdo/mysql' compiler: jit diff --git a/system/core/Controller.php b/system/core/Controller.php index aeccd60ee4c..3713ae06308 100644 --- a/system/core/Controller.php +++ b/system/core/Controller.php @@ -50,6 +50,7 @@ * @author EllisLab Dev Team * @link https://codeigniter.com/userguide3/general/controllers.html */ +#[AllowDynamicProperties] class CI_Controller { /** diff --git a/system/core/Loader.php b/system/core/Loader.php index 648b7cfc7c2..32f3873262d 100644 --- a/system/core/Loader.php +++ b/system/core/Loader.php @@ -49,6 +49,7 @@ * @author EllisLab Dev Team * @link https://codeigniter.com/userguide3/libraries/loader.html */ +#[AllowDynamicProperties] class CI_Loader { // All these are set automatically. Don't mess with them. diff --git a/system/core/Router.php b/system/core/Router.php index e0fb922f1a6..8302dc06006 100644 --- a/system/core/Router.php +++ b/system/core/Router.php @@ -58,6 +58,13 @@ class CI_Router { */ public $config; + /** + * CI_URI class object + * + * @var object + */ + public $uri; + /** * List of routes * diff --git a/system/core/URI.php b/system/core/URI.php index 1e948588354..95b9c926c96 100644 --- a/system/core/URI.php +++ b/system/core/URI.php @@ -51,6 +51,13 @@ */ class CI_URI { + /** + * CI_Config instance + * + * @var CI_Config + */ + public $config; + /** * List of cached URI segments * diff --git a/system/database/DB_driver.php b/system/database/DB_driver.php index de03a418567..3c28c8ac535 100644 --- a/system/database/DB_driver.php +++ b/system/database/DB_driver.php @@ -51,6 +51,7 @@ * @author EllisLab Dev Team * @link https://codeigniter.com/userguide3/database/ */ +#[AllowDynamicProperties] abstract class CI_DB_driver { /** @@ -338,6 +339,20 @@ abstract class CI_DB_driver { */ protected $_like_escape_chr = '!'; + /** + * RegExp used to escape identifiers + * + * @var array + */ + protected $_preg_escape_char = array(); + + /** + * RegExp used to get operators + * + * @var string[] + */ + protected $_preg_operators = array(); + /** * ORDER BY random keyword * @@ -1353,13 +1368,11 @@ public function escape_identifiers($item, $split = TRUE) return $item; } - static $preg_ec; - - if (empty($preg_ec)) + if (empty($this->_preg_escape_char)) { if (is_array($this->_escape_char)) { - $preg_ec = array( + $this->_preg_escape_char = array( preg_quote($this->_escape_char[0]), preg_quote($this->_escape_char[1]), $this->_escape_char[0], @@ -1368,8 +1381,8 @@ public function escape_identifiers($item, $split = TRUE) } else { - $preg_ec[0] = $preg_ec[1] = preg_quote($this->_escape_char); - $preg_ec[2] = $preg_ec[3] = $this->_escape_char; + $this->_preg_escape_char[0] = $this->_preg_escape_char[1] = preg_quote($this->_escape_char); + $this->_preg_escape_char[2] = $this->_preg_escape_char[3] = $this->_escape_char; } } @@ -1377,13 +1390,21 @@ public function escape_identifiers($item, $split = TRUE) { if (strpos($item, '.'.$id) !== FALSE) { - return preg_replace('#'.$preg_ec[0].'?([^'.$preg_ec[1].'\.]+)'.$preg_ec[1].'?\.#i', $preg_ec[2].'$1'.$preg_ec[3].'.', $item); + return preg_replace( + '#'.$this->_preg_escape_char[0].'?([^'.$this->_preg_escape_char[1].'\.]+)'.$this->_preg_escape_char[1].'?\.#i', + $this->_preg_escape_char[2].'$1'.$this->_preg_escape_char[3].'.', + $item + ); } } $dot = ($split !== FALSE) ? '\.' : ''; - return preg_replace('#'.$preg_ec[0].'?([^'.$preg_ec[1].$dot.']+)'.$preg_ec[1].'?(\.)?#i', $preg_ec[2].'$1'.$preg_ec[3].'$2', $item); + return preg_replace( + '#'.$this->_preg_escape_char[0].'?([^'.$this->_preg_escape_char[1].$dot.']+)'.$this->_preg_escape_char[1].'?(\.)?#i', + $this->_preg_escape_char[2].'$1'.$this->_preg_escape_char[3].'$2', + $item + ); } // -------------------------------------------------------------------- @@ -1502,14 +1523,12 @@ protected function _has_operator($str) */ protected function _get_operator($str) { - static $_operators; - - if (empty($_operators)) + if (empty($this->_preg_operators)) { $_les = ($this->_like_escape_str !== '') ? '\s+'.preg_quote(trim(sprintf($this->_like_escape_str, $this->_like_escape_chr)), '/') : ''; - $_operators = array( + $this->_preg_operators = array( '\s*(?:<|>|!)?=\s*', // =, <=, >=, != '\s*<>?\s*', // <, <> '\s*>\s*', // > @@ -1527,7 +1546,7 @@ protected function _get_operator($str) } - return preg_match('/'.implode('|', $_operators).'/i', $str, $match) + return preg_match('/'.implode('|', $this->_preg_operators).'/i', $str, $match) ? $match[0] : FALSE; } diff --git a/system/database/DB_query_builder.php b/system/database/DB_query_builder.php index de6aa04fc08..ebbb22307eb 100644 --- a/system/database/DB_query_builder.php +++ b/system/database/DB_query_builder.php @@ -271,6 +271,13 @@ abstract class CI_DB_query_builder extends CI_DB_driver { */ protected $qb_cache_no_escape = array(); + /** + * Strings that determine if a string represents a literal value or a field name + * + * @var string[] + */ + protected $is_literal_str = array(); + // -------------------------------------------------------------------- /** @@ -2787,15 +2794,13 @@ protected function _is_literal($str) return TRUE; } - static $_str; - - if (empty($_str)) + if (empty($this->is_literal_str)) { - $_str = ($this->_escape_char !== '"') + $this->is_literal_str = ($this->_escape_char !== '"') ? array('"', "'") : array("'"); } - return in_array($str[0], $_str, TRUE); + return in_array($str[0], $this->is_literal_str, TRUE); } // -------------------------------------------------------------------- diff --git a/system/database/drivers/postgre/postgre_forge.php b/system/database/drivers/postgre/postgre_forge.php index 2857fd51727..291a705baf4 100644 --- a/system/database/drivers/postgre/postgre_forge.php +++ b/system/database/drivers/postgre/postgre_forge.php @@ -87,7 +87,7 @@ public function __construct(&$db) if (version_compare($this->db->version(), '9.0', '>')) { - $this->create_table_if = 'CREATE TABLE IF NOT EXISTS'; + $this->_create_table_if = 'CREATE TABLE IF NOT EXISTS'; } } diff --git a/system/libraries/Driver.php b/system/libraries/Driver.php index 84f0b6c3e76..23f4d23f3d0 100644 --- a/system/libraries/Driver.php +++ b/system/libraries/Driver.php @@ -50,6 +50,7 @@ * @author EllisLab Dev Team * @link */ +#[AllowDynamicProperties] class CI_Driver_Library { /** diff --git a/system/libraries/Image_lib.php b/system/libraries/Image_lib.php index 4e5fc7be6fc..9067eff692f 100644 --- a/system/libraries/Image_lib.php +++ b/system/libraries/Image_lib.php @@ -85,6 +85,14 @@ class CI_Image_lib { */ public $new_image = ''; + + /** + * Path to destination image + * + * @var string + */ + public $dest_image = ''; + /** * Image width * diff --git a/system/libraries/Table.php b/system/libraries/Table.php index a033ced212c..60b9fddcf84 100644 --- a/system/libraries/Table.php +++ b/system/libraries/Table.php @@ -490,12 +490,12 @@ protected function _compile_template() return; } - $this->temp = $this->_default_template(); + $temp = $this->_default_template(); foreach (array('table_open', 'thead_open', 'thead_close', 'heading_row_start', 'heading_row_end', 'heading_cell_start', 'heading_cell_end', 'tbody_open', 'tbody_close', 'row_start', 'row_end', 'cell_start', 'cell_end', 'row_alt_start', 'row_alt_end', 'cell_alt_start', 'cell_alt_end', 'table_close') as $val) { if ( ! isset($this->template[$val])) { - $this->template[$val] = $this->temp[$val]; + $this->template[$val] = $temp[$val]; } } } diff --git a/tests/codeigniter/core/Loader_test.php b/tests/codeigniter/core/Loader_test.php index df9c9f44b68..b14b7178019 100644 --- a/tests/codeigniter/core/Loader_test.php +++ b/tests/codeigniter/core/Loader_test.php @@ -125,7 +125,7 @@ public function test_library_config() // Create library in VFS $lib = 'unit_test_config_lib'; $class = 'CI_'.ucfirst($lib); - $content = 'config = $params; } }'; + $content = "config = $params; } }'; $this->ci_vfs_create(ucfirst($lib), $content, $this->ci_base_root, 'libraries'); // Create config file diff --git a/tests/codeigniter/libraries/Upload_test.php b/tests/codeigniter/libraries/Upload_test.php index 74a7d2c22df..b660d0ec85f 100644 --- a/tests/codeigniter/libraries/Upload_test.php +++ b/tests/codeigniter/libraries/Upload_test.php @@ -59,9 +59,6 @@ function test_data() $data = array( 'file_name' => 'hello.txt', 'file_type' => 'text/plain', - 'file_path' => '/tmp/', - 'full_path' => '/tmp/hello.txt', - 'raw_name' => 'hello', 'orig_name' => 'hello.txt', 'client_name' => '', 'file_ext' => '.txt', @@ -80,6 +77,10 @@ function test_data() $this->upload->{$k} = $v; } + $data['file_path'] = '/tmp/'; + $data['full_path'] = '/tmp/hello.txt'; + $data['raw_name'] = 'hello'; + $this->assertEquals('hello.txt', $this->upload->data('file_name')); $this->assertEquals($data, $this->upload->data()); } diff --git a/tests/mocks/ci_testcase.php b/tests/mocks/ci_testcase.php index 3ebb6b822e9..e755bd0be5b 100644 --- a/tests/mocks/ci_testcase.php +++ b/tests/mocks/ci_testcase.php @@ -1,5 +1,6 @@