Skip to content

Commit 78c7fe9

Browse files
committed
refactor: towards PHP 8.4 and PHP 8.5
Signed-off-by: otengkwame <developerkwame@gmail.com>
1 parent ad3f20e commit 78c7fe9

4 files changed

Lines changed: 11 additions & 18 deletions

File tree

CodeIgniter/Framework/libraries/Email.php

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@ class CI_Email
301301
/**
302302
* Recipients
303303
*
304-
* @var string[]
304+
* @var string|array
305305
*/
306306
protected $_recipients = [];
307307

@@ -397,9 +397,6 @@ public function __construct(array $config = [])
397397
{
398398
$this->charset = config_item('charset');
399399
$this->initialize($config);
400-
$this->_safe_mode = (! is_php('5.4') && ini_get('safe_mode'));
401-
402-
isset(self::$func_overload) or self::$func_overload = (! is_php('8.0') && extension_loaded('mbstring') && @ini_get('mbstring.func_overload'));
403400

404401
log_message('info', 'Email Class Initialized');
405402
}
@@ -2000,9 +1997,8 @@ protected function _smtp_connect()
20001997
*
20011998
* We want the negotiation, so we'll force it below ...
20021999
*/
2003-
$method = is_php('5.6')
2004-
? STREAM_CRYPTO_METHOD_TLSv1_0_CLIENT | STREAM_CRYPTO_METHOD_TLSv1_1_CLIENT | STREAM_CRYPTO_METHOD_TLSv1_2_CLIENT
2005-
: STREAM_CRYPTO_METHOD_TLS_CLIENT;
2000+
$method = STREAM_CRYPTO_METHOD_TLSv1_0_CLIENT | STREAM_CRYPTO_METHOD_TLSv1_1_CLIENT | STREAM_CRYPTO_METHOD_TLSv1_2_CLIENT;
2001+
20062002
$crypto = stream_socket_enable_crypto($this->_smtp_connect, true, $method);
20072003

20082004
if ($crypto !== true) {

CodeIgniter/Framework/libraries/Form_validation.php

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2219,17 +2219,10 @@ public function valid_url($str)
22192219

22202220
// Apparently, FILTER_VALIDATE_URL doesn't reject digit-only names for some reason ...
22212221
// See https://github.com/bcit-ci/CodeIgniter/issues/5755
2222-
if (ctype_digit($str)) {
2222+
if (ctype_digit((string) $str)) {
22232223
return false;
22242224
}
22252225

2226-
// PHP 7 accepts IPv6 addresses within square brackets as hostnames,
2227-
// but it appears that the PR that came in with https://bugs.php.net/bug.php?id=68039
2228-
// was never merged into a PHP 5 branch ... https://3v4l.org/8PsSN
2229-
if (preg_match('/^\[([^\]]+)\]/', $str, $matches) && !is_php('7') && filter_var($matches[1], FILTER_VALIDATE_IP, FILTER_FLAG_IPV6) !== false) {
2230-
$str = 'ipv6.host' . substr($str, strlen($matches[1]) + 2);
2231-
}
2232-
22332226
return (filter_var('http://' . $str, FILTER_VALIDATE_URL) !== false);
22342227
}
22352228

CodeIgniter/Framework/libraries/Image_lib.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1308,7 +1308,7 @@ public function text_watermark()
13081308
*
13091309
* @param string
13101310
* @param string
1311-
* @return resource
1311+
* @return resource|bool
13121312
*/
13131313
public function image_create_gd($path = '', $image_type = '')
13141314
{
@@ -1403,6 +1403,10 @@ public function image_save_gd($resource)
14031403

14041404
return false;
14051405
}
1406+
if (! @imagewebp($resource, $this->full_dst_path)) {
1407+
$this->set_error('imglib_save_failed');
1408+
return false;
1409+
}
14061410
break;
14071411
case IMAGETYPE_AVIF:
14081412
if (! function_exists('imageavif')) {
@@ -1670,7 +1674,7 @@ public function gd_version()
16701674
/**
16711675
* Set error message
16721676
*
1673-
* @param string
1677+
* @param string|array
16741678
* @return void
16751679
*/
16761680
public function set_error($msg)

CodeIgniter/Framework/libraries/Pagination.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -498,7 +498,7 @@ public function create_links()
498498
$this->uri_segment = count($this->CI->uri->segment_array());
499499
}
500500

501-
$this->cur_page = $this->CI->uri->segment($this->uri_segment);
501+
$this->cur_page = $this->CI->uri->segment($this->uri_segment, '');
502502

503503
// Remove any specified prefix/suffix from the segment.
504504
if ($this->prefix !== '' or $this->suffix !== '') {

0 commit comments

Comments
 (0)