Skip to content

Commit 165d415

Browse files
committed
Enable strict param on base64_decode and array_search
1 parent 3d0ecc4 commit 165d415

6 files changed

Lines changed: 10 additions & 9 deletions

File tree

system/Filters/Filters.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@ public function initialize(string $uri = null)
286286
$this->filters['after'][$count - 1] !== 'toolbar'
287287
)
288288
{
289-
array_splice($this->filters['after'], array_search('toolbar', $this->filters['after']), 1);
289+
array_splice($this->filters['after'], array_search('toolbar', $this->filters['after'], true), 1);
290290
$this->filters['after'][] = 'toolbar';
291291
}
292292

system/Log/Logger.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,12 +61,11 @@
6161
*/
6262
class Logger implements LoggerInterface
6363
{
64-
6564
/**
6665
* Used by the logThreshold Config setting to define
6766
* which errors to show.
6867
*
69-
* @var array
68+
* @var array<string, integer>
7069
*/
7170
protected $logLevels = [
7271
'emergency' => 1,
@@ -160,7 +159,7 @@ public function __construct($config, bool $debug = CI_DEBUG)
160159
$temp = [];
161160
foreach ($this->loggableLevels as $level)
162161
{
163-
$temp[] = array_search((int) $level, $this->logLevels);
162+
$temp[] = array_search((int) $level, $this->logLevels, true);
164163
}
165164

166165
$this->loggableLevels = $temp;
@@ -331,7 +330,7 @@ public function log($level, $message, array $context = []): bool
331330
{
332331
if (is_numeric($level))
333332
{
334-
$level = array_search((int) $level, $this->logLevels);
333+
$level = array_search((int) $level, $this->logLevels, true);
335334
}
336335

337336
// Is the level a valid level?

system/Router/Router.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -426,7 +426,7 @@ protected function checkRoutes(string $uri): bool
426426
// Are we dealing with a locale?
427427
if (strpos($key, '{locale}') !== false)
428428
{
429-
$localeSegment = array_search('{locale}', preg_split('/[\/]*((^[a-zA-Z0-9])|\(([^()]*)\))*[\/]+/m', $key));
429+
$localeSegment = array_search('{locale}', preg_split('/[\/]*((^[a-zA-Z0-9])|\(([^()]*)\))*[\/]+/m', $key), true);
430430

431431
// Replace it with a regex so it
432432
// will actually match.

system/Session/Handlers/DatabaseHandler.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ public function read($sessionID): string
204204
}
205205
else
206206
{
207-
$result = ($this->platform === 'postgre') ? base64_decode(rtrim($result->data)) : $result->data;
207+
$result = ($this->platform === 'postgre') ? base64_decode(rtrim($result->data), true) : $result->data;
208208
}
209209

210210
$this->fingerprint = md5($result);

system/Validation/FormatRules.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ public function timezone(string $str = null): bool
259259
*/
260260
public function valid_base64(string $str = null): bool
261261
{
262-
return (base64_encode(base64_decode($str)) === $str);
262+
return (base64_encode(base64_decode($str, true)) === $str);
263263
}
264264

265265
/**

utils/Rector/PassStrictParameterToFunctionParameterRector.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@ final class PassStrictParameterToFunctionParameterRector extends AbstractRector
2020
{
2121
private const FUNCTION_WITH_ARG_POSITION = [
2222
// position start from 0
23-
'in_array' => 2,
23+
'array_search' => 2,
24+
'base64_decode' => 1,
25+
'in_array' => 2,
2426
];
2527

2628
public function getDefinition(): RectorDefinition

0 commit comments

Comments
 (0)