From 674b6c55def262df89fb21959003e91507a0d95c Mon Sep 17 00:00:00 2001 From: Art4 Date: Mon, 17 Mar 2025 07:38:53 +0000 Subject: [PATCH] Fix code style --- src/Console/PoToPhp.php | 10 ++--- .../Introduction/Repository/Introduction.php | 5 ++- .../Repository/UserDefinedChannel.php | 6 +-- src/Content/Post/Entity/PostMedia.php | 7 ++-- src/Content/Post/Repository/PostMedia.php | 2 +- src/Core/Hook.php | 2 +- src/Database/Database.php | 34 ++++++++-------- src/Factory/Api/Mastodon/Attachment.php | 2 +- src/Factory/Api/Twitter/Status.php | 4 +- src/Module/Filer/RemoveTag.php | 2 +- .../Notifications/Repository/Notification.php | 14 +++---- .../ValueObject/Introduction.php | 40 +++++++++---------- .../HTTPClient/Response/CurlResult.php | 6 +-- src/Object/Api/Friendica/Notification.php | 6 +-- src/Object/Api/Mastodon/Field.php | 2 +- .../Diaspora/Repository/DiasporaContact.php | 4 +- .../Repository/PermissionSet.php | 4 +- src/Security/Security.php | 18 +++------ 18 files changed, 81 insertions(+), 87 deletions(-) diff --git a/src/Console/PoToPhp.php b/src/Console/PoToPhp.php index a99cd6e806..480da23c46 100644 --- a/src/Console/PoToPhp.php +++ b/src/Console/PoToPhp.php @@ -134,7 +134,7 @@ HELP; ); $fnname = 'string_plural_select_' . $lang; - $out = 'if(! function_exists("' . $fnname . '")) {' . "\n"; + $out = 'if(! function_exists("' . $fnname . '")) {' . "\n"; $out .= 'function ' . $fnname . '($n){' . "\n"; $out .= ' $n = intval($n);' . "\n"; $out .= ' ' . $return . "\n"; @@ -192,13 +192,13 @@ HELP; if ($q === false || $s < $q) { list($then, $else) = explode(':', $string, 2); - $node['then'] = $then; - $parsedElse = []; + $node['then'] = $then; + $parsedElse = []; self::parse($else, $parsedElse); $node['else'] = $parsedElse; } else { list($if, $thenelse) = explode('?', $string, 2); - $node['if'] = $if; + $node['if'] = $if; self::parse($thenelse, $node); } } @@ -214,7 +214,7 @@ HELP; private static function render($tree): string { if (is_array($tree)) { - $if = trim($tree['if']); + $if = trim($tree['if']); $then = trim($tree['then']); $else = self::render($tree['else']); diff --git a/src/Contact/Introduction/Repository/Introduction.php b/src/Contact/Introduction/Repository/Introduction.php index dec2f2a246..a624017a2a 100644 --- a/src/Contact/Introduction/Repository/Introduction.php +++ b/src/Contact/Introduction/Repository/Introduction.php @@ -83,7 +83,10 @@ class Introduction extends BaseRepository $BaseCollection = parent::_selectByBoundaries( ['`uid` = ? AND NOT `ignore`',$uid], ['order' => ['id' => 'DESC']], - $min_id, $max_id, $limit); + $min_id, + $max_id, + $limit + ); } catch (\Exception $e) { throw new IntroductionPersistenceException(sprintf('Cannot select Introductions for used %d', $uid), $e); } diff --git a/src/Content/Conversation/Repository/UserDefinedChannel.php b/src/Content/Conversation/Repository/UserDefinedChannel.php index b9eecbf53c..b256e34e56 100644 --- a/src/Content/Conversation/Repository/UserDefinedChannel.php +++ b/src/Content/Conversation/Repository/UserDefinedChannel.php @@ -169,14 +169,14 @@ class UserDefinedChannel extends BaseRepository $uids = array_column($users, 'uid'); $usercondition = ['uid' => $uids]; - $condition = DBA::mergeConditions($usercondition, ["`languages` != ? AND `include-tags` = ? AND `full-text-search` = ? AND `circle` = ?", '', '', '', 0]); + $condition = DBA::mergeConditions($usercondition, ["`languages` != ? AND `include-tags` = ? AND `full-text-search` = ? AND `circle` = ?", '', '', '', 0]); foreach ($this->select($condition) as $channel) { if (!empty($channel->languages) && in_array($language, $channel->languages)) { return true; } } - $search = ''; + $search = ''; $condition = DBA::mergeConditions($usercondition, ["`full-text-search` != ? AND `circle` = ? AND `valid`", '', 0]); foreach ($this->select($condition) as $channel) { $search .= '(' . $channel->fullTextSearch . ') '; @@ -201,7 +201,7 @@ class UserDefinedChannel extends BaseRepository { $condition = $this->getUserCondition(); $condition = DBA::mergeConditions($condition, ["`account-type` IN (?, ?) AND `uid` != ?", User::ACCOUNT_TYPE_RELAY, User::ACCOUNT_TYPE_COMMUNITY, 0]); - $users = $this->db->selectToArray('user', ['uid'], $condition); + $users = $this->db->selectToArray('user', ['uid'], $condition); if (empty($users)) { return []; } diff --git a/src/Content/Post/Entity/PostMedia.php b/src/Content/Post/Entity/PostMedia.php index 59d1ec9c57..b06e258710 100644 --- a/src/Content/Post/Entity/PostMedia.php +++ b/src/Content/Post/Entity/PostMedia.php @@ -121,8 +121,7 @@ class PostMedia extends BaseEntity ?UriInterface $publisherImage = null, ?string $blurhash = null, int $id = null - ) - { + ) { $this->uriId = $uriId; $this->url = $url; $this->type = $type; @@ -223,8 +222,8 @@ class PostMedia extends BaseEntity if ($newWidth && $newHeight && $size) { $dimensionts = Images::getScalingDimensions($newWidth, $newHeight, Proxy::getPixelsFromSize($size)); - $newWidth = $dimensionts['width']; - $newHeight = $dimensionts['height']; + $newWidth = $dimensionts['width']; + $newHeight = $dimensionts['height']; } return new self( diff --git a/src/Content/Post/Repository/PostMedia.php b/src/Content/Post/Repository/PostMedia.php index 9d6b09cb5f..d28d15bca7 100644 --- a/src/Content/Post/Repository/PostMedia.php +++ b/src/Content/Post/Repository/PostMedia.php @@ -167,7 +167,7 @@ class PostMedia extends BaseRepository // Peertube videos are delivered in many different resolutions. We pick a moderate one. // Since only Peertube provides a "height" parameter, this wouldn't be executed // when someone for example on Mastodon was sharing multiple videos in a single post. - $heights[$PostMedia->height] = (string)$PostMedia->url; + $heights[$PostMedia->height] = (string)$PostMedia->url; $video[(string) $PostMedia->url] = $PostMedia; } else { $attachments['visual'][] = $PostMedia; diff --git a/src/Core/Hook.php b/src/Core/Hook.php index 8c9f3ba910..555b6b5d9f 100644 --- a/src/Core/Hook.php +++ b/src/Core/Hook.php @@ -40,7 +40,7 @@ class Hook public static function loadHooks() { self::$hooks = []; - $stmt = DBA::select('hook', ['hook', 'file', 'function'], [], ['order' => ['priority' => 'desc', 'file']]); + $stmt = DBA::select('hook', ['hook', 'file', 'function'], [], ['order' => ['priority' => 'desc', 'file']]); while ($hook = DBA::fetch($stmt)) { self::add($hook['hook'], $hook['file'], $hook['function']); diff --git a/src/Database/Database.php b/src/Database/Database.php index 6f42756302..88aa636fd3 100644 --- a/src/Database/Database.php +++ b/src/Database/Database.php @@ -62,15 +62,15 @@ class Database protected $server_info = ''; /** @var PDO|mysqli|null */ protected $connection; - protected $driver = ''; + protected $driver = ''; protected $pdo_emulate_prepares = false; - private $error = ''; - private $errorno = 0; - private $affected_rows = 0; - protected $in_transaction = false; - protected $in_retrial = false; - protected $testmode = false; - private $relation = []; + private $error = ''; + private $errorno = 0; + private $affected_rows = 0; + protected $in_transaction = false; + protected $in_retrial = false; + protected $testmode = false; + private $relation = []; /** @var DbaDefinition */ protected $dbaDefinition; /** @var ViewDefinition */ @@ -86,7 +86,7 @@ class Database $this->viewDefinition = $viewDefinition; // Use dummy values - necessary for the first factory call of the logger itself - $this->logger = new NullLogger(); + $this->logger = new NullLogger(); $this->profiler = new Profiler($config); $this->connect(); @@ -630,7 +630,7 @@ class Database } elseif (is_string($args[$param])) { $param_types .= 's'; } elseif (is_object($args[$param]) && method_exists($args[$param], '__toString')) { - $param_types .= 's'; + $param_types .= 's'; $args[$param] = (string)$args[$param]; } else { $param_types .= 'b'; @@ -677,9 +677,9 @@ class Database } $this->logger->error('DB Error', [ - 'code' => $errorno, - 'error' => $error, - 'params' => $this->replaceParameters($sql, $args), + 'code' => $errorno, + 'error' => $error, + 'params' => $this->replaceParameters($sql, $args), ]); // On a lost connection we try to reconnect - but only once. @@ -784,9 +784,9 @@ class Database } $this->logger->error('DB Error', [ - 'code' => $errorno, - 'error' => $error, - 'params' => $this->replaceParameters($sql, $params), + 'code' => $errorno, + 'error' => $error, + 'params' => $this->replaceParameters($sql, $params), ]); // On a lost connection we simply quit. @@ -1335,7 +1335,7 @@ class Database return true; } - $fields = $this->castFields($table, $fields); + $fields = $this->castFields($table, $fields); $direct_fields = []; foreach ($fields as $key => $value) { diff --git a/src/Factory/Api/Mastodon/Attachment.php b/src/Factory/Api/Mastodon/Attachment.php index bd16b61b38..65eeec22eb 100644 --- a/src/Factory/Api/Mastodon/Attachment.php +++ b/src/Factory/Api/Mastodon/Attachment.php @@ -65,7 +65,7 @@ class Attachment extends BaseFactory * @return \Friendica\Object\Api\Mastodon\Attachment * @throws InternalServerErrorException */ - private function createFromMediaArray(array $attachment): \Friendica\Object\Api\Mastodon\Attachment + private function createFromMediaArray(array $attachment): \Friendica\Object\Api\Mastodon\Attachment { $filetype = !empty($attachment['mimetype']) ? strtolower(substr($attachment['mimetype'], 0, strpos($attachment['mimetype'], '/'))) : ''; diff --git a/src/Factory/Api/Twitter/Status.php b/src/Factory/Api/Twitter/Status.php index b77ee801f7..7d235cc870 100644 --- a/src/Factory/Api/Twitter/Status.php +++ b/src/Factory/Api/Twitter/Status.php @@ -111,7 +111,7 @@ class Status extends BaseFactory */ private function createFromArray(array $item, int $uid, bool $include_entities): \Friendica\Object\Api\Twitter\Status { - $item = Post\Media::addHTMLAttachmentToItem($item); + $item = Post\Media::addHTMLAttachmentToItem($item); $author = $this->twitterUser->createFromContactId($item['author-id'], $uid, true); if (!empty($item['causer-id']) && ($item['post-reason'] == Item::PR_ANNOUNCEMENT)) { @@ -203,6 +203,6 @@ class Status extends BaseFactory $entities = []; } - return new \Friendica\Object\Api\Twitter\Status($text, $statusnetHtml, $friendicaHtml, $item, $author, $owner, $retweeted, $quoted, $geo, $friendica_activities, $entities, $attachments, $friendica_comments, $liked); + return new \Friendica\Object\Api\Twitter\Status($text, $statusnetHtml, $friendicaHtml, $item, $author, $owner, $retweeted, $quoted, $geo, $friendica_activities, $entities, $attachments, $friendica_comments, $liked); } } diff --git a/src/Module/Filer/RemoveTag.php b/src/Module/Filer/RemoveTag.php index 28666c8a44..eb20efe0bb 100644 --- a/src/Module/Filer/RemoveTag.php +++ b/src/Module/Filer/RemoveTag.php @@ -71,7 +71,7 @@ class RemoveTag extends BaseModule $item_id = $this->parameters['id'] ?? 0; $term = trim($request['term'] ?? ''); - $cat = trim($request['cat'] ?? ''); + $cat = trim($request['cat'] ?? ''); if (!empty($cat)) { $type = Post\Category::CATEGORY; diff --git a/src/Navigation/Notifications/Repository/Notification.php b/src/Navigation/Notifications/Repository/Notification.php index 49703bc1f9..85c8895135 100644 --- a/src/Navigation/Notifications/Repository/Notification.php +++ b/src/Navigation/Notifications/Repository/Notification.php @@ -127,23 +127,23 @@ class Notification extends BaseRepository $values = [$uid]; $type_condition = ''; - $notify_type = $this->pconfig->get($uid, 'system', 'notify_type'); + $notify_type = $this->pconfig->get($uid, 'system', 'notify_type'); if (!is_null($notify_type)) { $type_condition = 'AND `type` & ? != 0'; - $values[] = $notify_type | UserNotification::TYPE_SHARED | UserNotification::TYPE_FOLLOW; + $values[] = $notify_type | UserNotification::TYPE_SHARED | UserNotification::TYPE_FOLLOW; } $like_condition = ''; if (!$this->pconfig->get($uid, 'system', 'notify_like')) { $like_condition = 'AND NOT `vid` IN (?, ?)'; - $values[] = Verb::getID(Activity::LIKE); - $values[] = Verb::getID(Activity::DISLIKE); + $values[] = Verb::getID(Activity::LIKE); + $values[] = Verb::getID(Activity::DISLIKE); } $announce_condition = ''; if (!$this->pconfig->get($uid, 'system', 'notify_announce')) { $announce_condition = 'AND vid != ?'; - $values[] = Verb::getID(Activity::ANNOUNCE); + $values[] = Verb::getID(Activity::ANNOUNCE); } $rows = $this->db->p(" @@ -253,12 +253,12 @@ class Notification extends BaseRepository public function deleteForItem(int $itemUriId): bool { $conditionTarget = [ - 'vid' => Verb::getID(Activity::POST), + 'vid' => Verb::getID(Activity::POST), 'target-uri-id' => $itemUriId, ]; $conditionParent = [ - 'vid' => Verb::getID(Activity::POST), + 'vid' => Verb::getID(Activity::POST), 'parent-uri-id' => $itemUriId, ]; diff --git a/src/Navigation/Notifications/ValueObject/Introduction.php b/src/Navigation/Notifications/ValueObject/Introduction.php index 6e2c24d340..36e490d0be 100644 --- a/src/Navigation/Notifications/ValueObject/Introduction.php +++ b/src/Navigation/Notifications/ValueObject/Introduction.php @@ -63,30 +63,30 @@ class Introduction implements \JsonSerializable public function __construct(array $data = []) { - $this->label = $data['label'] ?? ''; - $this->type = $data['str_type'] ?? ''; - $this->intro_id = $data['intro_id'] ?? -1; - $this->madeBy = $data['madeBy'] ?? ''; - $this->madeByUrl = $data['madeByUrl'] ?? ''; - $this->madeByZrl = $data['madeByZrl'] ?? ''; - $this->madeByAddr = $data['madeByAddr'] ?? ''; - $this->contactId = $data['contactId'] ?? -1; - $this->photo = $data['photo'] ?? ''; - $this->name = $data['name'] ?? ''; - $this->url = $data['url'] ?? ''; - $this->zrl = $data['zrl'] ?? ''; - $this->hidden = $data['hidden'] ?? false; + $this->label = $data['label'] ?? ''; + $this->type = $data['str_type'] ?? ''; + $this->intro_id = $data['intro_id'] ?? -1; + $this->madeBy = $data['madeBy'] ?? ''; + $this->madeByUrl = $data['madeByUrl'] ?? ''; + $this->madeByZrl = $data['madeByZrl'] ?? ''; + $this->madeByAddr = $data['madeByAddr'] ?? ''; + $this->contactId = $data['contactId'] ?? -1; + $this->photo = $data['photo'] ?? ''; + $this->name = $data['name'] ?? ''; + $this->url = $data['url'] ?? ''; + $this->zrl = $data['zrl'] ?? ''; + $this->hidden = $data['hidden'] ?? false; $this->postNewFriend = $data['postNewFriend'] ?? ''; - $this->knowYou = $data['knowYou'] ?? false; - $this->note = $data['note'] ?? ''; - $this->request = $data['request'] ?? ''; + $this->knowYou = $data['knowYou'] ?? false; + $this->note = $data['note'] ?? ''; + $this->request = $data['request'] ?? ''; $this->dfrnId = -1; - $this->addr = $data['addr'] ?? ''; - $this->network = $data['network'] ?? ''; - $this->uid = $data['uid'] ?? -1; + $this->addr = $data['addr'] ?? ''; + $this->network = $data['network'] ?? ''; + $this->uid = $data['uid'] ?? -1; $this->keywords = $data['keywords'] ?? ''; $this->location = $data['location'] ?? ''; - $this->about = $data['about'] ?? ''; + $this->about = $data['about'] ?? ''; } public function getLabel(): string diff --git a/src/Network/HTTPClient/Response/CurlResult.php b/src/Network/HTTPClient/Response/CurlResult.php index 30b8be3830..a38de01336 100644 --- a/src/Network/HTTPClient/Response/CurlResult.php +++ b/src/Network/HTTPClient/Response/CurlResult.php @@ -225,11 +225,11 @@ class CurlResult implements ICanHandleHttpResponses } } - $this->redirectUrl = (string)Uri::fromParts((array)$redirect_parts); - $this->isRedirectUrl = true; + $this->redirectUrl = (string)Uri::fromParts((array)$redirect_parts); + $this->isRedirectUrl = true; $this->redirectIsPermanent = $this->returnCode == 301 || $this->returnCode == 308; } else { - $this->isRedirectUrl = false; + $this->isRedirectUrl = false; $this->redirectIsPermanent = false; } } diff --git a/src/Object/Api/Friendica/Notification.php b/src/Object/Api/Friendica/Notification.php index f83cd9cc2c..2a49ea770c 100644 --- a/src/Object/Api/Friendica/Notification.php +++ b/src/Object/Api/Friendica/Notification.php @@ -84,15 +84,15 @@ class Notification extends BaseDataTransferObject $this->date_rel = Temporal::getRelativeDate($this->date); try { - $this->msg_html = BBCode::convertForUriId($notify->uriId, $this->msg, BBCode::EXTERNAL); + $this->msg_html = BBCode::convertForUriId($notify->uriId, $this->msg, BBCode::EXTERNAL); } catch (\Exception $e) { - $this->msg_html = ''; + $this->msg_html = ''; } try { $this->msg_plain = explode("\n", trim(HTML::toPlaintext($this->msg_html, 0)))[0]; } catch (\Exception $e) { - $this->msg_plain = ''; + $this->msg_plain = ''; } } } diff --git a/src/Object/Api/Mastodon/Field.php b/src/Object/Api/Mastodon/Field.php index 846aac4d0f..092f33b361 100644 --- a/src/Object/Api/Mastodon/Field.php +++ b/src/Object/Api/Mastodon/Field.php @@ -25,7 +25,7 @@ class Field extends BaseDataTransferObject public function __construct(string $name, string $value) { - $this->name = $name; + $this->name = $name; $this->value = $value; // Link verification unsupported $this->verified_at = null; diff --git a/src/Protocol/Diaspora/Repository/DiasporaContact.php b/src/Protocol/Diaspora/Repository/DiasporaContact.php index 6d92b066f8..5cf05b8aa0 100644 --- a/src/Protocol/Diaspora/Repository/DiasporaContact.php +++ b/src/Protocol/Diaspora/Repository/DiasporaContact.php @@ -245,8 +245,8 @@ class DiasporaContact extends BaseRepository $uriId, new DateTime($contact['created'] ?? 'now', new DateTimeZone('UTC')), $interacting_count ?? 0, - $interacted_count ?? 0, - $post_count ?? 0 + $interacted_count ?? 0, + $post_count ?? 0 ); $DiasporaContact = $this->save($DiasporaContact); diff --git a/src/Security/PermissionSet/Repository/PermissionSet.php b/src/Security/PermissionSet/Repository/PermissionSet.php index c77baf0f2e..42b6219e9c 100644 --- a/src/Security/PermissionSet/Repository/PermissionSet.php +++ b/src/Security/PermissionSet/Repository/PermissionSet.php @@ -119,8 +119,8 @@ class PermissionSet extends BaseRepository $circle_ids = []; if (!empty($user_contact_str) && $this->db->exists('contact', [ - 'id' => $cid, - 'uid' => $uid, + 'id' => $cid, + 'uid' => $uid, 'blocked' => false ])) { $circle_ids = Circle::getIdsByContactId($cid); diff --git a/src/Security/Security.php b/src/Security/Security.php index 9056596f27..f04af42061 100644 --- a/src/Security/Security.php +++ b/src/Security/Security.php @@ -79,33 +79,25 @@ class Security */ public static function getPermissionsSQLByUserId(int $owner_id, bool $accessible = false) { - $local_user = DI::userSession()->getLocalUserId(); + $local_user = DI::userSession()->getLocalUserId(); $remote_contact = DI::userSession()->getRemoteContactID($owner_id); - $acc_sql = ''; + $acc_sql = ''; if ($accessible) { $acc_sql = ' OR `accessible`'; } - /* - * Construct permissions - * - * default permissions - anonymous user - */ + // Construct permissions: default permissions - anonymous user $sql = " AND (allow_cid = '' AND allow_gid = '' AND deny_cid = '' AND deny_gid = ''" . $acc_sql . ") "; - /* - * Profile owner - everything is visible - */ if ($local_user && $local_user == $owner_id) { + // Profile owner - everything is visible $sql = ''; - /* - * Authenticated visitor. Load the circles the visitor belongs to. - */ } elseif ($remote_contact) { + // Authenticated visitor. Load the circles the visitor belongs to. $circleIds = '<<>>'; // should be impossible to match foreach (Circle::getIdsByContactId($remote_contact) as $circleId) {