Merge "Type hint against LinkTarget in WatchedItemStore"
[lhc/web/wiklou.git] / includes / changes / CategoryMembershipChange.php
index f095b64..2ef9c9f 100644 (file)
@@ -1,4 +1,7 @@
 <?php
+
+use MediaWiki\Storage\RevisionRecord;
+
 /**
  * Helper class for category membership changes
  *
@@ -23,8 +26,6 @@
  * @since 1.27
  */
 
-use Wikimedia\Assert\Assert;
-
 class CategoryMembershipChange {
 
        const CATEGORY_ADDITION = 1;
@@ -59,7 +60,7 @@ class CategoryMembershipChange {
 
        /**
         * @param Title $pageTitle Title instance of the categorized page
-        * @param Revision $revision Latest Revision instance of the categorized page
+        * @param Revision|null $revision Latest Revision instance of the categorized page
         *
         * @throws MWException
         */
@@ -83,11 +84,10 @@ class CategoryMembershipChange {
         *
         * @throws MWException
         */
-       public function overrideNewForCategorizationCallback( $callback ) {
+       public function overrideNewForCategorizationCallback( callable $callback ) {
                if ( !defined( 'MW_PHPUNIT_TEST' ) ) {
                        throw new MWException( 'Cannot override newForCategorization callback in operation.' );
                }
-               Assert::parameterType( 'callable', $callback, '$callback' );
                $this->newForCategorizationCallback = $callback;
        }
 
@@ -142,7 +142,7 @@ class CategoryMembershipChange {
        /**
         * @param string $timestamp Timestamp of the recent change to occur in TS_MW format
         * @param Title $categoryTitle Title of the category a page is being added to or removed from
-        * @param User $user User object of the user that made the change
+        * @param User|null $user User object of the user that made the change
         * @param string $comment Change summary
         * @param Title $pageTitle Title of the page that is being added or removed
         * @param string $lastTimestamp Parent revision timestamp of this change in TS_MW format
@@ -161,7 +161,7 @@ class CategoryMembershipChange {
                $revision,
                $added
        ) {
-               $deleted = $revision ? $revision->getVisibility() & Revision::SUPPRESSED_USER : 0;
+               $deleted = $revision ? $revision->getVisibility() & RevisionRecord::SUPPRESSED_USER : 0;
                $newRevId = $revision ? $revision->getId() : 0;
 
                /**
@@ -187,22 +187,19 @@ class CategoryMembershipChange {
                }
 
                /** @var RecentChange $rc */
-               $rc = call_user_func_array(
-                       $this->newForCategorizationCallback,
-                       [
-                               $timestamp,
-                               $categoryTitle,
-                               $user,
-                               $comment,
-                               $pageTitle,
-                               $lastRevId,
-                               $newRevId,
-                               $lastTimestamp,
-                               $bot,
-                               $ip,
-                               $deleted,
-                               $added
-                       ]
+               $rc = ( $this->newForCategorizationCallback )(
+                       $timestamp,
+                       $categoryTitle,
+                       $user,
+                       $comment,
+                       $pageTitle,
+                       $lastRevId,
+                       $newRevId,
+                       $lastTimestamp,
+                       $bot,
+                       $ip,
+                       $deleted,
+                       $added
                );
                $rc->save();
        }
@@ -220,9 +217,9 @@ class CategoryMembershipChange {
         */
        private function getUser() {
                if ( $this->revision ) {
-                       $userId = $this->revision->getUser( Revision::RAW );
+                       $userId = $this->revision->getUser( RevisionRecord::RAW );
                        if ( $userId === 0 ) {
-                               return User::newFromName( $this->revision->getUserText( Revision::RAW ), false );
+                               return User::newFromName( $this->revision->getUserText( RevisionRecord::RAW ), false );
                        } else {
                                return User::newFromId( $userId );
                        }