From: Roland Haeder Date: Fri, 12 Sep 2014 19:41:53 +0000 (+0200) Subject: Added some (good known) type-hints. X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=2cfcda5bcee794af0a62352797b8eb96a82fa9bf;p=quix0rs-gnu-social.git Added some (good known) type-hints. Signed-off-by: Roland Haeder --- diff --git a/classes/Notice.php b/classes/Notice.php index b6f480ed5e..35d88355ed 100644 --- a/classes/Notice.php +++ b/classes/Notice.php @@ -330,7 +330,7 @@ class Notice extends Managed_DataObject * Record the given set of hash tags in the db for this notice. * Given tag strings will be normalized and checked for dupes. */ - function saveKnownTags($hashtags) + function saveKnownTags(array $hashtags) { //turn each into their canonical tag //this is needed to remove dupes before saving e.g. #hash.tag = #hashtag diff --git a/plugins/ForceGroup/ForceGroupPlugin.php b/plugins/ForceGroup/ForceGroupPlugin.php index a79c9d312b..56e33355e8 100644 --- a/plugins/ForceGroup/ForceGroupPlugin.php +++ b/plugins/ForceGroup/ForceGroupPlugin.php @@ -105,7 +105,7 @@ class ForceGroupPlugin extends Plugin * * @return boolean hook value */ - function onPluginVersion(&$versions) + function onPluginVersion(array &$versions) { $url = 'http://status.net/wiki/Plugin:ForceGroup'; diff --git a/plugins/GroupPrivateMessage/GroupPrivateMessagePlugin.php b/plugins/GroupPrivateMessage/GroupPrivateMessagePlugin.php index 0788161dd3..fc15fdcfdc 100644 --- a/plugins/GroupPrivateMessage/GroupPrivateMessagePlugin.php +++ b/plugins/GroupPrivateMessage/GroupPrivateMessagePlugin.php @@ -124,7 +124,7 @@ class GroupPrivateMessagePlugin extends Plugin * * @result boolean hook value */ - function onEndGroupSave($group) + function onEndGroupSave(User_group $group) { $gps = new Group_privacy_settings(); @@ -321,7 +321,7 @@ class GroupPrivateMessagePlugin extends Plugin foreach (array_unique($match[1]) as $nickname) { $group = User_group::getForNickname($nickname, $profile); - if (empty($group)) { + if (!$group instanceof User_group) { continue; } diff --git a/plugins/OStatus/classes/Ostatus_profile.php b/plugins/OStatus/classes/Ostatus_profile.php index 45c01a568b..42b883361e 100644 --- a/plugins/OStatus/classes/Ostatus_profile.php +++ b/plugins/OStatus/classes/Ostatus_profile.php @@ -357,9 +357,10 @@ class Ostatus_profile extends Managed_DataObject * send immediately but won't get the return value. * * @param mixed $entry XML string, Notice, or Activity + * @param Profile $actor Acting profile * @return boolean success */ - public function notifyDeferred($entry, $actor) + public function notifyDeferred($entry, Profile $actor) { if ($this->salmonuri) { $data = array('salmonuri' => $this->salmonuri, @@ -465,14 +466,14 @@ class Ostatus_profile extends Managed_DataObject * * @return Notice Notice representing the new (or existing) activity */ - public function processEntry($entry, $feed, $source) + public function processEntry(DOMElement $entry, DOMElement $feed, $source) { $activity = new Activity($entry, $feed); return $this->processActivity($activity, $source); } // TODO: Make this throw an exception - public function processActivity($activity, $source) + public function processActivity(Activity $activity, $source) { $notice = null; @@ -512,7 +513,7 @@ class Ostatus_profile extends Managed_DataObject return $notice; } - public function processShare($activity, $method) + public function processShare(Activity $activity, $method) { $notice = null; @@ -727,7 +728,7 @@ class Ostatus_profile extends Managed_DataObject * @return mixed saved Notice or false * @todo FIXME: Break up this function, it's getting nasty long */ - public function processPost($activity, $method) + public function processPost(Activity $activity, $method) { $notice = null; @@ -977,7 +978,7 @@ class Ostatus_profile extends Managed_DataObject * @throws Exception on various error conditions * @throws OStatusShadowException if this reference would obscure a local user/group */ - public static function ensureProfileURL($profile_url, $hints=array()) + public static function ensureProfileURL($profile_url, array $hints=array()) { $oprofile = self::getFromProfileURL($profile_url); @@ -1153,7 +1154,7 @@ class Ostatus_profile extends Managed_DataObject * @return Ostatus_profile * @throws Exception */ - public static function ensureAtomFeed($feedEl, $hints) + public static function ensureAtomFeed(DOMElement $feedEl, array $hints) { $author = ActivityUtils::getFeedAuthor($feedEl); @@ -1288,7 +1289,7 @@ class Ostatus_profile extends Managed_DataObject * @param array $hints * @return mixed URL string or false */ - public static function getActivityObjectAvatar($object, $hints=array()) + public static function getActivityObjectAvatar(ActivityObject $object, array $hints=array()) { if ($object->avatarLinks) { $best = false; @@ -1317,7 +1318,7 @@ class Ostatus_profile extends Managed_DataObject * @param DOMElement $feed * @return string */ - protected static function getAvatar($actor, $feed) + protected static function getAvatar(ActivityObject $actor, DOMElement $feed) { $url = ''; $icon = ''; @@ -1368,7 +1369,7 @@ class Ostatus_profile extends Managed_DataObject * @return Ostatus_profile * @throws Exception */ - public static function ensureActorProfile($activity, $hints=array()) + public static function ensureActorProfile(Activity $activity, array $hints=array()) { return self::ensureActivityObjectProfile($activity->actor, $hints); } @@ -1384,7 +1385,7 @@ class Ostatus_profile extends Managed_DataObject * @return Ostatus_profile * @throws Exception */ - public static function ensureActivityObjectProfile($object, $hints=array()) + public static function ensureActivityObjectProfile(ActivityObject $object, array $hints=array()) { $profile = self::getActivityObjectProfile($object); if ($profile instanceof Ostatus_profile) { @@ -1400,7 +1401,7 @@ class Ostatus_profile extends Managed_DataObject * @return mixed matching Ostatus_profile or false if none known * @throws ServerException if feed info invalid */ - public static function getActorProfile($activity) + public static function getActorProfile(Activity $activity) { return self::getActivityObjectProfile($activity->actor); } @@ -1410,7 +1411,7 @@ class Ostatus_profile extends Managed_DataObject * @return mixed matching Ostatus_profile or false if none known * @throws ServerException if feed info invalid */ - protected static function getActivityObjectProfile($object) + protected static function getActivityObjectProfile(ActivityObject $object) { $uri = self::getActivityObjectProfileURI($object); return Ostatus_profile::getKV('uri', $uri); @@ -1425,7 +1426,7 @@ class Ostatus_profile extends Managed_DataObject * @return string * @throws ServerException if feed info invalid */ - protected static function getActivityObjectProfileURI($object) + protected static function getActivityObjectProfileURI(ActivityObject $object) { if ($object->id) { if (ActivityUtils::validateUri($object->id)) { @@ -1458,7 +1459,7 @@ class Ostatus_profile extends Managed_DataObject * * @return Ostatus_profile */ - protected static function createActivityObjectProfile($object, $hints=array()) + protected static function createActivityObjectProfile(ActivityObject $object, array $hints=array()) { $homeuri = $object->id; $discover = false; @@ -1623,7 +1624,7 @@ class Ostatus_profile extends Managed_DataObject * @param ActivityObject $object * @param array $hints */ - public function updateFromActivityObject($object, $hints=array()) + public function updateFromActivityObject(ActivityObject $object, array $hints=array()) { if ($this->isGroup()) { $group = $this->localGroup(); @@ -1646,7 +1647,7 @@ class Ostatus_profile extends Managed_DataObject } } - public static function updateProfile($profile, $object, $hints=array()) + public static function updateProfile(Profile $profile, ActivityObject $object, array $hints=array()) { $orig = clone($profile); @@ -1711,7 +1712,7 @@ class Ostatus_profile extends Managed_DataObject } } - protected static function updateGroup(User_group $group, $object, $hints=array()) + protected static function updateGroup(User_group $group, ActivityObject $object, array $hints=array()) { $orig = clone($group); @@ -1735,7 +1736,7 @@ class Ostatus_profile extends Managed_DataObject } } - protected static function updatePeopletag($tag, $object, $hints=array()) { + protected static function updatePeopletag(Peopletag $tag, ActivityObject $object, array $hints=array()) { $orig = clone($tag); $tag->tag = $object->title; @@ -2155,7 +2156,7 @@ class Ostatus_profile extends Managed_DataObject } else { $actor = $activity->actor; - if (empty($actor)) { + if (!$actor instanceof Profile) { // OK here! assume the default } else if ($actor->id == $this->getUri() || $actor->link == $this->getUri()) { $this->updateFromActivityObject($actor);