1
0
Fork 0

Continued:

- more type-hints
- fixed incompatible method declarations
This commit is contained in:
Roland Häder 2022-06-16 18:28:38 +02:00
parent 1edc6b3c3b
commit 40d7f29a11
6 changed files with 37 additions and 35 deletions

View file

@ -123,7 +123,7 @@ class Avatar
return $fields; return $fields;
} }
private static function getFilename(string $url) private static function getFilename(string $url): string
{ {
$guid = Item::guidFromUri($url, parse_url($url, PHP_URL_HOST)); $guid = Item::guidFromUri($url, parse_url($url, PHP_URL_HOST));

View file

@ -49,7 +49,7 @@ class BoundariesPager extends Pager
* @param string $last_item_id The id† of the last item in the displayed item list * @param string $last_item_id The id† of the last item in the displayed item list
* @param integer $itemsPerPage An optional number of items per page to override the default value * @param integer $itemsPerPage An optional number of items per page to override the default value
*/ */
public function __construct(L10n $l10n, $queryString, $first_item_id = null, $last_item_id = null, $itemsPerPage = 50) public function __construct(L10n $l10n, string $queryString, string $first_item_id = null, string $last_item_id = null, int $itemsPerPage = 50)
{ {
parent::__construct($l10n, $queryString, $itemsPerPage); parent::__construct($l10n, $queryString, $itemsPerPage);
@ -102,7 +102,7 @@ class BoundariesPager extends Pager
* @return string HTML string of the pager * @return string HTML string of the pager
* @throws \Exception * @throws \Exception
*/ */
public function renderMinimal(int $itemCount) public function renderMinimal(int $itemCount): string
{ {
$displayedItemCount = max(0, intval($itemCount)); $displayedItemCount = max(0, intval($itemCount));

View file

@ -41,7 +41,7 @@ class ContactSelector
* @param boolean $disabled optional, default false * @param boolean $disabled optional, default false
* @return string * @return string
*/ */
public static function pollInterval($current, $disabled = false) public static function pollInterval(string $current, bool $disabled = false): string
{ {
$dis = (($disabled) ? ' disabled="disabled" ' : ''); $dis = (($disabled) ? ' disabled="disabled" ' : '');
$o = ''; $o = '';
@ -84,7 +84,7 @@ class ContactSelector
* @return string Server URL * @return string Server URL
* @throws \Exception * @throws \Exception
*/ */
private static function getServerURLForProfile($profile) private static function getServerURLForProfile(string $profile): string
{ {
if (!empty(self::$server_url[$profile])) { if (!empty(self::$server_url[$profile])) {
return self::$server_url[$profile]; return self::$server_url[$profile];
@ -114,10 +114,11 @@ class ContactSelector
* @param string $network network of the contact * @param string $network network of the contact
* @param string $profile optional, default empty * @param string $profile optional, default empty
* @param string $protocol (Optional) Protocol that is used for the transmission * @param string $protocol (Optional) Protocol that is used for the transmission
* @param int $gsid ??? (@TODO)
* @return string * @return string
* @throws \Friendica\Network\HTTPException\InternalServerErrorException * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/ */
public static function networkToName($network, $profile = '', $protocol = '', $gsid = 0) public static function networkToName(string $network, string $profile = '', string $protocol = '', int $gsid = 0): string
{ {
$nets = [ $nets = [
Protocol::DFRN => DI::l10n()->t('DFRN'), Protocol::DFRN => DI::l10n()->t('DFRN'),
@ -181,10 +182,11 @@ class ContactSelector
/** /**
* @param string $network network * @param string $network network
* @param string $profile optional, default empty * @param string $profile optional, default empty
* @param int $gsid ??? (@TODO)
* @return string * @return string
* @throws \Exception * @throws \Exception
*/ */
public static function networkToIcon($network, $profile = "", $gsid = 0) public static function networkToIcon(string $network, string $profile = "", int $gsid = 0): string
{ {
$nets = [ $nets = [
Protocol::DFRN => 'friendica', Protocol::DFRN => 'friendica',

View file

@ -189,7 +189,7 @@ class Conversation
* @return string formatted text * @return string formatted text
* @throws \Friendica\Network\HTTPException\InternalServerErrorException * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/ */
public function formatActivity(array $links, $verb, $id) public function formatActivity(array $links, string $verb, int $id): string
{ {
$this->profiler->startRecording('rendering'); $this->profiler->startRecording('rendering');
$o = ''; $o = '';
@ -275,7 +275,7 @@ class Conversation
return $o; return $o;
} }
public function statusEditor(array $x = [], $notes_cid = 0, $popup = false) public function statusEditor(array $x = [], int $notes_cid = 0, bool $popup = false): string
{ {
$user = User::getById($this->app->getLoggedInUserId(), ['uid', 'nickname', 'allow_location', 'default-location']); $user = User::getById($this->app->getLoggedInUserId(), ['uid', 'nickname', 'allow_location', 'default-location']);
if (empty($user['uid'])) { if (empty($user['uid'])) {
@ -414,8 +414,8 @@ class Conversation
* figures out how to determine page owner and other contextual items * figures out how to determine page owner and other contextual items
* that are based on unique features of the calling module. * that are based on unique features of the calling module.
* @param array $items * @param array $items
* @param $mode * @param string $mode
* @param $update * @param $update @TODO Which type?
* @param bool $preview * @param bool $preview
* @param string $order * @param string $order
* @param int $uid * @param int $uid
@ -423,7 +423,7 @@ class Conversation
* @throws ImagickException * @throws ImagickException
* @throws \Friendica\Network\HTTPException\InternalServerErrorException * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/ */
public function create(array $items, $mode, $update, $preview = false, $order = 'commented', $uid = 0) public function create(array $items, string $mode, $update, bool $preview = false, string $order = 'commented', int $uid = 0): string
{ {
$this->profiler->startRecording('rendering'); $this->profiler->startRecording('rendering');
@ -784,7 +784,7 @@ class Conversation
return $o; return $o;
} }
private function getBlocklist() private function getBlocklist(): array
{ {
if (!local_user()) { if (!local_user()) {
return []; return [];
@ -816,7 +816,7 @@ class Conversation
* *
* @return array items with parents and comments * @return array items with parents and comments
*/ */
private function addRowInformation(array $row, array $activity, array $thr_parent) private function addRowInformation(array $row, array $activity, array $thr_parent): array
{ {
$this->profiler->startRecording('rendering'); $this->profiler->startRecording('rendering');
@ -911,7 +911,7 @@ class Conversation
* @return array items with parents and comments * @return array items with parents and comments
* @throws \Friendica\Network\HTTPException\InternalServerErrorException * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/ */
private function addChildren(array $parents, bool $block_authors, string $order, int $uid, string $mode) private function addChildren(array $parents, bool $block_authors, string $order, int $uid, string $mode): array
{ {
$this->profiler->startRecording('rendering'); $this->profiler->startRecording('rendering');
if (count($parents) > 1) { if (count($parents) > 1) {
@ -1005,7 +1005,7 @@ class Conversation
* @param bool $recursive * @param bool $recursive
* @return array * @return array
*/ */
private function getItemChildren(array &$item_list, array $parent, $recursive = true) private function getItemChildren(array &$item_list, array $parent, bool $recursive = true): array
{ {
$this->profiler->startRecording('rendering'); $this->profiler->startRecording('rendering');
$children = []; $children = [];
@ -1040,7 +1040,7 @@ class Conversation
* @param array $items * @param array $items
* @return array * @return array
*/ */
private function sortItemChildren(array $items) private function sortItemChildren(array $items): array
{ {
$this->profiler->startRecording('rendering'); $this->profiler->startRecording('rendering');
$result = $items; $result = $items;
@ -1086,7 +1086,7 @@ class Conversation
* @param array $parent A tree-like array of items * @param array $parent A tree-like array of items
* @return array * @return array
*/ */
private function smartFlattenConversation(array $parent) private function smartFlattenConversation(array $parent): array
{ {
$this->profiler->startRecording('rendering'); $this->profiler->startRecording('rendering');
if (!isset($parent['children']) || count($parent['children']) == 0) { if (!isset($parent['children']) || count($parent['children']) == 0) {
@ -1142,7 +1142,7 @@ class Conversation
* @return array * @return array
* @throws \Friendica\Network\HTTPException\InternalServerErrorException * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/ */
private function convSort(array $item_list, $order) private function convSort(array $item_list, string $order): array
{ {
$this->profiler->startRecording('rendering'); $this->profiler->startRecording('rendering');
$parents = []; $parents = [];
@ -1222,7 +1222,7 @@ class Conversation
* @param array $b * @param array $b
* @return int * @return int
*/ */
private function sortThrFeaturedReceived(array $a, array $b) private function sortThrFeaturedReceived(array $a, array $b): int
{ {
if ($b['featured'] && !$a['featured']) { if ($b['featured'] && !$a['featured']) {
return 1; return 1;
@ -1240,7 +1240,7 @@ class Conversation
* @param array $b * @param array $b
* @return int * @return int
*/ */
private function sortThrFeaturedCommented(array $a, array $b) private function sortThrFeaturedCommented(array $a, array $b): int
{ {
if ($b['featured'] && !$a['featured']) { if ($b['featured'] && !$a['featured']) {
return 1; return 1;
@ -1258,7 +1258,7 @@ class Conversation
* @param array $b * @param array $b
* @return int * @return int
*/ */
private function sortThrReceived(array $a, array $b) private function sortThrReceived(array $a, array $b): int
{ {
return strcmp($b['received'], $a['received']); return strcmp($b['received'], $a['received']);
} }
@ -1270,7 +1270,7 @@ class Conversation
* @param array $b * @param array $b
* @return int * @return int
*/ */
private function sortThrReceivedRev(array $a, array $b) private function sortThrReceivedRev(array $a, array $b): int
{ {
return strcmp($a['received'], $b['received']); return strcmp($a['received'], $b['received']);
} }
@ -1282,7 +1282,7 @@ class Conversation
* @param array $b * @param array $b
* @return int * @return int
*/ */
private function sortThrCommented(array $a, array $b) private function sortThrCommented(array $a, array $b): int
{ {
return strcmp($b['commented'], $a['commented']); return strcmp($b['commented'], $a['commented']);
} }
@ -1294,7 +1294,7 @@ class Conversation
* @param array $b * @param array $b
* @return int * @return int
*/ */
private function sortThrCreated(array $a, array $b) private function sortThrCreated(array $a, array $b): int
{ {
return strcmp($b['created'], $a['created']); return strcmp($b['created'], $a['created']);
} }

View file

@ -60,7 +60,7 @@ class ParsedLogIterator implements \Iterator
* @param string $filename File to open * @param string $filename File to open
* @return $this * @return $this
*/ */
public function open(string $filename) public function open(string $filename): ParsedLogIterator
{ {
$this->reader->open($filename); $this->reader->open($filename);
return $this; return $this;
@ -70,7 +70,7 @@ class ParsedLogIterator implements \Iterator
* @param int $limit Max num of lines to read * @param int $limit Max num of lines to read
* @return $this * @return $this
*/ */
public function withLimit(int $limit) public function withLimit(int $limit): ParsedLogIterator
{ {
$this->limit = $limit; $this->limit = $limit;
return $this; return $this;
@ -80,7 +80,7 @@ class ParsedLogIterator implements \Iterator
* @param array $filters filters per column * @param array $filters filters per column
* @return $this * @return $this
*/ */
public function withFilters(array $filters) public function withFilters(array $filters): ParsedLogIterator
{ {
$this->filters = $filters; $this->filters = $filters;
return $this; return $this;
@ -90,7 +90,7 @@ class ParsedLogIterator implements \Iterator
* @param string $search string to search to filter lines * @param string $search string to search to filter lines
* @return $this * @return $this
*/ */
public function withSearch(string $search) public function withSearch(string $search): ParsedLogIterator
{ {
$this->search = $search; $this->search = $search;
return $this; return $this;
@ -100,10 +100,10 @@ class ParsedLogIterator implements \Iterator
* Check if parsed log line match filters. * Check if parsed log line match filters.
* Always match if no filters are set. * Always match if no filters are set.
* *
* @param ParsedLogLine $parsedlogline * @param ParsedLogLine $parsedlogline ParsedLogLine instance
* @return bool * @return bool Wether the parse log line matches
*/ */
private function filter($parsedlogline) private function filter(ParsedLogLine $parsedlogline): bool
{ {
$match = true; $match = true;
foreach ($this->filters as $filter => $filtervalue) { foreach ($this->filters as $filter => $filtervalue) {
@ -126,7 +126,7 @@ class ParsedLogIterator implements \Iterator
* @param ParsedLogLine $parsedlogline * @param ParsedLogLine $parsedlogline
* @return bool * @return bool
*/ */
private function search($parsedlogline) private function search(ParsedLogLine $parsedlogline): bool
{ {
if ($this->search != "") { if ($this->search != "") {
return strstr($parsedlogline->logline, $this->search) !== false; return strstr($parsedlogline->logline, $this->search) !== false;

View file

@ -33,9 +33,9 @@ class ProfileFields extends BaseCollection
/** /**
* @param callable $callback * @param callable $callback
* @return ProfileFields * @return ProfileFields (as an extended form of BaseCollection)
*/ */
public function map(callable $callback): ProfileFields public function map(callable $callback): BaseCollection
{ {
return parent::map($callback); return parent::map($callback);
} }