From fd3d46d07da49eeeaedce406e30344a8bf0b7e6a Mon Sep 17 00:00:00 2001 From: Roland Haeder Date: Tue, 10 Mar 2015 18:31:46 +0100 Subject: [PATCH] Added checked type-hints Signed-off-by: Roland Haeder Conflicts: classes/Notice.php Signed-off-by: Roland Haeder --- classes/Notice.php | 44 +++++++++++++++++++++----------------------- 1 file changed, 21 insertions(+), 23 deletions(-) diff --git a/classes/Notice.php b/classes/Notice.php index 00aaed8d3e..3825e07a0f 100644 --- a/classes/Notice.php +++ b/classes/Notice.php @@ -1115,7 +1115,7 @@ class Notice extends Managed_DataObject * * @return void */ - function saveKnownUrls($urls) + function saveKnownUrls(array $urls) { if (common_config('attachments', 'process_links')) { // @fixme validation? @@ -1689,12 +1689,12 @@ class Notice extends Managed_DataObject $ids[] = $reply->profile_id; } - $this->_replies[$this->id] = $ids; + $this->_setReplies($ids); return $ids; } - function _setReplies($replies) + function _setReplies(array $replies) { $this->_replies[$this->id] = $replies; } @@ -1772,13 +1772,11 @@ class Notice extends Managed_DataObject } $groups = User_group::multiGet('id', $ids); - - $this->_groups[$this->id] = $groups->fetchAll(); - + $this->_setGroups($groups->fetchAll()); return $this->_groups[$this->id]; } - - function _setGroups($groups) + + function _setGroups(array $groups) { $this->_groups[$this->id] = $groups; } @@ -2656,7 +2654,7 @@ class Notice extends Managed_DataObject * * @return boolean whether the profile is in the notice's scope */ - function inScope($profile) + function inScope(Profile $profile=null) { if (is_null($profile)) { $keypart = sprintf('notice:in-scope-for:%d:null', $this->id); @@ -2679,7 +2677,7 @@ class Notice extends Managed_DataObject return ($result == 1) ? true : false; } - protected function _inScope($profile) + protected function _inScope(Profile $profile=null) { if (!is_null($this->scope)) { $scope = $this->scope; @@ -2768,8 +2766,8 @@ class Notice extends Managed_DataObject } } - function isHiddenSpam($profile) { - + function isHiddenSpam(Profile $profile=null) { + // Hide posts by silenced users from everyone but moderators. if (common_config('notice', 'hidespam')) { @@ -2833,7 +2831,7 @@ class Notice extends Managed_DataObject return $scope; } - static function fillProfiles($notices) + static function fillProfiles(array $notices) { $map = self::getProfiles($notices); @@ -2850,8 +2848,8 @@ class Notice extends Managed_DataObject return array_values($map); } - - static function getProfiles(&$notices) + + static function getProfiles(array &$notices) { $ids = array(); foreach ($notices as $notice) { @@ -2862,8 +2860,8 @@ class Notice extends Managed_DataObject return Profile::pivotGet('id', $ids); } - - static function fillGroups(&$notices) + + static function fillGroups(array &$notices) { $ids = self::_idsOf($notices); @@ -2903,7 +2901,7 @@ class Notice extends Managed_DataObject return array_keys($ids); } - static function fillAttachments(&$notices) + static function fillAttachments(array &$notices) { $ids = self::_idsOf($notices); @@ -2932,7 +2930,7 @@ class Notice extends Managed_DataObject } } - static function fillReplies(&$notices) + static function fillReplies(array &$notices) { $ids = self::_idsOf($notices); $replyMap = Reply::listGet('notice_id', $ids); @@ -2954,21 +2952,21 @@ class Notice extends Managed_DataObject return $this->_repeats[$this->id]; } $repeatMap = Notice::listGet('repeat_of', array($this->id)); - $this->_repeats[$this->id] = $repeatMap[$this->id]; + $this->_setRepeats($repeatMap[$this->id]); return $this->_repeats[$this->id]; } - function _setRepeats($repeats) + function _setRepeats(array $repeats) { $this->_repeats[$this->id] = $repeats; } - static function fillRepeats(&$notices) + static function fillRepeats(array &$notices) { $ids = self::_idsOf($notices); $repeatMap = Notice::listGet('repeat_of', $ids); foreach ($notices as $notice) { - $repeats = $repeatMap[$notice->id]; + $repeats = $repeatMap[$notice->id]; $notice->_setRepeats($repeats); } } -- 2.39.2