Skip to content

Commit 6967bfb

Browse files
committed
Fix strtolower and strtoupper
1 parent 529c011 commit 6967bfb

File tree

9 files changed

+17
-17
lines changed

9 files changed

+17
-17
lines changed

helpers/html_helper.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@ function html_tag($tag, $attr = array(), $content = false)
256256
$html .= (!empty($attr)) ? ' ' . (is_array($attr) ? arrayToAttributes($attr) : $attr) : '';
257257

258258
// a void element?
259-
if (in_array(mb_strtolower($tag), $void_elements)) {
259+
if (in_array(mb_strtolower((string) $tag), $void_elements)) {
260260
// these can not have content
261261
$html .= ' />';
262262
} else {

helpers/request_helper.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
*/
2424
function sendSimpleGetRequest($url = '', $data = array(), $method = 'GET')
2525
{
26-
$method = mb_strtoupper($method);
26+
$method = mb_strtoupper((string)$method);
2727
if ((!empty($data) && (is_array($data) || is_object($data)))) {
2828
$target = $url . '?' . http_build_query($data);
2929
} else {
@@ -39,7 +39,7 @@ function sendSimpleGetRequest($url = '', $data = array(), $method = 'GET')
3939
CURLOPT_MAXREDIRS => 10,
4040
CURLOPT_TIMEOUT => 30,
4141
CURLOPT_FOLLOWLOCATION => true,
42-
CURLOPT_CUSTOMREQUEST => "GET",
42+
CURLOPT_CUSTOMREQUEST => $method,
4343
CURLOPT_HTTPHEADER => array($UA),
4444
);
4545
if (isset($parseUrl['scheme']) && $parseUrl['scheme'] === 'https') {

helpers/string_helper.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -473,10 +473,10 @@ function str_starts_with($needle, $haystack)
473473
*/
474474
function str_ignore_starts_with($needle, $haystack)
475475
{
476-
$hs = mb_strtolower($haystack);
476+
$hs = mb_strtolower((string) $haystack);
477477

478478
foreach ((array)$needle as $ndl) {
479-
$n = mb_strtolower($ndl);
479+
$n = mb_strtolower((string) $ndl);
480480
if ($n !== '' && mb_strpos($hs, $n) === 0) {
481481
return true;
482482
}
@@ -568,10 +568,10 @@ function str_ends_with($needle, $haystack)
568568
*/
569569
function str_ignore_ends_with($needle, $haystack)
570570
{
571-
$hs = mb_strtolower($haystack);
571+
$hs = mb_strtolower((string) $haystack);
572572

573573
foreach ((array)$needle as $ndl) {
574-
$n = mb_strtolower($ndl);
574+
$n = mb_strtolower((string) $ndl);
575575
$length = mb_strlen($ndl);
576576
if ($length === 0 || (mb_substr($hs, -$length) === $n)) {
577577
return true;

helpers/url_helper.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ function encodeId_Url_byHungDEV($id)
118118
*/
119119
function decodeId_Url_byHungDEV($id)
120120
{
121-
$id = mb_strtoupper($id);
121+
$id = mb_strtoupper((string) $id);
122122
$id = str_replace(
123123
array('E', 'R', 'M', 'N', 'J', 'I', 'Z', 'K', 'L', 'O'),
124124
array('0', '1', '2', '3', '4', '5', '6', '7', '8', '9'),
@@ -567,7 +567,7 @@ function convertToLatin($string = '', $alphabetOnly = false, $toLower = true)
567567
$output = alphabetOnly($output);
568568
}
569569
if ($toLower) {
570-
$output = mb_strtolower($output);
570+
$output = mb_strtolower((string) $output);
571571
}
572572
}
573573

src/BaseHelper.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@
1919
*/
2020
class BaseHelper
2121
{
22-
const VERSION = '1.6.6';
23-
const LAST_MODIFIED = '2024-09-15';
22+
const VERSION = '1.6.7';
23+
const LAST_MODIFIED = '2024-09-22';
2424
const PROJECT_NAME = 'CodeIgniter - Basic Helper';
2525
const AUTHOR_NAME = 'Hung Nguyen';
2626
const AUTHOR_FULL_NAME = 'Hung Nguyen';

src/BasicCurl.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ private function init()
199199
*/
200200
public function addResponseHeaderLine($curl, $header_line)
201201
{
202-
$trimmed_header = trim($header_line, "\r\n");
202+
$trimmed_header = trim((string) $header_line, "\r\n");
203203

204204
if ($trimmed_header === "") {
205205
$this->response_header_continue = false;
@@ -802,7 +802,7 @@ public function getResponseHeaders($headerKey = null)
802802
{
803803
$headers = array();
804804
if (!is_null($headerKey)) {
805-
$headerKey = strtolower($headerKey);
805+
$headerKey = strtolower((string) $headerKey);
806806
}
807807

808808
foreach ($this->response_headers as $header) {
@@ -811,7 +811,7 @@ public function getResponseHeaders($headerKey = null)
811811
$key = isset($parts[0]) ? $parts[0] : '';
812812
$value = isset($parts[1]) ? $parts[1] : '';
813813

814-
$headers[strtolower(trim($key))] = trim($value);
814+
$headers[strtolower(trim((string) $key))] = trim($value);
815815
}
816816

817817
if ($headerKey) {

src/SimpleRequests.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ public function setHeader($header = array())
117117
public function sendRequest($url = '', $data = array(), $method = 'GET')
118118
{
119119
try {
120-
$getMethod = mb_strtoupper($method);
120+
$getMethod = mb_strtoupper((string) $method);
121121
if ($this->DEBUG === true) {
122122
$this->logger->info('||=========== Logger Send Requests ===========||');
123123
$this->logger->info('Send ' . $getMethod . ' Request to URL: ' . $url, $data);

src/Valid.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,7 @@ public static function credit_card($number, $type = null)
339339
);
340340

341341
// Check card type
342-
$type = mb_strtolower($type);
342+
$type = mb_strtolower((string) $type);
343343

344344
if (!isset($cards[$type])) {
345345
return false;

src/Validator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -725,7 +725,7 @@ protected function validateUrlActive($field, $value)
725725

726726
foreach ($this->validUrlPrefixes as $prefix) {
727727
if (mb_strpos($value, $prefix) !== false) {
728-
$host = parse_url(mb_strtolower($value), PHP_URL_HOST);
728+
$host = parse_url(mb_strtolower((string) $value), PHP_URL_HOST);
729729

730730
return checkdnsrr($host, 'A') || checkdnsrr($host, 'AAAA') || checkdnsrr($host, 'CNAME');
731731
}

0 commit comments

Comments
 (0)