Skip to content

Commit 6fb934b

Browse files
committed
Fix strtolower and strtoupper
1 parent 671fb76 commit 6fb934b

23 files changed

+56
-56
lines changed

system/core/CodeIgniter.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@
246246
* in it's constructor, but it's _not_ class-specific.
247247
*
248248
*/
249-
$charset = strtoupper(config_item('charset'));
249+
$charset = strtoupper((string) config_item('charset'));
250250
ini_set('default_charset', $charset);
251251

252252
if (extension_loaded('mbstring'))

system/core/Common.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ function &is_loaded($class = '')
267267

268268
if ($class !== '')
269269
{
270-
$_is_loaded[strtolower($class)] = $class;
270+
$_is_loaded[strtolower((string) $class)] = $class;
271271
}
272272

273273
return $_is_loaded;
@@ -404,15 +404,15 @@ function &get_mimes()
404404
*/
405405
function is_https()
406406
{
407-
if (! empty($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) !== 'off') {
407+
if (! empty($_SERVER['HTTPS']) && strtolower((string) $_SERVER['HTTPS']) !== 'off') {
408408
return TRUE;
409409
}
410410

411-
if (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && strtolower($_SERVER['HTTP_X_FORWARDED_PROTO']) === 'https') {
411+
if (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && strtolower((string) $_SERVER['HTTP_X_FORWARDED_PROTO']) === 'https') {
412412
return TRUE;
413413
}
414414

415-
if (! empty($_SERVER['HTTP_FRONT_END_HTTPS']) && strtolower($_SERVER['HTTP_FRONT_END_HTTPS']) !== 'off') {
415+
if (! empty($_SERVER['HTTP_FRONT_END_HTTPS']) && strtolower((string) $_SERVER['HTTP_FRONT_END_HTTPS']) !== 'off') {
416416
return TRUE;
417417
}
418418

system/core/Input.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -410,7 +410,7 @@ public function set_cookie($name, $value = '', $expire = '', $domain = '', $path
410410
isset($samesite) OR $samesite = config_item('cookie_samesite');
411411
if (isset($samesite))
412412
{
413-
$samesite = ucfirst(strtolower($samesite));
413+
$samesite = ucfirst(strtolower((string) $samesite));
414414
in_array($samesite, array('Lax', 'Strict', 'None'), TRUE) OR $samesite = 'Lax';
415415
}
416416
else
@@ -598,7 +598,7 @@ public function ip_address()
598598
*/
599599
public function valid_ip($ip, $which = '')
600600
{
601-
switch (strtolower($which))
601+
switch (strtolower((string) $which))
602602
{
603603
case 'ipv4':
604604
$which = FILTER_FLAG_IPV4;
@@ -817,7 +817,7 @@ public function request_headers($xss_clean = FALSE)
817817
if (sscanf($key, 'HTTP_%s', $header) === 1)
818818
{
819819
// take SOME_HEADER and turn it into Some-Header
820-
$header = str_replace('_', ' ', strtolower($header));
820+
$header = str_replace('_', ' ', strtolower((string) $header));
821821
$header = str_replace(' ', '-', ucwords($header));
822822

823823
$this->headers[$header] = $_SERVER[$key];
@@ -848,11 +848,11 @@ public function get_request_header($index, $xss_clean = FALSE)
848848
empty($this->headers) && $this->request_headers();
849849
foreach ($this->headers as $key => $value)
850850
{
851-
$headers[strtolower($key)] = $value;
851+
$headers[strtolower((string) $key)] = $value;
852852
}
853853
}
854854

855-
$index = strtolower($index);
855+
$index = strtolower((string) $index);
856856

857857
if ( ! isset($headers[$index]))
858858
{
@@ -875,7 +875,7 @@ public function get_request_header($index, $xss_clean = FALSE)
875875
*/
876876
public function is_ajax_request()
877877
{
878-
return ( ! empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) === 'xmlhttprequest');
878+
return ( ! empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower((string) $_SERVER['HTTP_X_REQUESTED_WITH']) === 'xmlhttprequest');
879879
}
880880

881881
// --------------------------------------------------------------------

system/core/Loader.php

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -976,7 +976,7 @@ protected function _ci_load_library($class, $params = null, $object_name = null)
976976
if (class_exists($class, false)) {
977977
$property = $object_name;
978978
if (empty($property)) {
979-
$property = strtolower($class);
979+
$property = strtolower((string) $class);
980980
isset($this->_ci_varmap[$property]) && $property = $this->_ci_varmap[$property];
981981
}
982982

@@ -1041,7 +1041,7 @@ protected function _ci_load_stock_library($library_name, $file_path, $params, $o
10411041

10421042
$property = $object_name;
10431043
if (empty($property)) {
1044-
$property = strtolower($library_name);
1044+
$property = strtolower((string) $library_name);
10451045
isset($this->_ci_varmap[$property]) && $property = $this->_ci_varmap[$property];
10461046
}
10471047

@@ -1120,21 +1120,21 @@ protected function _ci_init_library($class, $prefix, $config = false, $object_na
11201120
// We test for both uppercase and lowercase, for servers that
11211121
// are case-sensitive with regard to file names. Load global first,
11221122
// override with environment next
1123-
if (file_exists($path . 'config/' . strtolower($class) . '.php')) {
1123+
if (file_exists($path . 'config/' . strtolower((string) $class) . '.php')) {
11241124
include($path . 'config/' . strtolower($class) . '.php');
11251125
$found = true;
1126-
} elseif (file_exists($path . 'config/' . ucfirst(strtolower($class)) . '.php')) {
1127-
include($path . 'config/' . ucfirst(strtolower($class)) . '.php');
1126+
} elseif (file_exists($path . 'config/' . ucfirst(strtolower((string) $class)) . '.php')) {
1127+
include($path . 'config/' . ucfirst(strtolower((string) $class)) . '.php');
11281128
$found = true;
11291129
}
11301130

1131-
if (file_exists($path . 'config/' . ENVIRONMENT . '/' . strtolower($class) . '.php')) {
1132-
include($path . 'config/' . ENVIRONMENT . '/' . strtolower($class) . '.php');
1131+
if (file_exists($path . 'config/' . ENVIRONMENT . '/' . strtolower((string) $class) . '.php')) {
1132+
include($path . 'config/' . ENVIRONMENT . '/' . strtolower((string) $class) . '.php');
11331133
$found = true;
11341134
} elseif (file_exists(
1135-
$path . 'config/' . ENVIRONMENT . '/' . ucfirst(strtolower($class)) . '.php'
1135+
$path . 'config/' . ENVIRONMENT . '/' . ucfirst(strtolower((string) $class)) . '.php'
11361136
)) {
1137-
include($path . 'config/' . ENVIRONMENT . '/' . ucfirst(strtolower($class)) . '.php');
1137+
include($path . 'config/' . ENVIRONMENT . '/' . ucfirst(strtolower((string) $class)) . '.php');
11381138
$found = true;
11391139
}
11401140

@@ -1158,7 +1158,7 @@ protected function _ci_init_library($class, $prefix, $config = false, $object_na
11581158
// Set the variable name we will assign the class to
11591159
// Was a custom class name supplied? If so we'll use it
11601160
if (empty($object_name)) {
1161-
$object_name = strtolower($class);
1161+
$object_name = strtolower((string) $class);
11621162
if (isset($this->_ci_varmap[$object_name])) {
11631163
$object_name = $this->_ci_varmap[$object_name];
11641164
}

system/core/Log.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ public function write_log($level, $msg)
175175
return FALSE;
176176
}
177177

178-
$level = strtoupper($level);
178+
$level = strtoupper((string) $level);
179179

180180
if (( ! isset($this->_levels[$level]) OR ($this->_levels[$level] > $this->_threshold))
181181
&& ! isset($this->_threshold_array[$this->_levels[$level]]))

system/core/Router.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -382,7 +382,7 @@ protected function _parse_routes()
382382
$uri = implode('/', $this->uri->segments);
383383

384384
// Get HTTP verb
385-
$http_verb = isset($_SERVER['REQUEST_METHOD']) ? strtolower($_SERVER['REQUEST_METHOD']) : 'cli';
385+
$http_verb = isset($_SERVER['REQUEST_METHOD']) ? strtolower((string) $_SERVER['REQUEST_METHOD']) : 'cli';
386386

387387
// Loop through the route array looking for wildcards
388388
foreach ($this->routes as $key => $val)

system/core/Security.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1013,7 +1013,7 @@ protected function _sanitize_naughty_html($matches)
10131013
if (empty($matches['closeTag'])) {
10141014
return '<' . $matches[1];
10151015
} // Is the element that we caught naughty? If so, escape it
1016-
elseif (in_array(strtolower($matches['tagName']), $naughty_tags, true)) {
1016+
elseif (in_array(strtolower((string) $matches['tagName']), $naughty_tags, true)) {
10171017
return '<' . $matches[1] . '>';
10181018
} // For other tags, see if their attributes are "evil" and strip those
10191019
elseif (isset($matches['attributes'])) {

system/core/Utf8.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ public function __construct()
6363
if (
6464
defined('PREG_BAD_UTF8_ERROR') // PCRE must support UTF-8
6565
&& (ICONV_ENABLED === TRUE OR MB_ENABLED === TRUE) // iconv or mbstring must be installed
66-
&& strtoupper(config_item('charset')) === 'UTF-8' // Application charset must be UTF-8
66+
&& strtoupper((string) config_item('charset')) === 'UTF-8' // Application charset must be UTF-8
6767
)
6868
{
6969
define('UTF8_ENABLED', TRUE);

system/core/compat/hash.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ function hash_equals($known_string, $user_string)
120120
*/
121121
function hash_pbkdf2($algo, $password, $salt, $iterations, $length = 0, $raw_output = FALSE)
122122
{
123-
if ( ! in_array(strtolower($algo), hash_algos(), TRUE))
123+
if ( ! in_array(strtolower((string) $algo), hash_algos(), TRUE))
124124
{
125125
trigger_error('hash_pbkdf2(): Unknown hashing algorithm: '.$algo, E_USER_WARNING);
126126
return FALSE;

system/database/DB_forge.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -777,7 +777,7 @@ protected function _process_fields($create_table = FALSE)
777777

778778
if (isset($attributes['TYPE']) && ! empty($attributes['CONSTRAINT']))
779779
{
780-
switch (strtoupper($attributes['TYPE']))
780+
switch (strtoupper((string) $attributes['TYPE']))
781781
{
782782
case 'ENUM':
783783
case 'SET':

0 commit comments

Comments
 (0)