diff --git a/system/Filters/Filters.php b/system/Filters/Filters.php index c253610288c4..1862fea87c2b 100644 --- a/system/Filters/Filters.php +++ b/system/Filters/Filters.php @@ -286,7 +286,7 @@ public function initialize(string $uri = null) $this->filters['after'][$count - 1] !== 'toolbar' ) { - array_splice($this->filters['after'], array_search('toolbar', $this->filters['after']), 1); + array_splice($this->filters['after'], array_search('toolbar', $this->filters['after'], true), 1); $this->filters['after'][] = 'toolbar'; } diff --git a/system/Log/Logger.php b/system/Log/Logger.php index aa924caf9a8d..fa4977e5ee26 100644 --- a/system/Log/Logger.php +++ b/system/Log/Logger.php @@ -61,12 +61,11 @@ */ class Logger implements LoggerInterface { - /** * Used by the logThreshold Config setting to define * which errors to show. * - * @var array + * @var array */ protected $logLevels = [ 'emergency' => 1, @@ -160,7 +159,7 @@ public function __construct($config, bool $debug = CI_DEBUG) $temp = []; foreach ($this->loggableLevels as $level) { - $temp[] = array_search((int) $level, $this->logLevels); + $temp[] = array_search((int) $level, $this->logLevels, true); } $this->loggableLevels = $temp; @@ -331,7 +330,7 @@ public function log($level, $message, array $context = []): bool { if (is_numeric($level)) { - $level = array_search((int) $level, $this->logLevels); + $level = array_search((int) $level, $this->logLevels, true); } // Is the level a valid level? diff --git a/system/Router/Router.php b/system/Router/Router.php index 3a423e81d468..4af5507ba4d5 100644 --- a/system/Router/Router.php +++ b/system/Router/Router.php @@ -426,7 +426,7 @@ protected function checkRoutes(string $uri): bool // Are we dealing with a locale? if (strpos($key, '{locale}') !== false) { - $localeSegment = array_search('{locale}', preg_split('/[\/]*((^[a-zA-Z0-9])|\(([^()]*)\))*[\/]+/m', $key)); + $localeSegment = array_search('{locale}', preg_split('/[\/]*((^[a-zA-Z0-9])|\(([^()]*)\))*[\/]+/m', $key), true); // Replace it with a regex so it // will actually match. diff --git a/system/Session/Handlers/DatabaseHandler.php b/system/Session/Handlers/DatabaseHandler.php index facd38939468..fa04d6a09c84 100644 --- a/system/Session/Handlers/DatabaseHandler.php +++ b/system/Session/Handlers/DatabaseHandler.php @@ -204,7 +204,7 @@ public function read($sessionID): string } else { - $result = ($this->platform === 'postgre') ? base64_decode(rtrim($result->data)) : $result->data; + $result = ($this->platform === 'postgre') ? base64_decode(rtrim($result->data), true) : $result->data; } $this->fingerprint = md5($result); diff --git a/system/Validation/FormatRules.php b/system/Validation/FormatRules.php index b8c92152a4ad..6ae2147874dc 100644 --- a/system/Validation/FormatRules.php +++ b/system/Validation/FormatRules.php @@ -259,7 +259,7 @@ public function timezone(string $str = null): bool */ public function valid_base64(string $str = null): bool { - return (base64_encode(base64_decode($str)) === $str); + return (base64_encode(base64_decode($str, true)) === $str); } /** diff --git a/utils/Rector/PassStrictParameterToFunctionParameterRector.php b/utils/Rector/PassStrictParameterToFunctionParameterRector.php index 1b1d22855fa4..c37430a73de6 100644 --- a/utils/Rector/PassStrictParameterToFunctionParameterRector.php +++ b/utils/Rector/PassStrictParameterToFunctionParameterRector.php @@ -20,21 +20,17 @@ final class PassStrictParameterToFunctionParameterRector extends AbstractRector { private const FUNCTION_WITH_ARG_POSITION = [ // position start from 0 - 'in_array' => 2, + 'array_search' => 2, + 'base64_decode' => 1, + 'in_array' => 2, ]; public function getDefinition(): RectorDefinition { return new RectorDefinition('Pass strict to function parameter on specific position argument when no value provided', [ - new CodeSample( - <<<'CODE_SAMPLE' -in_array('a', $array); -CODE_SAMPLE -, - <<<'CODE_SAMPLE' -in_array('a', $array, true); -CODE_SAMPLE - ), + new CodeSample('array_search($value, $array);', 'array_search($value, $array, true);'), + new CodeSample('base64_decode($string);', 'base64_decode($string, true);'), + new CodeSample("in_array('a', \$array);", "in_array('a', \$array, true);"), ]); }