Skip to content

Commit

Permalink
Replace or improve use of 'for'
Browse files Browse the repository at this point in the history
Signed-off-by: Hugues Peccatte <hugues.peccatte@gmail.com>
  • Loading branch information
Tithugues committed Jan 12, 2019
1 parent dd74c49 commit 7685733
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -659,7 +659,7 @@ private function _extractPartitionDetails()

$partitionDetails['partitions'] = [];

for ($i = 0; $i < intval($partitionDetails['partition_count']); $i++) {
for ($i = 0, $iMax = (int) $partitionDetails['partition_count']; $i < $iMax; $i++) {
if (! isset($stmt->partitions[$i])) {
$partitionDetails['partitions'][$i] = [
'name' => 'p' . $i,
Expand Down Expand Up @@ -704,7 +704,7 @@ private function _extractPartitionDetails()
$partition['subpartition_count'] = $partitionDetails['subpartition_count'];
$partition['subpartitions'] = [];

for ($j = 0; $j < intval($partitionDetails['subpartition_count']); $j++) {
for ($j = 0, $jMax = (int) $partitionDetails['subpartition_count']; $j < $jMax; $j++) {
if (! isset($stmt->partitions[$i]->subpartitions[$j])) {
$partition['subpartitions'][$j] = [
'name' => $partition['name'] . '_s' . $j,
Expand Down
23 changes: 11 additions & 12 deletions libraries/classes/Import.php
Original file line number Diff line number Diff line change
Expand Up @@ -1235,7 +1235,7 @@ public function buildSql(
$inTables = false;
}

$params = ['db' => (string) $db_name];
$params = ['db' => $db_name];
$db_url = 'db_structure.php' . Url::getCommon($params);
$db_ops_url = 'db_operations.php' . Url::getCommon($params);

Expand Down Expand Up @@ -1271,19 +1271,18 @@ public function buildSql(

unset($params);

$num_tables = count($tables);
for ($i = 0; $i < $num_tables; ++$i) {
foreach ($tables as $table) {
$params = [
'db' => (string) $db_name,
'table' => (string) $tables[$i][self::TBL_NAME],
'db' => $db_name,
'table' => (string) $table[self::TBL_NAME],
];
$tbl_url = 'sql.php' . Url::getCommon($params);
$tbl_struct_url = 'tbl_structure.php' . Url::getCommon($params);
$tbl_ops_url = 'tbl_operations.php' . Url::getCommon($params);

unset($params);

$_table = new Table($tables[$i][self::TBL_NAME], $db_name);
$_table = new Table($table[self::TBL_NAME], $db_name);
if (! $_table->isView()) {
$message .= sprintf(
'<li><a href="%s" title="%s">%s</a> (<a href="%s" title="%s">' . __(
Expand All @@ -1293,22 +1292,22 @@ public function buildSql(
sprintf(
__('Go to table: %s'),
htmlspecialchars(
Util::backquote($tables[$i][self::TBL_NAME])
Util::backquote($table[self::TBL_NAME])
)
),
htmlspecialchars($tables[$i][self::TBL_NAME]),
htmlspecialchars($table[self::TBL_NAME]),
$tbl_struct_url,
sprintf(
__('Structure of %s'),
htmlspecialchars(
Util::backquote($tables[$i][self::TBL_NAME])
Util::backquote($table[self::TBL_NAME])
)
),
$tbl_ops_url,
sprintf(
__('Edit settings for %s'),
htmlspecialchars(
Util::backquote($tables[$i][self::TBL_NAME])
Util::backquote($table[self::TBL_NAME])
)
)
);
Expand All @@ -1319,10 +1318,10 @@ public function buildSql(
sprintf(
__('Go to view: %s'),
htmlspecialchars(
Util::backquote($tables[$i][self::TBL_NAME])
Util::backquote($table[self::TBL_NAME])
)
),
htmlspecialchars($tables[$i][self::TBL_NAME])
htmlspecialchars($table[self::TBL_NAME])
);
}
}
Expand Down
2 changes: 1 addition & 1 deletion libraries/classes/Plugins/Import/ImportMediawiki.php
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,7 @@ private function _delimiterReplace($replace, $subject)
$partial_separator = false;

// Parse text char by char
for ($i = 0; $i < strlen($subject); $i++) {
for ($i = 0, $iMax = strlen($subject); $i < $iMax; $i++) {
$cur_char = $subject[$i];
// Check for separators
if ($cur_char == '|') {
Expand Down
5 changes: 1 addition & 4 deletions libraries/classes/Util.php
Original file line number Diff line number Diff line change
Expand Up @@ -3548,10 +3548,7 @@ public static function getGISDatatypes($upper_case = false)
'geometrycollection',
];
if ($upper_case) {
for ($i = 0, $nb = count($gis_data_types); $i < $nb; $i++) {
$gis_data_types[$i]
= mb_strtoupper($gis_data_types[$i]);
}
$gis_data_types = array_map('mb_strtoupper', $gis_data_types);
}
return $gis_data_types;
}
Expand Down

0 comments on commit 7685733

Please sign in to comment.