Skip to content

Commit dc47198

Browse files
Short boolean conditions (#18413)
* Short boolean conditions Signed-off-by: Kamil Tekiela <tekiela246@gmail.com> * Simplify conditions Signed-off-by: Kamil Tekiela <tekiela246@gmail.com> --------- Signed-off-by: Kamil Tekiela <tekiela246@gmail.com>
1 parent 9528590 commit dc47198

16 files changed

Lines changed: 23 additions & 23 deletions

File tree

libraries/classes/ConfigStorage/Relation.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1022,7 +1022,7 @@ public function getForeignData(
10221022
$moreThanLimit = $this->dbi->getTable($foreignDb, $foreignTable)
10231023
->checkIfMinRecordsExist($GLOBALS['cfg']['ForeignKeyMaxLimit']);
10241024

1025-
if ($overrideTotal === true || ! $moreThanLimit) {
1025+
if ($overrideTotal || ! $moreThanLimit) {
10261026
// foreign_display can be false if no display field defined:
10271027
$foreignDisplay = $this->getDisplayField($foreignDb, $foreignTable);
10281028

libraries/classes/Controllers/Database/StructureController.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ public function __invoke(ServerRequest $request): void
174174
}
175175

176176
$createTable = '';
177-
if ($this->dbIsSystemSchema === false) {
177+
if (! $this->dbIsSystemSchema) {
178178
$checkUserPrivileges = new CheckUserPrivileges($this->dbi);
179179
$checkUserPrivileges->getPrivileges();
180180

@@ -186,7 +186,7 @@ public function __invoke(ServerRequest $request): void
186186
'has_tables' => $this->numTables > 0,
187187
'list_navigator_html' => $listNavigator ?? '',
188188
'table_list_html' => $tableList ?? '',
189-
'is_system_schema' => $this->dbIsSystemSchema === true,
189+
'is_system_schema' => $this->dbIsSystemSchema,
190190
'create_table_html' => $createTable,
191191
]);
192192
}

libraries/classes/Controllers/Sql/ColumnPreferencesController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,6 @@ public function __invoke(ServerRequest $request): void
6060
return;
6161
}
6262

63-
$this->response->setRequestStatus($status === true);
63+
$this->response->setRequestStatus($status);
6464
}
6565
}

libraries/classes/Controllers/Table/AddFieldController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ public function __invoke(ServerRequest $request): void
110110
$GLOBALS['errorUrl'],
111111
);
112112

113-
if ($GLOBALS['result'] !== true) {
113+
if (! $GLOBALS['result']) {
114114
$errorMessageHtml = Generator::mysqlDie('', '', false, $GLOBALS['errorUrl'], false);
115115
$this->response->addHTML($errorMessageHtml ?? '');
116116
$this->response->setRequestStatus(false);

libraries/classes/Database/Qbe.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1233,7 +1233,7 @@ private function getMasterTable(
12331233
// Of course the actual query would be faster if we check for
12341234
// the Criteria which gives the smallest result set in its table,
12351235
// but it would take too much time to check this
1236-
if (! (count($candidateColumns) > 1)) {
1236+
if (count($candidateColumns) <= 1) {
12371237
// Only one single candidate
12381238
return reset($candidateColumns);
12391239
}

libraries/classes/DatabaseInterface.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -492,10 +492,10 @@ static function ($a, $b) {
492492
// this is why we fall back to SHOW TABLE STATUS even for MySQL >= 50002
493493
if ($tables === []) {
494494
$sql = 'SHOW TABLE STATUS FROM ' . Util::backquote($database);
495-
if (($table !== '' && $table !== []) || ($tableIsGroup === true) || $tableType) {
495+
if (($table !== '' && $table !== []) || $tableIsGroup || $tableType) {
496496
$sql .= ' WHERE';
497497
$needAnd = false;
498-
if (($table !== '' && $table !== []) || ($tableIsGroup === true)) {
498+
if (($table !== '' && $table !== []) || $tableIsGroup) {
499499
if (is_array($table)) {
500500
$sql .= ' `Name` IN ('
501501
. implode(

libraries/classes/Navigation/NavigationTree.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1069,7 +1069,7 @@ private function renderNode(Node $node, string $class = ''): string
10691069

10701070
$haveAjax = ['functions', 'procedures', 'events', 'triggers', 'indexes'];
10711071
$parent = $node->parents(false, true);
1072-
$isNewView = $parent[0]->realName === 'views' && $node->isNew === true;
1072+
$isNewView = $parent[0]->realName === 'views' && $node->isNew;
10731073
$linkHasAjaxClass = $parent[0]->type == Node::CONTAINER
10741074
&& (in_array($parent[0]->realName, $haveAjax) || $isNewView);
10751075

libraries/classes/Navigation/Nodes/Node.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ public function getChild(string $name, bool $realName = false): Node|null
176176
}
177177
} else {
178178
foreach ($this->children as $child) {
179-
if ($child->name == $name && $child->isNew === false) {
179+
if ($child->name == $name && ! $child->isNew) {
180180
return $child;
181181
}
182182
}

libraries/classes/Query/Generator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public static function getTableNameCondition(
2828
bool $tblIsGroup,
2929
): string {
3030
$sqlWhereTable = 'AND t.`TABLE_NAME` ';
31-
if ($tblIsGroup === true) {
31+
if ($tblIsGroup) {
3232
$sqlWhereTable .= 'LIKE ' . $escapedTabletable . '%';
3333
} else {
3434
$sqlWhereTable .= Util::getCollateForIS() . ' = ' . $escapedTabletable;

libraries/classes/ResponseRenderer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ public static function getInstance(): ResponseRenderer
192192
*/
193193
public function setRequestStatus(bool $state): void
194194
{
195-
$this->isSuccess = ($state === true);
195+
$this->isSuccess = $state;
196196
}
197197

198198
/**

0 commit comments

Comments
 (0)