diff --git a/src/Moderation/DomainPatternBlocklist.php b/src/Moderation/DomainPatternBlocklist.php
index a57b5f04cb..7b6cf997aa 100644
--- a/src/Moderation/DomainPatternBlocklist.php
+++ b/src/Moderation/DomainPatternBlocklist.php
@@ -73,6 +73,7 @@ class DomainPatternBlocklist
/**
* @param string $pattern
* @param string $reason
+ *
* @return int 0 if the block list couldn't be saved, 1 if the pattern was added, 2 if it was updated in place
*/
public function addPattern(string $pattern, string $reason): int
@@ -105,6 +106,7 @@ class DomainPatternBlocklist
/**
* @param string $pattern
+ *
* @return int 0 if the block list couldn't be saved, 1 if the pattern wasn't found, 2 if it was removed
*/
public function removePattern(string $pattern): int
@@ -123,6 +125,13 @@ class DomainPatternBlocklist
return $found ? ($this->set($blocklist) ? 2 : 0) : 1;
}
+ /**
+ * @param string $filename
+ *
+ * @return void
+ * @throws Exception
+ * @todo maybe throw more explicit exception
+ */
public function exportToFile(string $filename)
{
$fp = fopen($filename, 'w');
@@ -165,6 +174,7 @@ class DomainPatternBlocklist
* Extracts a server domain pattern block list from the provided CSV file name. Deduplicates the list based on patterns.
*
* @param string $filename
+ *
* @return array
* @throws Exception
*/
diff --git a/src/Module/Api/ApiResponse.php b/src/Module/Api/ApiResponse.php
index 0eb2f644b9..960ce3d2cb 100644
--- a/src/Module/Api/ApiResponse.php
+++ b/src/Module/Api/ApiResponse.php
@@ -109,7 +109,7 @@ class ApiResponse extends Response
* @param int $cid Contact ID of template
* @return array
*/
- private function addRSSValues(array $arr, int $cid)
+ private function addRSSValues(array $arr, int $cid): array
{
if (empty($cid)) {
return $arr;
@@ -244,6 +244,8 @@ class ApiResponse extends Response
* Wrapper around exit() for JSON only responses
*
* @param array $data
+ *
+ * @return void
*/
public function exitWithJson(array $data)
{
diff --git a/src/Module/Api/Friendica/Profile/Show.php b/src/Module/Api/Friendica/Profile/Show.php
index 67f4e22edf..6b583b936a 100644
--- a/src/Module/Api/Friendica/Profile/Show.php
+++ b/src/Module/Api/Friendica/Profile/Show.php
@@ -68,10 +68,11 @@ class Show extends BaseApi
/**
* @param array $profile_row array containing data from db table 'profile'
* @param ProfileFields $profileFields
+ *
* @return array
* @throws HTTPException\InternalServerErrorException
*/
- private static function formatProfile($profile_row, ProfileFields $profileFields)
+ private static function formatProfile($profile_row, ProfileFields $profileFields): array
{
$custom_fields = [];
foreach ($profileFields as $profileField) {
diff --git a/src/Module/Api/Twitter/ContactEndpoint.php b/src/Module/Api/Twitter/ContactEndpoint.php
index fb165f1cad..ea2edb30e9 100644
--- a/src/Module/Api/Twitter/ContactEndpoint.php
+++ b/src/Module/Api/Twitter/ContactEndpoint.php
@@ -95,7 +95,7 @@ abstract class ContactEndpoint extends BaseApi
* @throws HTTPException\NotFoundException
* @throws \ImagickException
*/
- protected static function list(array $ids, int $total_count, int $uid, int $cursor = -1, int $count = self::DEFAULT_COUNT, bool $skip_status = false, bool $include_user_entities = true)
+ protected static function list(array $ids, int $total_count, int $uid, int $cursor = -1, int $count = self::DEFAULT_COUNT, bool $skip_status = false, bool $include_user_entities = true): array
{
$return = self::ids($ids, $total_count, $cursor, $count, false);
@@ -128,7 +128,7 @@ abstract class ContactEndpoint extends BaseApi
* @return array
* @throws HTTPException\NotFoundException
*/
- protected static function ids(array $ids, int $total_count, int $cursor = -1, int $count = self::DEFAULT_COUNT, bool $stringify_ids = false)
+ protected static function ids(array $ids, int $total_count, int $cursor = -1, int $count = self::DEFAULT_COUNT, bool $stringify_ids = false): array
{
$next_cursor = 0;
$previous_cursor = 0;
diff --git a/src/Module/Api/Twitter/DirectMessagesEndpoint.php b/src/Module/Api/Twitter/DirectMessagesEndpoint.php
index 5505c6c44c..2f385e3db7 100644
--- a/src/Module/Api/Twitter/DirectMessagesEndpoint.php
+++ b/src/Module/Api/Twitter/DirectMessagesEndpoint.php
@@ -54,6 +54,8 @@ abstract class DirectMessagesEndpoint extends BaseApi
* @param array $request
* @param int $uid
* @param array $condition
+ *
+ * @return void
*/
protected function getMessages(array $request, int $uid, array $condition)
{
diff --git a/src/Module/Xrd.php b/src/Module/Xrd.php
index 1fc0431095..9420a2c61a 100644
--- a/src/Module/Xrd.php
+++ b/src/Module/Xrd.php
@@ -102,9 +102,9 @@ class Xrd extends BaseModule
}
if ($mode == Response::TYPE_XML) {
- self::printXML($alias, DI::baseUrl()->get(), $user, $owner, $avatar);
+ self::printXML($alias, $user, $owner, $avatar);
} else {
- self::printJSON($alias, DI::baseUrl()->get(), $owner, $avatar);
+ self::printJSON($alias, $owner, $avatar);
}
}
@@ -153,8 +153,9 @@ class Xrd extends BaseModule
System::jsonExit($json, 'application/jrd+json; charset=utf-8');
}
- private static function printJSON($alias, $baseURL, $owner, $avatar)
+ private static function printJSON(string $alias, array $owner, array $avatar)
{
+ $baseURL = DI::baseUrl()->get();
$salmon_key = Salmon::salmonKey($owner['spubkey']);
$json = [
@@ -234,8 +235,9 @@ class Xrd extends BaseModule
System::jsonExit($json, 'application/jrd+json; charset=utf-8');
}
- private static function printXML($alias, $baseURL, $user, $owner, $avatar)
+ private static function printXML(string $alias, array $user, array $owner, array $avatar)
{
+ $baseURL = DI::baseUrl()->get();
$salmon_key = Salmon::salmonKey($owner['spubkey']);
$tpl = Renderer::getMarkupTemplate('xrd_person.tpl');
diff --git a/src/Navigation/Notifications/Repository/Notification.php b/src/Navigation/Notifications/Repository/Notification.php
index bb835c33e9..9b7b5c1033 100644
--- a/src/Navigation/Notifications/Repository/Notification.php
+++ b/src/Navigation/Notifications/Repository/Notification.php
@@ -112,6 +112,7 @@ class Notification extends BaseRepository
* Returns only the most recent notifications for the same conversation or contact
*
* @param int $uid
+ *
* @return Collection\Notifications
* @throws Exception
*/
@@ -139,6 +140,7 @@ class Notification extends BaseRepository
* Returns only the most recent notifications for the same conversation or contact
*
* @param int $uid
+ *
* @return Collection\Notifications
* @throws Exception
*/
@@ -201,6 +203,7 @@ class Notification extends BaseRepository
* @param int|null $min_id Retrieve models with an id no fewer than this, as close to it as possible
* @param int|null $max_id Retrieve models with an id no greater than this, as close to it as possible
* @param int $limit
+ *
* @return BaseCollection
* @throws Exception
* @see _selectByBoundaries
diff --git a/src/Navigation/Notifications/Repository/Notify.php b/src/Navigation/Notifications/Repository/Notify.php
index 8fb0f5fb07..813f91263b 100644
--- a/src/Navigation/Notifications/Repository/Notify.php
+++ b/src/Navigation/Notifications/Repository/Notify.php
@@ -88,6 +88,7 @@ class Notify extends BaseRepository
/**
* @param array $condition
* @param array $params
+ *
* @return Entity\Notify
* @throws HTTPException\NotFoundException
*/
@@ -117,6 +118,7 @@ class Notify extends BaseRepository
/**
* @param int $id
+ *
* @return Entity\Notify
* @throws HTTPException\NotFoundException
*/
@@ -153,6 +155,7 @@ class Notify extends BaseRepository
/**
* @param Entity\Notify $Notify
+ *
* @return Entity\Notify
* @throws HTTPException\NotFoundException
* @throws HTTPException\InternalServerErrorException
@@ -459,7 +462,7 @@ class Notify extends BaseRepository
case Model\Notification\Type::SYSTEM:
switch($params['event']) {
- case "SYSTEM_REGISTER_REQUEST":
+ case 'SYSTEM_REGISTER_REQUEST':
$itemlink = $params['link'];
$subject = $l10n->t('[Friendica System Notify]') . ' ' . $l10n->t('registration request');
@@ -479,7 +482,8 @@ class Notify extends BaseRepository
$tsitelink = sprintf($sitelink, $params['link']);
$hsitelink = sprintf($sitelink, ''.$sitename.'
');
break;
- case "SYSTEM_DB_UPDATE_FAIL":
+
+ case 'SYSTEM_DB_UPDATE_FAIL': // @TODO Unused (only here)
break;
}
break;
@@ -492,7 +496,7 @@ class Notify extends BaseRepository
return $this->storeAndSend($params, $sitelink, $tsitelink, $hsitelink, $title, $subject, $preamble, $epreamble, $body, $itemlink, $show_in_notification_page);
}
- private function storeAndSend($params, $sitelink, $tsitelink, $hsitelink, $title, $subject, $preamble, $epreamble, $body, $itemlink, $show_in_notification_page)
+ private function storeAndSend(array $params, string $sitelink, string $tsitelink, string $hsitelink, string $title, string $subject, string $preamble, string $epreamble, string $body, string $itemlink, bool $show_in_notification_page): bool
{
$item_id = $params['item']['id'] ?? 0;
$uri_id = $params['item']['uri-id'] ?? null;
@@ -671,7 +675,7 @@ class Notify extends BaseRepository
return false;
}
- public function createFromNotification(Entity\Notification $Notification)
+ public function createFromNotification(Entity\Notification $Notification): bool
{
$this->logger->info('Start', ['uid' => $Notification->uid, 'id' => $Notification->id, 'type' => $Notification->type]);
diff --git a/src/Protocol/Diaspora.php b/src/Protocol/Diaspora.php
index bec4fd333f..045992333e 100644
--- a/src/Protocol/Diaspora.php
+++ b/src/Protocol/Diaspora.php
@@ -128,7 +128,7 @@ class Diaspora
return false;
}
- $children = $basedom->children('http://salmon-protocol.org/ns/magic-env');
+ $children = $basedom->children(ActivityNamespace::SALMON_ME);
if (sizeof($children) == 0) {
Logger::notice('XML has no children');
@@ -2969,7 +2969,7 @@ class Diaspora
]
];
- $namespaces = ['me' => 'http://salmon-protocol.org/ns/magic-env'];
+ $namespaces = ['me' => ActivityNamespace::SALMON_ME];
return XML::fromArray($xmldata, $xml, false, $namespaces);
}
diff --git a/src/Protocol/Salmon.php b/src/Protocol/Salmon.php
index 7a4e8cc94e..b1bdb67e1d 100644
--- a/src/Protocol/Salmon.php
+++ b/src/Protocol/Salmon.php
@@ -145,14 +145,18 @@ class Salmon
$signature3 = Strings::base64UrlEncode(Crypto::rsaSign($data, $owner['sprvkey']));
// At first try the non compliant method that works for GNU Social
- $xmldata = ["me:env" => ["me:data" => $data,
- "@attributes" => ["type" => $data_type],
- "me:encoding" => $encoding,
- "me:alg" => $algorithm,
- "me:sig" => $signature,
- "@attributes2" => ["key_id" => $keyhash]]];
+ $xmldata = [
+ 'me:env' => [
+ 'me:data' => $data,
+ '@attributes' => ['type' => $data_type],
+ 'me:encoding' => $encoding,
+ 'me:alg' => $algorithm,
+ 'me:sig' => $signature,
+ '@attributes2' => ['key_id' => $keyhash],
+ ]
+ ];
- $namespaces = ["me" => "http://salmon-protocol.org/ns/magic-env"];
+ $namespaces = ['me' => ActivityNamespace::SALMON_ME];
$salmon = XML::fromArray($xmldata, $xml, false, $namespaces);
@@ -170,14 +174,18 @@ class Salmon
Logger::notice('GNU Social salmon failed. Falling back to compliant mode');
// Now try the compliant mode that normally isn't used for GNU Social
- $xmldata = ["me:env" => ["me:data" => $data,
- "@attributes" => ["type" => $data_type],
- "me:encoding" => $encoding,
- "me:alg" => $algorithm,
- "me:sig" => $signature2,
- "@attributes2" => ["key_id" => $keyhash]]];
+ $xmldata = [
+ 'me:env' => [
+ 'me:data' => $data,
+ '@attributes' => ['type' => $data_type],
+ 'me:encoding' => $encoding,
+ 'me:alg' => $algorithm,
+ 'me:sig' => $signature2,
+ '@attributes2' => ['key_id' => $keyhash]
+ ]
+ ];
- $namespaces = ["me" => "http://salmon-protocol.org/ns/magic-env"];
+ $namespaces = ['me' => ActivityNamespace::SALMON_ME];
$salmon = XML::fromArray($xmldata, $xml, false, $namespaces);
@@ -193,14 +201,18 @@ class Salmon
Logger::notice('compliant salmon failed. Falling back to old status.net');
// Last try. This will most likely fail as well.
- $xmldata = ["me:env" => ["me:data" => $data,
- "@attributes" => ["type" => $data_type],
- "me:encoding" => $encoding,
- "me:alg" => $algorithm,
- "me:sig" => $signature3,
- "@attributes2" => ["key_id" => $keyhash]]];
+ $xmldata = [
+ 'me:env' => [
+ 'me:data' => $data,
+ '@attributes' => ['type' => $data_type],
+ 'me:encoding' => $encoding,
+ 'me:alg' => $algorithm,
+ 'me:sig' => $signature3,
+ '@attributes2' => ['key_id' => $keyhash],
+ ]
+ ];
- $namespaces = ["me" => "http://salmon-protocol.org/ns/magic-env"];
+ $namespaces = ['me' => ActivityNamespace::SALMON_ME];
$salmon = XML::fromArray($xmldata, $xml, false, $namespaces);