From c8bc124f0d4c2f7293bfe3d23acbd8865c91795a Mon Sep 17 00:00:00 2001 From: Roland Haeder Date: Sun, 1 Mar 2015 18:34:46 +0100 Subject: [PATCH] Added some checked (I checked them) type-hints to improve type-safety (typing mistakes). Signed-off-by: Roland Haeder --- plugins/Blacklist/BlacklistPlugin.php | 2 +- plugins/BlogspamNet/BlogspamNetPlugin.php | 2 +- plugins/DirectionDetector/DirectionDetectorPlugin.php | 8 ++++---- plugins/Mollom/MollomPlugin.php | 2 +- .../RequireValidatedEmail/RequireValidatedEmailPlugin.php | 4 ++-- plugins/Spotify/SpotifyPlugin.php | 2 +- 6 files changed, 10 insertions(+), 10 deletions(-) diff --git a/plugins/Blacklist/BlacklistPlugin.php b/plugins/Blacklist/BlacklistPlugin.php index bad89f2457..4491c27329 100644 --- a/plugins/Blacklist/BlacklistPlugin.php +++ b/plugins/Blacklist/BlacklistPlugin.php @@ -122,7 +122,7 @@ class BlacklistPlugin extends Plugin * * @return boolean hook value */ - function onStartRegisterUser(&$user, &$profile) + function onStartRegisterUser(User &$user, Profile &$profile) { $homepage = strtolower($profile->homepage); diff --git a/plugins/BlogspamNet/BlogspamNetPlugin.php b/plugins/BlogspamNet/BlogspamNetPlugin.php index 2cab69be30..3df1e29f2e 100644 --- a/plugins/BlogspamNet/BlogspamNetPlugin.php +++ b/plugins/BlogspamNet/BlogspamNetPlugin.php @@ -65,7 +65,7 @@ class BlogspamNetPlugin extends Plugin } } - function onStartNoticeSave($notice) + function onStartNoticeSave(Notice $notice) { $args = $this->testArgs($notice); common_debug("Blogspamnet args = " . print_r($args, TRUE)); diff --git a/plugins/DirectionDetector/DirectionDetectorPlugin.php b/plugins/DirectionDetector/DirectionDetectorPlugin.php index 289196b4a9..73ea999408 100644 --- a/plugins/DirectionDetector/DirectionDetectorPlugin.php +++ b/plugins/DirectionDetector/DirectionDetectorPlugin.php @@ -36,7 +36,7 @@ class DirectionDetectorPlugin extends Plugin { * * @param object $notice notice is going to be saved */ - public function onStartNoticeSave($notice){ + public function onStartNoticeSave(Notice $notice) { if(!preg_match('//', $notice->rendered) && self::isRTL($notice->content)) $notice->rendered = ''.$notice->rendered.''; return true; @@ -48,7 +48,7 @@ class DirectionDetectorPlugin extends Plugin { * @param string $content * @return boolean */ - public static function isRTL($content){ + public static function isRTL($content) { $content = self::getClearText($content); $words = explode(' ', $content); $rtl = 0; @@ -71,7 +71,7 @@ class DirectionDetectorPlugin extends Plugin { * @param string $str * @return boolean */ - public static function startsWithRTLCharacter($str){ + public static function startsWithRTLCharacter($str ){ if (strlen($str) < 1) { return false; } @@ -106,7 +106,7 @@ class DirectionDetectorPlugin extends Plugin { * @param string $str * @return string */ - private static function getClearText($str){ + private static function getClearText($str) { $str = preg_replace('/@[^ ]+|![^ ]+|#[^ ]+/u', '', $str); // reply, tag, group $str = preg_replace('/^RT[: ]{1}| RT | RT: |^RD[: ]{1}| RD | RD: |[♺♻:]/u', '', $str); // redent, retweet $str = preg_replace("/[ \r\t\n]+/", ' ', trim($str)); // remove spaces diff --git a/plugins/Mollom/MollomPlugin.php b/plugins/Mollom/MollomPlugin.php index 382ce2ee5b..b4c9c1cf69 100644 --- a/plugins/Mollom/MollomPlugin.php +++ b/plugins/Mollom/MollomPlugin.php @@ -70,7 +70,7 @@ class MollomPlugin extends Plugin public $private_key; public $servers; - function onStartNoticeSave($notice) + function onStartNoticeSave(Notice $notice) { if ( $this->public_key ) { //Check spam diff --git a/plugins/RequireValidatedEmail/RequireValidatedEmailPlugin.php b/plugins/RequireValidatedEmail/RequireValidatedEmailPlugin.php index 99f61dcf02..f6b3c4ef7c 100644 --- a/plugins/RequireValidatedEmail/RequireValidatedEmailPlugin.php +++ b/plugins/RequireValidatedEmail/RequireValidatedEmailPlugin.php @@ -95,7 +95,7 @@ class RequireValidatedEmailPlugin extends Plugin * * @return bool hook result code */ - function onStartNoticeSave($notice) + function onStartNoticeSave(Notice $notice) { $user = User::getKV('id', $notice->profile_id); if (!empty($user)) { // it's a remote notice @@ -116,7 +116,7 @@ class RequireValidatedEmailPlugin extends Plugin * * @return bool hook result code */ - function onStartRegisterUser(&$user, &$profile) + function onStartRegisterUser(User &$user, Profile &$profile) { $email = $user->email; diff --git a/plugins/Spotify/SpotifyPlugin.php b/plugins/Spotify/SpotifyPlugin.php index f001fc3909..2754d18021 100644 --- a/plugins/Spotify/SpotifyPlugin.php +++ b/plugins/Spotify/SpotifyPlugin.php @@ -54,7 +54,7 @@ class SpotifyPlugin extends Plugin parent::__construct(); } - function onStartNoticeSave($notice) + function onStartNoticeSave(Notice $notice) { $notice->rendered = preg_replace_callback('/spotify:[a-z]{5,6}:[a-z0-9]{22}/i', "renderSpotifyURILink", -- 2.39.5