1
1
Fork 0
- added some type-hints
- replaced most double-quotes (only Diaspora.php, later more) with single
- added some documentation
- normalized indenting in Diaspora.php (I hope I got all?)
This commit is contained in:
Roland Häder 2022-06-18 05:01:51 +02:00
parent 51f43278d6
commit adb4aea6ad
Signed by: roland
GPG key ID: C82EDE5DDFA0BA77
5 changed files with 604 additions and 565 deletions

View file

@ -45,7 +45,7 @@ class Widget
* @return string
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public static function follow(string $value = ""): string
public static function follow(string $value = ''): string
{
return Renderer::replaceMacros(Renderer::getMarkupTemplate('widget/follow.tpl'), array(
'$connect' => DI::l10n()->t('Add New Contact'),

View file

@ -1553,11 +1553,11 @@ class Contact
/**
* Blocks a contact
*
* @param int $cid
* @return bool
* @throws \Exception
* @param int $cid Contact id to block
* @param string $reason Block reason
* @return bool Whether it was successful
*/
public static function block($cid, $reason = null)
public static function block(int $cid, string $reason = null): bool
{
$return = self::update(['blocked' => true, 'block_reason' => $reason], ['id' => $cid]);
@ -1567,11 +1567,10 @@ class Contact
/**
* Unblocks a contact
*
* @param int $cid
* @return bool
* @throws \Exception
* @param int $cid Contact id to unblock
* @return bool Whether it was successfull
*/
public static function unblock($cid)
public static function unblock(int $cid): bool
{
$return = self::update(['blocked' => false, 'block_reason' => null], ['id' => $cid]);
@ -1581,7 +1580,7 @@ class Contact
/**
* Ensure that cached avatar exist
*
* @param integer $cid
* @param integer $cid Contact id
*/
public static function checkAvatarCache(int $cid)
{
@ -1621,7 +1620,7 @@ class Contact
* @param bool $no_update Don't perfom an update if no cached avatar was found
* @return string photo path
*/
private static function getAvatarPath(array $contact, string $size, $no_update = false)
private static function getAvatarPath(array $contact, string $size, bool $no_update = false): string
{
$contact = self::checkAvatarCacheByArray($contact, $no_update);
@ -1655,7 +1654,7 @@ class Contact
* @param bool $no_update Don't perfom an update if no cached avatar was found
* @return string photo path
*/
public static function getPhoto(array $contact, bool $no_update = false)
public static function getPhoto(array $contact, bool $no_update = false): string
{
return self::getAvatarPath($contact, Proxy::SIZE_SMALL, $no_update);
}
@ -1667,7 +1666,7 @@ class Contact
* @param bool $no_update Don't perfom an update if no cached avatar was found
* @return string photo path
*/
public static function getThumb(array $contact, bool $no_update = false)
public static function getThumb(array $contact, bool $no_update = false): string
{
return self::getAvatarPath($contact, Proxy::SIZE_THUMB, $no_update);
}
@ -1679,7 +1678,7 @@ class Contact
* @param bool $no_update Don't perfom an update if no cached avatar was found
* @return string photo path
*/
public static function getMicro(array $contact, bool $no_update = false)
public static function getMicro(array $contact, bool $no_update = false): string
{
return self::getAvatarPath($contact, Proxy::SIZE_MICRO, $no_update);
}
@ -1691,7 +1690,7 @@ class Contact
* @param bool $no_update Don't perfom an update if no cached avatar was found
* @return array contact array with avatar cache fields
*/
private static function checkAvatarCacheByArray(array $contact, bool $no_update = false)
private static function checkAvatarCacheByArray(array $contact, bool $no_update = false): array
{
$update = false;
$contact_fields = [];
@ -1797,7 +1796,7 @@ class Contact
* @param string $size Size of the avatar picture
* @return string avatar URL
*/
public static function getDefaultAvatar(array $contact, string $size)
public static function getDefaultAvatar(array $contact, string $size): string
{
switch ($size) {
case Proxy::SIZE_MICRO:

View file

@ -166,7 +166,7 @@ class Directory extends BaseModule
'img_hover' => $contact['name'],
'name' => $contact['name'],
'details' => $details,
'account_type' => (!empty($contact['contact-type']) ? Model\Contact::getAccountType($contact['contact-type']) : ''),
'account_type' => Model\Contact::getAccountType($contact['contact-type'] ?? ''),
'profile' => $profile,
'location' => $location_e,
'tags' => $contact['pub_keywords'],

View file

@ -348,7 +348,7 @@ class DFRN
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
* @todo Find proper type-hint for returned type
*/
private static function addHeader(DOMDocument $doc, array $owner, string $authorelement, string $alternatelink = "", bool $public = false)
private static function addHeader(DOMDocument $doc, array $owner, string $authorelement, string $alternatelink = '', bool $public = false)
{
if ($alternatelink == "") {
@ -1063,7 +1063,7 @@ class DFRN
* @throws \ImagickException
* @todo Find good type-hints for all parameter
*/
private static function fetchauthor(\DOMXPath $xpath, \DOMNode $context, array $importer, string $element, bool $onlyfetch, string $xml = ""): array
private static function fetchauthor(\DOMXPath $xpath, \DOMNode $context, array $importer, string $element, bool $onlyfetch, string $xml = ''): array
{
$author = [];
$author["name"] = XML::getFirstNodeValue($xpath, $element."/atom:name/text()", $context);

File diff suppressed because it is too large Load diff