]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
Stronger typing for NoticeListItem and so
authorMikael Nordfeldth <mmn@hethane.se>
Sun, 1 Jun 2014 22:20:27 +0000 (00:20 +0200)
committerMikael Nordfeldth <mmn@hethane.se>
Sun, 1 Jun 2014 22:20:27 +0000 (00:20 +0200)
actions/newnotice.php
actions/shownotice.php
lib/noticelist.php
lib/noticelistitem.php
lib/noticesection.php
lib/threadednoticelist.php
plugins/Bookmark/actions/newbookmark.php
plugins/Event/actions/newevent.php
plugins/Poll/PollPlugin.php
plugins/Poll/actions/newpoll.php
plugins/QnA/QnAPlugin.php

index 0c12c7d74ad70ca022dfe57b9c0f71ff462473da..060f1ecd7d5c2231f66cc067dd60c713d81a319d 100644 (file)
@@ -170,6 +170,9 @@ class NewnoticeAction extends FormAction
 
             Event::handle('EndNoticeSaveWeb', array($this, $notice));
         }
+
+        assert($notice instanceof Notice);
+
         Event::handle('EndSaveNewNoticeWeb', array($this, $user, &$content_shortened, &$options));
 
         if (StatusNet::isAjax()) {
@@ -345,7 +348,7 @@ class NewnoticeAction extends FormAction
      *
      * @return void
      */
-    function showNotice($notice)
+    function showNotice(Notice $notice)
     {
         $nli = new NoticeListItem($notice, $this);
         $nli->show();
index 28cb68c121f224c9b1b93f4c3f5eb09ba1d212bd..5e2be9f9d2b2ff48c685026779178a76e3b6e157 100644 (file)
@@ -114,20 +114,19 @@ class ShownoticeAction extends Action
         $id = $this->arg('notice');
 
         $notice = Notice::getKV('id', $id);
+        if ($notice instanceof Notice) {
+            // Alright, got it!
+            return $notice;
+        }
 
-        if (!$notice instanceof Notice) {
-            // Did we used to have it, and it got deleted?
-            $deleted = Deleted_notice::getKV($id);
-            if ($deleted instanceof Deleted_notice) {
-                // TRANS: Client error displayed trying to show a deleted notice.
-                $this->clientError(_('Notice deleted.'), 410);
-            } else {
-                // TRANS: Client error displayed trying to show a non-existing notice.
-                $this->clientError(_('No such notice.'), 404);
-            }
-            return false;
+        // Did we use to have it, and it got deleted?
+        $deleted = Deleted_notice::getKV('id', $id);
+        if ($deleted instanceof Deleted_notice) {
+            // TRANS: Client error displayed trying to show a deleted notice.
+            $this->clientError(_('Notice deleted.'), 410);
         }
-        return $notice;
+        // TRANS: Client error displayed trying to show a non-existing notice.
+        $this->clientError(_('No such notice.'), 404);
     }
 
     /**
index b00e476d92a1e11f231fea7b40977f7e096e97c8..c21d73cff5665ff04460ee8c6906ab10884408c2 100644 (file)
@@ -58,7 +58,7 @@ class NoticeList extends Widget
      *
      * @param Notice $notice stream of notices from DB_DataObject
      */
-    function __construct($notice, $out=null)
+    function __construct(Notice $notice, $out=null)
     {
         parent::__construct($out);
         $this->notice = $notice;
@@ -111,7 +111,7 @@ class NoticeList extends Widget
      *
      * @return NoticeListItem a list item for displaying the notice
      */
-    function newListItem($notice)
+    function newListItem(Notice $notice)
     {
         return new NoticeListItem($notice, $this->out);
     }
index b8ebe3bede27a85264136246cdc99bc38cac1489..f46827d1f739206881eb7784b9c6d63761f82d53 100644 (file)
@@ -65,7 +65,7 @@ class NoticeListItem extends Widget
      *
      * @param Notice $notice The notice we'll display
      */
-    function __construct($notice, $out=null)
+    function __construct(Notice $notice, HTMLOutputter $out=null)
     {
         parent::__construct($out);
         if (!empty($notice->repeat_of)) {
index 4a4eac344a3b95e955e5bcd22fa26eeb19113a50..c1fcbbf8cd1fcf904d875b882e89c04f45ad174c 100644 (file)
@@ -70,7 +70,7 @@ class NoticeSection extends Section
         return null;
     }
 
-    function showNotice($notice)
+    function showNotice(Notice $notice)
     {
         $profile = $notice->getProfile();
         if (empty($profile)) {
index e8abeb74fc2048ae0d28abf10f0375e5e87e7b5b..ed3193420f009b5c3113cc1f9e586e602e07e0ff 100644 (file)
@@ -50,7 +50,7 @@ class ThreadedNoticeList extends NoticeList
 {
     protected $userProfile;
 
-    function __construct($notice, $out=null, $profile=-1)
+    function __construct(Notice $notice, HTMLOutputter $out=null, $profile=-1)
     {
         parent::__construct($notice, $out);
         if (is_int($profile) && $profile == -1) {
@@ -147,7 +147,7 @@ class ThreadedNoticeList extends NoticeList
      *
      * @return NoticeListItem a list item for displaying the notice
      */
-    function newListItem($notice)
+    function newListItem(Notice $notice)
     {
         return new ThreadedNoticeListItem($notice, $this->out, $this->userProfile);
     }
@@ -174,7 +174,7 @@ class ThreadedNoticeListItem extends NoticeListItem
 {
     protected $userProfile = null;
 
-    function __construct($notice, $out=null, $profile=null)
+    function __construct(Notice $notice, HTMLOutputter $out=null, $profile=null)
     {
         parent::__construct($notice, $out);
         $this->userProfile = $profile;
@@ -269,7 +269,7 @@ class ThreadedNoticeListSubItem extends NoticeListItem
 {
     protected $root = null;
 
-    function __construct($notice, $root, $out)
+    function __construct(Notice $notice, $root, $out)
     {
         $this->root = $root;
         parent::__construct($notice, $out);
@@ -327,7 +327,7 @@ class ThreadedNoticeListMoreItem extends NoticeListItem
 {
     protected $cnt;
 
-    function __construct($notice, $out, $cnt)
+    function __construct(Notice $notice, HTMLOutputter $out, $cnt)
     {
         parent::__construct($notice, $out);
         $this->cnt = $cnt;
index 168a6e07b69d1383cf23301097f6d806f362cb16..bc043f41ed51e01eafdde5878efde1fb4e07f4ae 100644 (file)
@@ -191,7 +191,7 @@ class NewbookmarkAction extends Action
      *
      * @return void
      */
-    function showNotice($notice)
+    function showNotice(Notice $notice)
     {
         class_exists('NoticeList'); // @fixme hack for autoloader
         $nli = new NoticeListItem($notice, $this);
index d05b5af8d3a5bd0ad4690267d266a925b1eac62e..9483db7b4e55ab5360410560bcbfef389ff407b6 100644 (file)
@@ -320,7 +320,7 @@ class NeweventAction extends Action
      *
      * @return void
      */
-    function showNotice($notice)
+    function showNotice(Notice $notice)
     {
         $nli = new NoticeListItem($notice, $this);
         $nli->show();
index c6b4099756c16b55556ac57ceb7c6f2831c656de..e87e81c2e398f8e8e31b734277492f06793de016 100644 (file)
@@ -379,7 +379,7 @@ class PollPlugin extends MicroAppPlugin
      * open here, but we probably shouldn't open it here. Check parent class
      * and Bookmark plugin for if that's right.
      */
-    function showNotice($notice, $out)
+    function showNotice(Notice $notice, $out)
     {
         switch ($notice->object_type) {
         case self::POLL_OBJECT:
@@ -393,7 +393,7 @@ class PollPlugin extends MicroAppPlugin
         }
     }
 
-    function showNoticePoll($notice, $out)
+    function showNoticePoll(Notice $notice, $out)
     {
         $user = common_current_user();
 
@@ -425,7 +425,7 @@ class PollPlugin extends MicroAppPlugin
         $out->elementStart('div', array('class' => 'entry-content'));
     }
 
-    function showNoticePollResponse($notice, $out)
+    function showNoticePollResponse(Notice $notice, $out)
     {
         $user = common_current_user();
 
index 8a1155ba857646cb9e9f51fc931380ddd57a71e1..071778aaa2109486618b515a3ce8d4b091a20a47 100644 (file)
@@ -181,7 +181,7 @@ class NewPollAction extends Action
      *
      * @return void
      */
-    function showNotice($notice)
+    function showNotice(Notice $notice)
     {
         class_exists('NoticeList'); // @fixme hack for autoloader
         $nli = new NoticeListItem($notice, $this);
index d874441d85a691f87aa13a2ce00bcc112564117b..8aa3247f9ae9ba4b52535d765b583ecef80db9dd 100644 (file)
@@ -319,7 +319,7 @@ class QnAPlugin extends MicroAppPlugin
      * @param Notice $notice
      * @param HTMLOutputter $out
      */
-    function showNotice($notice, $out)
+    function showNotice(Notice $notice, $out)
     {
         switch ($notice->object_type) {
         case QnA_Question::OBJECT_TYPE:
@@ -337,7 +337,7 @@ class QnAPlugin extends MicroAppPlugin
         }
     }
 
-    function showNoticeQuestion($notice, $out)
+    function showNoticeQuestion(Notice $notice, $out)
     {
         $user = common_current_user();
 
@@ -427,7 +427,7 @@ class QnAPlugin extends MicroAppPlugin
         return false;
     }
 
-    function showNoticeAnswer($notice, $out)
+    function showNoticeAnswer(Notice $notice, $out)
     {
         $user = common_current_user();