Merge pull request #10809 from annando/small-as

Code Style: Replace "AS" with "as"
This commit is contained in:
Tobias Diekershoff 2021-10-03 12:49:24 +02:00 committed by GitHub
commit e8becc1538
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 39 additions and 39 deletions

View file

@ -73,7 +73,7 @@ HELP;
$previous = ""; $previous = "";
foreach ($lines AS $line) { foreach ($lines as $line) {
$line = rtrim(trim($line, "\r")); $line = rtrim(trim($line, "\r"));
if (strstr(strtolower($line), "function")) { if (strstr(strtolower($line), "function")) {
@ -147,7 +147,7 @@ HELP;
if ($line != "") { if ($line != "") {
$parameters = explode(",", $line); $parameters = explode(",", $line);
foreach ($parameters AS $parameter) { foreach ($parameters as $parameter) {
$parameter = trim($parameter); $parameter = trim($parameter);
$splitted = explode("=", $parameter); $splitted = explode("=", $parameter);

View file

@ -2103,7 +2103,7 @@ class BBCode
$addon = strtolower($addon); $addon = strtolower($addon);
if (preg_match_all("/\[abstract=(.*?)\](.*?)\[\/abstract\]/ism", $text, $results, PREG_SET_ORDER)) { if (preg_match_all("/\[abstract=(.*?)\](.*?)\[\/abstract\]/ism", $text, $results, PREG_SET_ORDER)) {
foreach ($results AS $result) { foreach ($results as $result) {
$abstracts[strtolower($result[1])] = $result[2]; $abstracts[strtolower($result[1])] = $result[2];
} }
} }

View file

@ -733,7 +733,7 @@ class DBA
$order_string = ''; $order_string = '';
if (isset($params['order'])) { if (isset($params['order'])) {
$order_string = " ORDER BY "; $order_string = " ORDER BY ";
foreach ($params['order'] AS $fields => $order) { foreach ($params['order'] as $fields => $order) {
if ($order === 'RAND()') { if ($order === 'RAND()') {
$order_string .= "RAND(), "; $order_string .= "RAND(), ";
} elseif (!is_int($fields)) { } elseif (!is_int($fields)) {

View file

@ -135,7 +135,7 @@ class DBStructure
return; return;
} }
foreach ($tables AS $table) { foreach ($tables as $table) {
$sql = "ALTER TABLE " . DBA::quoteIdentifier($table['table_name']) . " ENGINE=InnoDB ROW_FORMAT=DYNAMIC;"; $sql = "ALTER TABLE " . DBA::quoteIdentifier($table['table_name']) . " ENGINE=InnoDB ROW_FORMAT=DYNAMIC;";
echo $sql . "\n"; echo $sql . "\n";
@ -271,7 +271,7 @@ class DBStructure
echo "-- " . FRIENDICA_PLATFORM . " " . FRIENDICA_VERSION . " (" . FRIENDICA_CODENAME, ")\n"; echo "-- " . FRIENDICA_PLATFORM . " " . FRIENDICA_VERSION . " (" . FRIENDICA_CODENAME, ")\n";
echo "-- DB_UPDATE_VERSION " . DB_UPDATE_VERSION . "\n"; echo "-- DB_UPDATE_VERSION " . DB_UPDATE_VERSION . "\n";
echo "-- ------------------------------------------\n\n\n"; echo "-- ------------------------------------------\n\n\n";
foreach ($database AS $name => $structure) { foreach ($database as $name => $structure) {
echo "--\n"; echo "--\n";
echo "-- TABLE $name\n"; echo "-- TABLE $name\n";
echo "--\n"; echo "--\n";
@ -368,7 +368,7 @@ class DBStructure
$primary_keys = []; $primary_keys = [];
$foreign_keys = []; $foreign_keys = [];
foreach ($structure["fields"] AS $fieldname => $field) { foreach ($structure["fields"] as $fieldname => $field) {
$sql_rows[] = "`" . DBA::escape($fieldname) . "` " . self::FieldCommand($field); $sql_rows[] = "`" . DBA::escape($fieldname) . "` " . self::FieldCommand($field);
if (!empty($field['primary'])) { if (!empty($field['primary'])) {
$primary_keys[] = $fieldname; $primary_keys[] = $fieldname;
@ -379,7 +379,7 @@ class DBStructure
} }
if (!empty($structure["indexes"])) { if (!empty($structure["indexes"])) {
foreach ($structure["indexes"] AS $indexname => $fieldnames) { foreach ($structure["indexes"] as $indexname => $fieldnames) {
$sql_index = self::createIndex($indexname, $fieldnames, ""); $sql_index = self::createIndex($indexname, $fieldnames, "");
if (!is_null($sql_index)) { if (!is_null($sql_index)) {
$sql_rows[] = $sql_index; $sql_rows[] = $sql_index;
@ -387,7 +387,7 @@ class DBStructure
} }
} }
foreach ($foreign_keys AS $fieldname => $parameters) { foreach ($foreign_keys as $fieldname => $parameters) {
$sql_rows[] = self::foreignCommand($name, $fieldname, $parameters); $sql_rows[] = self::foreignCommand($name, $fieldname, $parameters);
} }
@ -460,7 +460,7 @@ class DBStructure
} }
$names = ""; $names = "";
foreach ($fieldnames AS $fieldname) { foreach ($fieldnames as $fieldname) {
if ($names != "") { if ($names != "") {
$names .= ","; $names .= ",";
} }
@ -569,7 +569,7 @@ class DBStructure
} }
if (DBA::isResult($tables)) { if (DBA::isResult($tables)) {
foreach ($tables AS $table) { foreach ($tables as $table) {
$table = current($table); $table = current($table);
Logger::info('updating structure', ['table' => $table]); Logger::info('updating structure', ['table' => $table]);
@ -591,7 +591,7 @@ class DBStructure
} }
// Compare it // Compare it
foreach ($definition AS $name => $structure) { foreach ($definition as $name => $structure) {
$is_new_table = false; $is_new_table = false;
$sql3 = ""; $sql3 = "";
if (!isset($database[$name])) { if (!isset($database[$name])) {
@ -623,7 +623,7 @@ class DBStructure
} }
} }
// Compare the field structure field by field // Compare the field structure field by field
foreach ($structure["fields"] AS $fieldname => $parameters) { foreach ($structure["fields"] as $fieldname => $parameters) {
if (!isset($database[$name]["fields"][$fieldname])) { if (!isset($database[$name]["fields"][$fieldname])) {
$sql2 = self::addTableField($fieldname, $parameters); $sql2 = self::addTableField($fieldname, $parameters);
if ($sql3 == "") { if ($sql3 == "") {
@ -670,7 +670,7 @@ class DBStructure
* Don't create keys if table is new * Don't create keys if table is new
*/ */
if (!$is_new_table) { if (!$is_new_table) {
foreach ($structure["indexes"] AS $indexname => $fieldnames) { foreach ($structure["indexes"] as $indexname => $fieldnames) {
if (isset($database[$name]["indexes"][$indexname])) { if (isset($database[$name]["indexes"][$indexname])) {
$current_index_definition = implode(",", $database[$name]["indexes"][$indexname]); $current_index_definition = implode(",", $database[$name]["indexes"][$indexname]);
} else { } else {
@ -694,7 +694,7 @@ class DBStructure
// Foreign keys // Foreign keys
// Compare the field structure field by field // Compare the field structure field by field
foreach ($structure["fields"] AS $fieldname => $parameters) { foreach ($structure["fields"] as $fieldname => $parameters) {
if (empty($parameters['foreign'])) { if (empty($parameters['foreign'])) {
continue; continue;
} }
@ -767,7 +767,7 @@ class DBStructure
// Now have a look at the field collations // Now have a look at the field collations
// Compare the field structure field by field // Compare the field structure field by field
foreach ($structure["fields"] AS $fieldname => $parameters) { foreach ($structure["fields"] as $fieldname => $parameters) {
// Compare the field definition // Compare the field definition
$field_definition = ($database[$name]["fields"][$fieldname] ?? '') ?: ['Collation' => '']; $field_definition = ($database[$name]["fields"][$fieldname] ?? '') ?: ['Collation' => ''];
@ -860,7 +860,7 @@ class DBStructure
} }
if (DBA::isResult($indexes)) { if (DBA::isResult($indexes)) {
foreach ($indexes AS $index) { foreach ($indexes as $index) {
if ($index["Key_name"] != "PRIMARY" && $index["Non_unique"] == "0" && !isset($indexdata[$index["Key_name"]])) { if ($index["Key_name"] != "PRIMARY" && $index["Non_unique"] == "0" && !isset($indexdata[$index["Key_name"]])) {
$indexdata[$index["Key_name"]] = ["UNIQUE"]; $indexdata[$index["Key_name"]] = ["UNIQUE"];
} }
@ -881,7 +881,7 @@ class DBStructure
$fielddata = []; $fielddata = [];
if (DBA::isResult($fields)) { if (DBA::isResult($fields)) {
foreach ($fields AS $field) { foreach ($fields as $field) {
$search = ['tinyint(1)', 'tinyint(3) unsigned', 'tinyint(4)', 'smallint(5) unsigned', 'smallint(6)', 'mediumint(8) unsigned', 'mediumint(9)', 'bigint(20)', 'int(10) unsigned', 'int(11)']; $search = ['tinyint(1)', 'tinyint(3) unsigned', 'tinyint(4)', 'smallint(5) unsigned', 'smallint(6)', 'mediumint(8) unsigned', 'mediumint(9)', 'bigint(20)', 'int(10) unsigned', 'int(11)'];
$replace = ['boolean', 'tinyint unsigned', 'tinyint', 'smallint unsigned', 'smallint', 'mediumint unsigned', 'mediumint', 'bigint', 'int unsigned', 'int']; $replace = ['boolean', 'tinyint unsigned', 'tinyint', 'smallint unsigned', 'smallint', 'mediumint unsigned', 'mediumint', 'bigint', 'int unsigned', 'int'];
$field['COLUMN_TYPE'] = str_replace($search, $replace, $field['COLUMN_TYPE']); $field['COLUMN_TYPE'] = str_replace($search, $replace, $field['COLUMN_TYPE']);
@ -1055,7 +1055,7 @@ class DBStructure
$table = DBA::escape($table); $table = DBA::escape($table);
foreach ($columns AS $column) { foreach ($columns as $column) {
$sql = "SHOW COLUMNS FROM `" . $table . "` LIKE '" . $column . "';"; $sql = "SHOW COLUMNS FROM `" . $table . "` LIKE '" . $column . "';";
$stmt = DBA::p($sql); $stmt = DBA::p($sql);

View file

@ -434,7 +434,7 @@ class Database
private function replaceParameters($sql, $args) private function replaceParameters($sql, $args)
{ {
$offset = 0; $offset = 0;
foreach ($args AS $param => $value) { foreach ($args as $param => $value) {
if (is_int($args[$param]) || is_float($args[$param]) || is_bool($args[$param])) { if (is_int($args[$param]) || is_float($args[$param]) || is_bool($args[$param])) {
$replace = intval($args[$param]); $replace = intval($args[$param]);
} elseif (is_null($args[$param])) { } elseif (is_null($args[$param])) {
@ -476,7 +476,7 @@ class Database
// Renumber the array keys to be sure that they fit // Renumber the array keys to be sure that they fit
$i = 0; $i = 0;
$args = []; $args = [];
foreach ($params AS $param) { foreach ($params as $param) {
// Avoid problems with some MySQL servers and boolean values. See issue #3645 // Avoid problems with some MySQL servers and boolean values. See issue #3645
if (is_bool($param)) { if (is_bool($param)) {
$param = (int)$param; $param = (int)$param;
@ -549,7 +549,7 @@ class Database
break; break;
} }
foreach ($args AS $param => $value) { foreach ($args as $param => $value) {
if (is_int($args[$param])) { if (is_int($args[$param])) {
$data_type = PDO::PARAM_INT; $data_type = PDO::PARAM_INT;
} else { } else {
@ -605,7 +605,7 @@ class Database
$param_types = ''; $param_types = '';
$values = []; $values = [];
foreach ($args AS $param => $value) { foreach ($args as $param => $value) {
if (is_int($args[$param])) { if (is_int($args[$param])) {
$param_types .= 'i'; $param_types .= 'i';
} elseif (is_float($args[$param])) { } elseif (is_float($args[$param])) {
@ -958,7 +958,7 @@ class Database
$result = $stmt->result_metadata(); $result = $stmt->result_metadata();
$fields = $result->fetch_fields(); $fields = $result->fetch_fields();
foreach ($cols_num AS $param => $col) { foreach ($cols_num as $param => $col) {
$columns[$fields[$param]->name] = $col; $columns[$fields[$param]->name] = $col;
} }
} }
@ -1293,7 +1293,7 @@ class Database
} }
} }
foreach ($old_fields AS $fieldname => $content) { foreach ($old_fields as $fieldname => $content) {
if (isset($fields[$fieldname]) && !is_null($content) && ($fields[$fieldname] == $content)) { if (isset($fields[$fieldname]) && !is_null($content) && ($fields[$fieldname] == $content)) {
unset($fields[$fieldname]); unset($fields[$fieldname]);
} }

View file

@ -102,7 +102,7 @@ class View
{ {
$database = self::definition($basePath, false); $database = self::definition($basePath, false);
foreach ($database AS $name => $structure) { foreach ($database as $name => $structure) {
echo "--\n"; echo "--\n";
echo "-- VIEW $name\n"; echo "-- VIEW $name\n";
echo "--\n"; echo "--\n";
@ -117,7 +117,7 @@ class View
$r = true; $r = true;
$sql_rows = []; $sql_rows = [];
foreach ($structure["fields"] AS $fieldname => $origin) { foreach ($structure["fields"] as $fieldname => $origin) {
if (is_string($origin)) { if (is_string($origin)) {
$sql_rows[] = $origin . " AS `" . DBA::escape($fieldname) . "`"; $sql_rows[] = $origin . " AS `" . DBA::escape($fieldname) . "`";
} elseif (is_array($origin) && (sizeof($origin) == 2)) { } elseif (is_array($origin) && (sizeof($origin) == 2)) {

View file

@ -45,7 +45,7 @@ class XSocialRelay extends BaseModule
$tagitems = explode(',', $server_tags); $tagitems = explode(',', $server_tags);
/// @todo Check if it was better to use "strtolower" on the tags /// @todo Check if it was better to use "strtolower" on the tags
foreach ($tagitems AS $tag) { foreach ($tagitems as $tag) {
$systemTags[] = trim($tag, '# '); $systemTags[] = trim($tag, '# ');
} }

View file

@ -2719,7 +2719,7 @@ class Diaspora
/// @todo enable support for polls /// @todo enable support for polls
//if ($data->poll) { //if ($data->poll) {
// foreach ($data->poll AS $poll) // foreach ($data->poll as $poll)
// print_r($poll); // print_r($poll);
// die("poll!\n"); // die("poll!\n");
//} //}

View file

@ -111,7 +111,7 @@ class Feed
if ($xpath->query('/atom:feed')->length > 0) { if ($xpath->query('/atom:feed')->length > 0) {
$alternate = XML::getFirstAttributes($xpath, "atom:link[@rel='alternate']"); $alternate = XML::getFirstAttributes($xpath, "atom:link[@rel='alternate']");
if (is_object($alternate)) { if (is_object($alternate)) {
foreach ($alternate AS $attribute) { foreach ($alternate as $attribute) {
if ($attribute->name == "href") { if ($attribute->name == "href") {
$author["author-link"] = $attribute->textContent; $author["author-link"] = $attribute->textContent;
} }
@ -121,7 +121,7 @@ class Feed
if (empty($author["author-link"])) { if (empty($author["author-link"])) {
$self = XML::getFirstAttributes($xpath, "atom:link[@rel='self']"); $self = XML::getFirstAttributes($xpath, "atom:link[@rel='self']");
if (is_object($self)) { if (is_object($self)) {
foreach ($self AS $attribute) { foreach ($self as $attribute) {
if ($attribute->name == "href") { if ($attribute->name == "href") {
$author["author-link"] = $attribute->textContent; $author["author-link"] = $attribute->textContent;
} }
@ -175,7 +175,7 @@ class Feed
$avatar = XML::getFirstAttributes($xpath, "atom:author/atom:link[@rel='avatar']"); $avatar = XML::getFirstAttributes($xpath, "atom:author/atom:link[@rel='avatar']");
if (is_object($avatar)) { if (is_object($avatar)) {
foreach ($avatar AS $attribute) { foreach ($avatar as $attribute) {
if ($attribute->name == "href") { if ($attribute->name == "href") {
$author["author-avatar"] = $attribute->textContent; $author["author-avatar"] = $attribute->textContent;
} }
@ -267,7 +267,7 @@ class Feed
$alternate = XML::getFirstAttributes($xpath, "atom:link", $entry); $alternate = XML::getFirstAttributes($xpath, "atom:link", $entry);
} }
if (is_object($alternate)) { if (is_object($alternate)) {
foreach ($alternate AS $attribute) { foreach ($alternate as $attribute) {
if ($attribute->name == "href") { if ($attribute->name == "href") {
$item["plink"] = $attribute->textContent; $item["plink"] = $attribute->textContent;
} }
@ -383,12 +383,12 @@ class Feed
$attachments = []; $attachments = [];
$enclosures = $xpath->query("enclosure|atom:link[@rel='enclosure']", $entry); $enclosures = $xpath->query("enclosure|atom:link[@rel='enclosure']", $entry);
foreach ($enclosures AS $enclosure) { foreach ($enclosures as $enclosure) {
$href = ""; $href = "";
$length = null; $length = null;
$type = null; $type = null;
foreach ($enclosure->attributes AS $attribute) { foreach ($enclosure->attributes as $attribute) {
if (in_array($attribute->name, ["url", "href"])) { if (in_array($attribute->name, ["url", "href"])) {
$href = $attribute->textContent; $href = $attribute->textContent;
} elseif ($attribute->name == "length") { } elseif ($attribute->name == "length") {
@ -405,7 +405,7 @@ class Feed
$taglist = []; $taglist = [];
$categories = $xpath->query("category", $entry); $categories = $xpath->query("category", $entry);
foreach ($categories AS $category) { foreach ($categories as $category) {
$taglist[] = $category->nodeValue; $taglist[] = $category->nodeValue;
} }
@ -459,7 +459,7 @@ class Feed
$preview = ''; $preview = '';
if (!empty($contact["fetch_further_information"]) && ($contact["fetch_further_information"] < 3)) { if (!empty($contact["fetch_further_information"]) && ($contact["fetch_further_information"] < 3)) {
// Handle enclosures and treat them as preview picture // Handle enclosures and treat them as preview picture
foreach ($attachments AS $attachment) { foreach ($attachments as $attachment) {
if ($attachment["mimetype"] == "image/jpeg") { if ($attachment["mimetype"] == "image/jpeg") {
$preview = $attachment["url"]; $preview = $attachment["url"];
} }

View file

@ -77,7 +77,7 @@ class Relay
if ($scope == SR_SCOPE_TAGS) { if ($scope == SR_SCOPE_TAGS) {
$server_tags = $config->get('system', 'relay_server_tags'); $server_tags = $config->get('system', 'relay_server_tags');
$tagitems = explode(',', mb_strtolower($server_tags)); $tagitems = explode(',', mb_strtolower($server_tags));
foreach ($tagitems AS $tag) { foreach ($tagitems as $tag) {
$systemTags[] = trim($tag, '# '); $systemTags[] = trim($tag, '# ');
} }
@ -90,7 +90,7 @@ class Relay
$deny_tags = $config->get('system', 'relay_deny_tags'); $deny_tags = $config->get('system', 'relay_deny_tags');
$tagitems = explode(',', mb_strtolower($deny_tags)); $tagitems = explode(',', mb_strtolower($deny_tags));
foreach ($tagitems AS $tag) { foreach ($tagitems as $tag) {
$tag = trim($tag, '# '); $tag = trim($tag, '# ');
$denyTags[] = $tag; $denyTags[] = $tag;
} }