Skip to content
This repository was archived by the owner on Nov 18, 2025. It is now read-only.

Commit b007dc7

Browse files
committed
✨ add PHP8.0 and PHP8.1 quick support
Signed-off-by: otengkwame <[email protected]>
1 parent 948d980 commit b007dc7

File tree

6 files changed

+117
-78
lines changed

6 files changed

+117
-78
lines changed

framework/core/Output.php

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -299,28 +299,27 @@ public function get_content_type()
299299
*/
300300
public function get_header($header)
301301
{
302-
// Combine headers already sent with our batched headers
303-
$headers = [];
304-
foreach ($this->headers as $value)
305-
{
306-
$headers[] = $value[0];
307-
}
302+
// We only need [x][0] from our multi-dimensional array
303+
$header_lines = array_map(function ($headers) {
304+
return array_shift($headers);
305+
}, $this->headers);
306+
308307
$headers = array_merge(
309-
$headers,
308+
$header_lines,
310309
headers_list()
311310
);
312311

313-
if (empty($headers) OR empty($header))
312+
if (empty($headers) OR empty($header))
314313
{
315314
return NULL;
316315
}
317316

318317
// Count backwards, in order to get the last matching header
319-
for ($c = count($headers) - 1; $c > -1; $c--)
318+
for ($c = count($headers) - 1; $c > -1; $c--)
320319
{
321-
if (strncasecmp($header, $headers[$c], $l = self::strlen($header)) === 0)
320+
if (strncasecmp($header, $headers[$c], $l = self::strlen($header)) === 0)
322321
{
323-
return trim(self::substr($headers[$c], $l+1));
322+
return trim(self::substr($headers[$c], $l + 1));
324323
}
325324
}
326325

framework/database/drivers/pdo/subdrivers/pdo_pgsql_forge.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,13 @@ class CI_DB_pdo_pgsql_forge extends CI_DB_pdo_forge {
5353
*/
5454
protected $_drop_table_if = 'DROP TABLE IF EXISTS';
5555

56+
/**
57+
* CREATE TABLE IF statement
58+
*
59+
* @var string
60+
*/
61+
protected $_create_table_if = 'CREATE TABLE IF NOT EXISTS';
62+
5663
/**
5764
* UNSIGNED support
5865
*

framework/libraries/Session/drivers/Session_database_driver.php

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ public function __construct(&$params)
126126
* @param string $name Session cookie name, unused
127127
* @return bool
128128
*/
129-
public function open($save_path, $name)
129+
public function open(string $save_path, string $name): bool
130130
{
131131
if (empty($this->_db->conn_id) && ! $this->_db->db_connect())
132132
{
@@ -148,7 +148,8 @@ public function open($save_path, $name)
148148
* @param string $session_id Session ID
149149
* @return string Serialized session data
150150
*/
151-
public function read($session_id)
151+
#[\ReturnTypeWillChange]
152+
public function read(string $session_id)
152153
{
153154
if ($this->_get_lock($session_id) === FALSE)
154155
{
@@ -204,7 +205,7 @@ public function read($session_id)
204205
* @param string $session_data Serialized session data
205206
* @return bool
206207
*/
207-
public function write($session_id, $session_data)
208+
public function write(string $session_id, string $session_data): bool
208209
{
209210
// Prevent previous QB calls from messing with our queries
210211
$this->_db->reset_query();
@@ -276,7 +277,7 @@ public function write($session_id, $session_data)
276277
*
277278
* @return bool
278279
*/
279-
public function close()
280+
public function close(): bool
280281
{
281282
return ($this->_lock && ! $this->_release_lock())
282283
? $this->_failure
@@ -293,7 +294,7 @@ public function close()
293294
* @param string $session_id Session ID
294295
* @return bool
295296
*/
296-
public function destroy($session_id)
297+
public function destroy(string $session_id): bool
297298
{
298299
if ($this->_lock)
299300
{
@@ -331,7 +332,8 @@ public function destroy($session_id)
331332
* @param int $maxlifetime Maximum lifetime of sessions
332333
* @return bool
333334
*/
334-
public function gc($maxlifetime)
335+
#[\ReturnTypeWillChange]
336+
public function gc(int $maxlifetime)
335337
{
336338
// Prevent previous QB calls from messing with our queries
337339
$this->_db->reset_query();

framework/libraries/Session/drivers/Session_files_driver.php

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ public function __construct(&$params)
129129
* @param string $name Session cookie name
130130
* @return bool
131131
*/
132-
public function open($save_path, $name)
132+
public function open(string $save_path, string $name): bool
133133
{
134134
if ( ! is_dir($save_path))
135135
{
@@ -165,7 +165,8 @@ public function open($save_path, $name)
165165
* @param string $session_id Session ID
166166
* @return string Serialized session data
167167
*/
168-
public function read($session_id)
168+
#[\ReturnTypeWillChange]
169+
public function read(string $session_id)
169170
{
170171
// This might seem weird, but PHP 5.6 introduces session_reset(),
171172
// which re-reads session data
@@ -213,7 +214,7 @@ public function read($session_id)
213214
}
214215

215216
$session_data = '';
216-
for ($read = 0, $length = filesize($this->_file_path.$session_id); $read < $length; $read += self::strlen($buffer))
217+
for ($read = 0, $length = filesize($this->_file_path.$session_id); $read < $length; $read += self::strlen($buffer = ''))
217218
{
218219
if (($buffer = fread($this->_file_handle, $length - $read)) === FALSE)
219220
{
@@ -238,7 +239,7 @@ public function read($session_id)
238239
* @param string $session_data Serialized session data
239240
* @return bool
240241
*/
241-
public function write($session_id, $session_data)
242+
public function write(string $session_id, string $session_data): bool
242243
{
243244
// If the two IDs don't match, we have a session_regenerate_id() call
244245
// and we need to close the old handle and open a new one
@@ -295,7 +296,7 @@ public function write($session_id, $session_data)
295296
*
296297
* @return bool
297298
*/
298-
public function close()
299+
public function close(): bool
299300
{
300301
if (is_resource($this->_file_handle))
301302
{
@@ -318,7 +319,7 @@ public function close()
318319
* @param string $session_id Session ID
319320
* @return bool
320321
*/
321-
public function destroy($session_id)
322+
public function destroy(string $session_id): bool
322323
{
323324
if ($this->close() === $this->_success)
324325
{
@@ -359,7 +360,8 @@ public function destroy($session_id)
359360
* @param int $maxlifetime Maximum lifetime of sessions
360361
* @return bool
361362
*/
362-
public function gc($maxlifetime)
363+
#[\ReturnTypeWillChange]
364+
public function gc(int $maxlifetime)
363365
{
364366
if ( ! is_dir($this->_config['save_path']) OR ($directory = opendir($this->_config['save_path'])) === FALSE)
365367
{

framework/libraries/Session/drivers/Session_memcached_driver.php

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ public function __construct(&$params)
103103
* @param string $name Session cookie name, unused
104104
* @return bool
105105
*/
106-
public function open($save_path, $name)
106+
public function open(string $save_path, string $name): bool
107107
{
108108
$this->_memcached = new Memcached();
109109
$this->_memcached->setOption(Memcached::OPT_BINARY_PROTOCOL, TRUE); // required for touch() usage
@@ -160,7 +160,8 @@ public function open($save_path, $name)
160160
* @param string $session_id Session ID
161161
* @return string Serialized session data
162162
*/
163-
public function read($session_id)
163+
#[\ReturnTypeWillChange]
164+
public function read(string $session_id)
164165
{
165166
if (isset($this->_memcached) && $this->_get_lock($session_id))
166167
{
@@ -186,7 +187,7 @@ public function read($session_id)
186187
* @param string $session_data Serialized session data
187188
* @return bool
188189
*/
189-
public function write($session_id, $session_data)
190+
public function write(string $session_id, string $session_data): bool
190191
{
191192
if ( ! isset($this->_memcached, $this->_lock_key))
192193
{
@@ -237,7 +238,7 @@ public function write($session_id, $session_data)
237238
*
238239
* @return bool
239240
*/
240-
public function close()
241+
public function close(): bool
241242
{
242243
if (isset($this->_memcached))
243244
{
@@ -264,7 +265,7 @@ public function close()
264265
* @param string $session_id Session ID
265266
* @return bool
266267
*/
267-
public function destroy($session_id)
268+
public function destroy(string $session_id): bool
268269
{
269270
if (isset($this->_memcached, $this->_lock_key))
270271
{
@@ -286,7 +287,8 @@ public function destroy($session_id)
286287
* @param int $maxlifetime Maximum lifetime of sessions
287288
* @return bool
288289
*/
289-
public function gc($maxlifetime)
290+
#[\ReturnTypeWillChange]
291+
public function gc(int $maxlifetime)
290292
{
291293
// Not necessary, Memcached takes care of that.
292294
return $this->_success;

0 commit comments

Comments
 (0)