From f7c0f325afdf4ccaa4735579eb54b320d6097678 Mon Sep 17 00:00:00 2001
From: Roland Haeder <roland@mxchange.org>
Date: Thu, 5 Mar 2015 19:18:38 +0100
Subject: [PATCH] Added more checked type-hints

Signed-off-by: Roland Haeder <roland@mxchange.org>
---
 lib/util.php                                         |  2 +-
 plugins/DomainWhitelist/DomainWhitelistPlugin.php    |  9 +++++----
 plugins/OStatus/OStatusPlugin.php                    | 12 ++++++------
 .../RequireValidatedEmailPlugin.php                  |  2 +-
 4 files changed, 13 insertions(+), 12 deletions(-)

diff --git a/lib/util.php b/lib/util.php
index 5897f58b45..35848c167b 100644
--- a/lib/util.php
+++ b/lib/util.php
@@ -686,7 +686,7 @@ function common_linkify_mention($mention)
  *
  * @access private
  */
-function common_find_mentions($text, $notice)
+function common_find_mentions($text, Notice $notice)
 {
     try {
         $sender = Profile::getKV('id', $notice->profile_id);
diff --git a/plugins/DomainWhitelist/DomainWhitelistPlugin.php b/plugins/DomainWhitelist/DomainWhitelistPlugin.php
index 2e15dd809a..76486f65b0 100644
--- a/plugins/DomainWhitelist/DomainWhitelistPlugin.php
+++ b/plugins/DomainWhitelist/DomainWhitelistPlugin.php
@@ -65,7 +65,7 @@ class DomainWhitelistPlugin extends Plugin
      *
      * @return boolean hook flag
      */
-    function onEndShowStatusNetScripts($action) {
+    public function onEndShowStatusNetScripts(Action $action) {
         $name = $action->arg('action');
         if ($name == 'invite') {
             $action->script($this->getPath() . '/js/whitelistinvite.js');
@@ -73,13 +73,14 @@ class DomainWhitelistPlugin extends Plugin
         return true;
     }
 
-    function onRequireValidatedEmailPlugin_Override($user, &$knownGood)
+    public function onRequireValidatedEmailPlugin_Override(User $user, &$knownGood)
     {
         $knownGood = (!empty($user->email) && $this->matchesWhitelist($user->email));
         return true;
     }
 
-    function onEndValidateUserEmail($user, $email, &$valid)
+    // @TODO Most callers are given NULL as first argument
+    public function onEndValidateUserEmail($user, $email, &$valid)
     {
         if ($valid) { // it's otherwise valid
             if (!$this->matchesWhitelist($email)) {
@@ -102,7 +103,7 @@ class DomainWhitelistPlugin extends Plugin
         return true;
     }
 
-    function onStartAddEmailAddress($user, $email)
+    public function onStartAddEmailAddress(User $user, $email)
     {
         if (!$this->matchesWhitelist($email)) {
             // TRANS: Exception thrown when an e-mail address does not match the site's domain whitelist.
diff --git a/plugins/OStatus/OStatusPlugin.php b/plugins/OStatus/OStatusPlugin.php
index 7c0530eb66..6062749ce6 100644
--- a/plugins/OStatus/OStatusPlugin.php
+++ b/plugins/OStatus/OStatusPlugin.php
@@ -233,7 +233,7 @@ class OStatusPlugin extends Plugin
         return true;
     }
 
-    function onStartTagProfileAction($action, $profile)
+    function onStartTagProfileAction(Action $action, Profile $profile)
     {
         $err = null;
         $uri = $action->trimmed('uri');
@@ -267,7 +267,7 @@ class OStatusPlugin extends Plugin
     /*
      * If the field being looked for is URI look for the profile
      */
-    function onStartProfileCompletionSearch($action, $profile, $search_engine) {
+    public function onStartProfileCompletionSearch(Action $action, Profile $profile, $search_engine) {
         if ($action->field == 'uri') {
             $profile->joinAdd(array('id', 'user:id'));
             $profile->whereAdd('uri LIKE "%' . $profile->escape($q) . '%"');
@@ -306,7 +306,7 @@ class OStatusPlugin extends Plugin
      * @param array &$mention in/out param: set of found mentions
      * @return boolean hook return value
      */
-    function onEndFindMentions($sender, $text, &$mentions)
+    function onEndFindMentions(Profile $sender, $text, array &$mentions)
     {
         $matches = array();
 
@@ -389,7 +389,7 @@ class OStatusPlugin extends Plugin
      * @param Profile &$profile
      * @return hook return code
      */
-    function onStartCommandGetProfile($command, $arg, &$profile)
+    public function onStartCommandGetProfile(Command $command, $arg, Profile &$profile = null)
     {
         $oprofile = $this->pullRemoteProfile($arg);
         if ($oprofile instanceof Ostatus_profile && !$oprofile->isGroup()) {
@@ -416,7 +416,7 @@ class OStatusPlugin extends Plugin
      * @param User_group &$group
      * @return hook return code
      */
-    function onStartCommandGetGroup($command, $arg, &$group)
+    function onStartCommandGetGroup(Command $command, $arg, User_group &$group = null)
     {
         $oprofile = $this->pullRemoteProfile($arg);
         if ($oprofile instanceof Ostatus_profile && $oprofile->isGroup()) {
@@ -481,7 +481,7 @@ class OStatusPlugin extends Plugin
         return true;
     }
 
-    function onEndShowStatusNetScripts($action) {
+    public function onEndShowStatusNetScripts(Action $action) {
         $action->script($this->path('js/ostatus.js'));
         return true;
     }
diff --git a/plugins/RequireValidatedEmail/RequireValidatedEmailPlugin.php b/plugins/RequireValidatedEmail/RequireValidatedEmailPlugin.php
index f6b3c4ef7c..c4f959a4c9 100644
--- a/plugins/RequireValidatedEmail/RequireValidatedEmailPlugin.php
+++ b/plugins/RequireValidatedEmail/RequireValidatedEmailPlugin.php
@@ -136,7 +136,7 @@ class RequireValidatedEmailPlugin extends Plugin
      *
      * @return bool
      */
-    protected function validated($user)
+    protected function validated(User $user)
     {
         // The email field is only stored after validation...
         // Until then you'll find them in confirm_address.
-- 
2.39.5