Fix code style

This commit is contained in:
Art4 2025-03-17 07:38:53 +00:00
parent 77e785dd7d
commit 674b6c55de
18 changed files with 81 additions and 87 deletions

View file

@ -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']);

View file

@ -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);
}

View file

@ -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 [];
}

View file

@ -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(

View file

@ -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;

View file

@ -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']);

View file

@ -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) {

View file

@ -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'], '/'))) : '';

View file

@ -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);
}
}

View file

@ -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;

View file

@ -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,
];

View file

@ -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

View file

@ -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;
}
}

View file

@ -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 = '';
}
}
}

View file

@ -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;

View file

@ -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);

View file

@ -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);

View file

@ -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) {