Skip to content

Commit 3e78c58

Browse files
committed
Merge remote-tracking branch 'upstream/develop' into 4.6
2 parents c830d5f + 3435872 commit 3e78c58

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+222
-94
lines changed

.github/workflows/reusable-phpunit-test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ jobs:
138138
steps:
139139
- name: Create database for MSSQL Server
140140
if: ${{ inputs.db-platform == 'SQLSRV' }}
141-
run: sqlcmd -S 127.0.0.1 -U sa -P 1Secure*Password1 -Q "CREATE DATABASE test"
141+
run: sqlcmd -S 127.0.0.1 -U sa -P 1Secure*Password1 -Q "CREATE DATABASE test COLLATE Latin1_General_100_CS_AS_SC_UTF8"
142142

143143
- name: Install latest ImageMagick
144144
if: ${{ contains(inputs.extra-extensions, 'imagick') }}

phpstan-baseline.php

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7759,12 +7759,6 @@
77597759
'count' => 1,
77607760
'path' => __DIR__ . '/system/Log/Handlers/FileHandler.php',
77617761
];
7762-
$ignoreErrors[] = [
7763-
// identifier: identical.alwaysTrue
7764-
'message' => '#^Strict comparison using \\=\\=\\= between true and true will always evaluate to true\\.$#',
7765-
'count' => 1,
7766-
'path' => __DIR__ . '/system/Log/Handlers/FileHandler.php',
7767-
];
77687762
$ignoreErrors[] = [
77697763
// identifier: missingType.iterableValue
77707764
'message' => '#^Method CodeIgniter\\\\Log\\\\Logger\\:\\:determineFile\\(\\) return type has no value type specified in iterable type array\\.$#',

rector.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
use Rector\CodeQuality\Rector\FuncCall\ChangeArrayPushToArrayAssignRector;
2020
use Rector\CodeQuality\Rector\FuncCall\SingleInArrayToCompareRector;
2121
use Rector\CodeQuality\Rector\FunctionLike\SimplifyUselessVariableRector;
22+
use Rector\CodeQuality\Rector\Identical\SimplifyBoolIdenticalTrueRector;
2223
use Rector\CodeQuality\Rector\If_\CombineIfRector;
2324
use Rector\CodeQuality\Rector\If_\ExplicitBoolCompareRector;
2425
use Rector\CodeQuality\Rector\If_\ShortenElseIfRector;
@@ -211,9 +212,10 @@
211212
AddMethodCallBasedStrictParamTypeRector::class,
212213
TypedPropertyFromAssignsRector::class,
213214
ClosureReturnTypeRector::class,
215+
SimplifyBoolIdenticalTrueRector::class,
214216
])
215217
->withConfiguredRule(StringClassNameToClassConstantRector::class, [
216218
// keep '\\' prefix string on string '\Foo\Bar'
217219
StringClassNameToClassConstantRector::SHOULD_KEEP_PRE_SLASH => true,
218220
])
219-
->withCodeQualityLevel(14);
221+
->withCodeQualityLevel(15);

system/CLI/CLI.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -514,7 +514,7 @@ public static function beep(int $num = 1)
514514
*/
515515
public static function wait(int $seconds, bool $countdown = false)
516516
{
517-
if ($countdown === true) {
517+
if ($countdown) {
518518
$time = $seconds;
519519

520520
while ($time > 0) {

system/Cache/Handlers/FileHandler.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -308,15 +308,15 @@ protected function deleteFiles(string $path, bool $delDir = false, bool $htdocs
308308
if ($filename !== '.' && $filename !== '..') {
309309
if (is_dir($path . DIRECTORY_SEPARATOR . $filename) && $filename[0] !== '.') {
310310
$this->deleteFiles($path . DIRECTORY_SEPARATOR . $filename, $delDir, $htdocs, $_level + 1);
311-
} elseif ($htdocs !== true || ! preg_match('/^(\.htaccess|index\.(html|htm|php)|web\.config)$/i', $filename)) {
311+
} elseif (! $htdocs || ! preg_match('/^(\.htaccess|index\.(html|htm|php)|web\.config)$/i', $filename)) {
312312
@unlink($path . DIRECTORY_SEPARATOR . $filename);
313313
}
314314
}
315315
}
316316

317317
closedir($currentDir);
318318

319-
return ($delDir === true && $_level > 0) ? @rmdir($path) : true;
319+
return ($delDir && $_level > 0) ? @rmdir($path) : true;
320320
}
321321

322322
/**

system/Config/Services.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ public static function csp(?CSPConfig $config = null, bool $getShared = true)
202202
*/
203203
public static function curlrequest(array $options = [], ?ResponseInterface $response = null, ?App $config = null, bool $getShared = true)
204204
{
205-
if ($getShared === true) {
205+
if ($getShared) {
206206
return static::getSharedInstance('curlrequest', $options, $response, $config);
207207
}
208208

system/Database/BaseBuilder.php

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -584,7 +584,7 @@ public function distinct(bool $val = true)
584584
*/
585585
public function from($from, bool $overwrite = false): self
586586
{
587-
if ($overwrite === true) {
587+
if ($overwrite) {
588588
$this->QBFrom = [];
589589
$this->db->setAliasedTables([]);
590590
}
@@ -774,7 +774,7 @@ protected function whereHaving(string $qbKey, $key, $value = null, string $type
774774
foreach ($keyValue as $k => $v) {
775775
$prefix = empty($this->{$qbKey}) ? $this->groupGetType('') : $this->groupGetType($type);
776776

777-
if ($rawSqlOnly === true) {
777+
if ($rawSqlOnly) {
778778
$k = '';
779779
$op = '';
780780
} elseif ($v !== null) {
@@ -1155,8 +1155,8 @@ protected function _like($field, string $match = '', string $type = 'AND ', stri
11551155
$keyValue = ! is_array($field) ? [$field => $match] : $field;
11561156

11571157
foreach ($keyValue as $k => $v) {
1158-
if ($insensitiveSearch === true) {
1159-
$v = strtolower($v);
1158+
if ($insensitiveSearch) {
1159+
$v = mb_strtolower($v, 'UTF-8');
11601160
}
11611161

11621162
$prefix = empty($this->{$clause}) ? $this->groupGetType('') : $this->groupGetType($type);
@@ -1192,7 +1192,7 @@ protected function _like($field, string $match = '', string $type = 'AND ', stri
11921192
*/
11931193
protected function _like_statement(?string $prefix, string $column, ?string $not, string $bind, bool $insensitiveSearch = false): string
11941194
{
1195-
if ($insensitiveSearch === true) {
1195+
if ($insensitiveSearch) {
11961196
return "{$prefix} LOWER(" . $this->db->escapeIdentifiers($column) . ") {$not} LIKE :{$bind}:";
11971197
}
11981198

@@ -1604,7 +1604,7 @@ public function getCompiledSelect(bool $reset = true): string
16041604
{
16051605
$select = $this->compileSelect();
16061606

1607-
if ($reset === true) {
1607+
if ($reset) {
16081608
$this->resetSelect();
16091609
}
16101610

@@ -1648,7 +1648,7 @@ public function get(?int $limit = null, int $offset = 0, bool $reset = true)
16481648
? $this->getCompiledSelect($reset)
16491649
: $this->db->query($this->compileSelect(), $this->binds, false);
16501650

1651-
if ($reset === true) {
1651+
if ($reset) {
16521652
$this->resetSelect();
16531653

16541654
// Clear our binds so we don't eat up memory
@@ -1683,7 +1683,7 @@ public function countAll(bool $reset = true)
16831683

16841684
$query = $query->getRow();
16851685

1686-
if ($reset === true) {
1686+
if ($reset) {
16871687
$this->resetSelect();
16881688
}
16891689

@@ -1732,7 +1732,7 @@ public function countAllResults(bool $reset = true)
17321732

17331733
$result = $this->db->query($sql, $this->binds, false);
17341734

1735-
if ($reset === true) {
1735+
if ($reset) {
17361736
$this->resetSelect();
17371737
} elseif (! isset($this->QBOrderBy)) {
17381738
$this->QBOrderBy = $orderBy;
@@ -1786,7 +1786,7 @@ public function getWhere($where = null, ?int $limit = null, ?int $offset = 0, bo
17861786
? $this->getCompiledSelect($reset)
17871787
: $this->db->query($this->compileSelect(), $this->binds, false);
17881788

1789-
if ($reset === true) {
1789+
if ($reset) {
17901790
$this->resetSelect();
17911791

17921792
// Clear our binds so we don't eat up memory
@@ -2302,7 +2302,7 @@ public function getCompiledInsert(bool $reset = true)
23022302
array_values($this->QBSet)
23032303
);
23042304

2305-
if ($reset === true) {
2305+
if ($reset) {
23062306
$this->resetWrite();
23072307
}
23082308

@@ -2471,7 +2471,7 @@ public function getCompiledUpdate(bool $reset = true)
24712471

24722472
$sql = $this->_update($this->QBFrom[0], $this->QBSet);
24732473

2474-
if ($reset === true) {
2474+
if ($reset) {
24752475
$this->resetWrite();
24762476
}
24772477

system/Database/BaseConnection.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -852,7 +852,7 @@ public function transBegin(bool $testMode = false): bool
852852
// Reset the transaction failure flag.
853853
// If the $test_mode flag is set to TRUE transactions will be rolled back
854854
// even if the queries produce a successful result.
855-
$this->transFailure = ($testMode === true);
855+
$this->transFailure = $testMode;
856856

857857
if ($this->_transBegin()) {
858858
$this->transDepth++;
@@ -1143,7 +1143,7 @@ public function protectIdentifiers($item, bool $prefixSingle = false, ?bool $pro
11431143
$item = preg_replace('/^' . $this->swapPre . '(\S+?)/', $this->DBPrefix . '\\1', $item);
11441144
}
11451145
// Do we prefix an item with no segments?
1146-
elseif ($prefixSingle === true && ! str_starts_with($item, $this->DBPrefix)) {
1146+
elseif ($prefixSingle && ! str_starts_with($item, $this->DBPrefix)) {
11471147
$item = $this->DBPrefix . $item;
11481148
}
11491149
}
@@ -1166,7 +1166,7 @@ private function protectDotItem(string $item, string $alias, bool $protectIdenti
11661166
// NOTE: The ! empty() condition prevents this method
11671167
// from breaking when QB isn't enabled.
11681168
if (! empty($this->aliasedTables) && in_array($parts[0], $this->aliasedTables, true)) {
1169-
if ($protectIdentifiers === true) {
1169+
if ($protectIdentifiers) {
11701170
foreach ($parts as $key => $val) {
11711171
if (! in_array($val, $this->reservedIdentifiers, true)) {
11721172
$parts[$key] = $this->escapeIdentifiers($val);
@@ -1217,7 +1217,7 @@ private function protectDotItem(string $item, string $alias, bool $protectIdenti
12171217
$item = implode('.', $parts);
12181218
}
12191219

1220-
if ($protectIdentifiers === true) {
1220+
if ($protectIdentifiers) {
12211221
$item = $this->escapeIdentifiers($item);
12221222
}
12231223

@@ -1410,7 +1410,7 @@ public function escapeString($str, bool $like = false)
14101410
$str = $this->_escapeString($str);
14111411

14121412
// escape LIKE condition wildcards
1413-
if ($like === true) {
1413+
if ($like) {
14141414
return str_replace(
14151415
[
14161416
$this->likeEscapeChar,
@@ -1539,7 +1539,7 @@ public function listTables(bool $constrainByPrefix = false)
15391539
*/
15401540
public function tableExists(string $tableName, bool $cached = true): bool
15411541
{
1542-
if ($cached === true) {
1542+
if ($cached) {
15431543
return in_array($this->protectIdentifiers($tableName, true, false, false), $this->listTables(), true);
15441544
}
15451545

system/Database/Forge.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -449,12 +449,12 @@ public function addForeignKey(
449449
*/
450450
public function dropKey(string $table, string $keyName, bool $prefixKeyName = true): bool
451451
{
452-
$keyName = $this->db->escapeIdentifiers(($prefixKeyName === true ? $this->db->DBPrefix : '') . $keyName);
452+
$keyName = $this->db->escapeIdentifiers(($prefixKeyName ? $this->db->DBPrefix : '') . $keyName);
453453
$table = $this->db->escapeIdentifiers($this->db->DBPrefix . $table);
454454

455455
$dropKeyAsConstraint = $this->dropKeyAsConstraint($table, $keyName);
456456

457-
if ($dropKeyAsConstraint === true) {
457+
if ($dropKeyAsConstraint) {
458458
$sql = sprintf(
459459
$this->dropConstraintStr,
460460
$table,
@@ -559,7 +559,7 @@ public function createTable(string $table, bool $ifNotExists = false, array $att
559559
}
560560

561561
// If table exists lets stop here
562-
if ($ifNotExists === true && $this->db->tableExists($table, false)) {
562+
if ($ifNotExists && $this->db->tableExists($table, false)) {
563563
$this->reset();
564564

565565
return true;
@@ -895,7 +895,7 @@ protected function _processFields(bool $createTable = false): array
895895

896896
$attributes = array_change_key_case($attributes, CASE_UPPER);
897897

898-
if ($createTable === true && empty($attributes['TYPE'])) {
898+
if ($createTable && empty($attributes['TYPE'])) {
899899
continue;
900900
}
901901

@@ -942,7 +942,7 @@ protected function _processFields(bool $createTable = false): array
942942
} else {
943943
$field['null'] = ' NOT ' . $this->null;
944944
}
945-
} elseif ($createTable === true) {
945+
} elseif ($createTable) {
946946
$field['null'] = ' NOT ' . $this->null;
947947
}
948948

@@ -1085,7 +1085,7 @@ protected function _processPrimaryKeys(string $table, bool $asQuery = false): st
10851085
}
10861086

10871087
if (isset($this->primaryKeys['fields']) && $this->primaryKeys['fields'] !== []) {
1088-
if ($asQuery === true) {
1088+
if ($asQuery) {
10891089
$sql .= 'ALTER TABLE ' . $this->db->escapeIdentifiers($this->db->DBPrefix . $table) . ' ADD ';
10901090
} else {
10911091
$sql .= ",\n\t";
@@ -1229,7 +1229,7 @@ protected function _processForeignKeys(string $table, bool $asQuery = false): ar
12291229
$referenceTableFilled = $this->db->escapeIdentifiers($this->db->DBPrefix . $fkey['referenceTable']);
12301230
$referenceFieldFilled = implode(', ', $this->db->escapeIdentifiers($fkey['referenceField']));
12311231

1232-
if ($asQuery === true) {
1232+
if ($asQuery) {
12331233
$sqls[$index] .= 'ALTER TABLE ' . $this->db->escapeIdentifiers($this->db->DBPrefix . $table) . ' ADD ';
12341234
} else {
12351235
$sqls[$index] .= ",\n\t";

system/Database/MySQLi/Connection.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ public function connect(bool $persistent = false)
107107
$port = null;
108108
$socket = $this->hostname;
109109
} else {
110-
$hostname = ($persistent === true) ? 'p:' . $this->hostname : $this->hostname;
110+
$hostname = $persistent ? 'p:' . $this->hostname : $this->hostname;
111111
$port = empty($this->port) ? null : $this->port;
112112
$socket = '';
113113
}
@@ -414,7 +414,7 @@ protected function _listTables(bool $prefixLimit = false, ?string $tableName = n
414414
return $sql . ' LIKE ' . $this->escape($tableName);
415415
}
416416

417-
if ($prefixLimit !== false && $this->DBPrefix !== '') {
417+
if ($prefixLimit && $this->DBPrefix !== '') {
418418
return $sql . " LIKE '" . $this->escapeLikeStringDirect($this->DBPrefix) . "%'";
419419
}
420420

system/Database/MySQLi/Forge.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ protected function _processIndexes(string $table, bool $asQuery = false): array
222222
implode('_', $this->keys[$i]['fields']) :
223223
$this->keys[$i]['keyName']);
224224

225-
if ($asQuery === true) {
225+
if ($asQuery) {
226226
$sqls[$index] = 'ALTER TABLE ' . $this->db->escapeIdentifiers($table) . " ADD {$unique}KEY "
227227
. $keyName
228228
. ' (' . implode(', ', $this->db->escapeIdentifiers($this->keys[$i]['fields'])) . ')';

system/Database/OCI8/Connection.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,7 @@ protected function _listTables(bool $prefixLimit = false, ?string $tableName = n
275275
return $sql . ' WHERE "TABLE_NAME" LIKE ' . $this->escape($tableName);
276276
}
277277

278-
if ($prefixLimit !== false && $this->DBPrefix !== '') {
278+
if ($prefixLimit && $this->DBPrefix !== '') {
279279
return $sql . ' WHERE "TABLE_NAME" LIKE \'' . $this->escapeLikeString($this->DBPrefix) . "%' "
280280
. sprintf($this->likeEscapeStr, $this->likeEscapeChar);
281281
}

system/Database/OCI8/Forge.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ protected function _alterTable(string $alterType, string $table, $processedField
135135
$wantToAddNull = ! str_contains($processedFields[$i]['null'], ' NOT');
136136
$currentNullable = $nullableMap[$processedFields[$i]['name']];
137137

138-
if ($wantToAddNull === true && $currentNullable === true) {
138+
if ($wantToAddNull && $currentNullable === true) {
139139
$processedFields[$i]['null'] = '';
140140
} elseif ($processedFields[$i]['null'] === '' && $currentNullable === false) {
141141
// Nullable by default
@@ -293,7 +293,7 @@ protected function _dropTable(string $table, bool $ifExists, bool $cascade)
293293
{
294294
$sql = parent::_dropTable($table, $ifExists, $cascade);
295295

296-
if ($sql !== true && $cascade === true) {
296+
if ($sql !== true && $cascade) {
297297
$sql .= ' CASCADE CONSTRAINTS PURGE';
298298
} elseif ($sql !== true) {
299299
$sql .= ' PURGE';

system/Database/Postgre/Builder.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@ protected function _truncate(string $table): string
293293
*/
294294
protected function _like_statement(?string $prefix, string $column, ?string $not, string $bind, bool $insensitiveSearch = false): string
295295
{
296-
$op = $insensitiveSearch === true ? 'ILIKE' : 'LIKE';
296+
$op = $insensitiveSearch ? 'ILIKE' : 'LIKE';
297297

298298
return "{$prefix} {$column} {$not} {$op} :{$bind}:";
299299
}

system/Database/Postgre/Connection.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,11 +75,11 @@ public function connect(bool $persistent = false)
7575
$this->convertDSN();
7676
}
7777

78-
$this->connID = $persistent === true ? pg_pconnect($this->DSN) : pg_connect($this->DSN);
78+
$this->connID = $persistent ? pg_pconnect($this->DSN) : pg_connect($this->DSN);
7979

8080
if ($this->connID !== false) {
8181
if (
82-
$persistent === true
82+
$persistent
8383
&& pg_connection_status($this->connID) === PGSQL_CONNECTION_BAD
8484
&& pg_ping($this->connID) === false
8585
) {
@@ -290,7 +290,7 @@ protected function _listTables(bool $prefixLimit = false, ?string $tableName = n
290290
return $sql . ' AND "table_name" LIKE ' . $this->escape($tableName);
291291
}
292292

293-
if ($prefixLimit !== false && $this->DBPrefix !== '') {
293+
if ($prefixLimit && $this->DBPrefix !== '') {
294294
return $sql . ' AND "table_name" LIKE \''
295295
. $this->escapeLikeString($this->DBPrefix) . "%' "
296296
. sprintf($this->likeEscapeStr, $this->likeEscapeChar);

system/Database/Postgre/Forge.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ protected function _alterTable(string $alterType, string $table, $processedField
118118
$nullable = false;
119119
}
120120
$sqls[] = $sql . ' ALTER COLUMN ' . $this->db->escapeIdentifiers($field['name'])
121-
. ($nullable === true ? ' DROP' : ' SET') . ' NOT NULL';
121+
. ($nullable ? ' DROP' : ' SET') . ' NOT NULL';
122122

123123
if (! empty($field['new_name'])) {
124124
$sqls[] = $sql . ' RENAME COLUMN ' . $this->db->escapeIdentifiers($field['name'])
@@ -195,7 +195,7 @@ protected function _dropTable(string $table, bool $ifExists, bool $cascade): str
195195
{
196196
$sql = parent::_dropTable($table, $ifExists, $cascade);
197197

198-
if ($cascade === true) {
198+
if ($cascade) {
199199
$sql .= ' CASCADE';
200200
}
201201

0 commit comments

Comments
 (0)