Merge "Fix/suppress phan errors related to arrays (#11)"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Sun, 7 Apr 2019 16:44:03 +0000 (16:44 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Sun, 7 Apr 2019 16:44:03 +0000 (16:44 +0000)
1  2 
includes/debug/DeprecationHelper.php
includes/user/User.php

@@@ -50,7 -50,7 +50,7 @@@ trait DeprecationHelper 
         * the name of the class defining the property, <component> is the MediaWiki component
         * (extension, skin etc.) for use in the deprecation warning) or null if it is MediaWiki.
         * E.g. [ 'mNewRev' => [ '1.32', 'DifferenceEngine', null ]
-        * @var string[]
+        * @var string[][]
         */
        protected $deprecatedPublicProperties = [];
  
@@@ -68,7 -68,7 +68,7 @@@
        protected function deprecatePublicProperty(
                $property, $version, $class = null, $component = null
        ) {
 -              $this->deprecatedPublicProperties[$property] = [ $version, $class ?: get_class(), $component ];
 +              $this->deprecatedPublicProperties[$property] = [ $version, $class ?: __CLASS__, $component ];
        }
  
        public function __get( $name ) {
@@@ -79,7 -79,7 +79,7 @@@
                        return $this->$name;
                }
  
 -              $qualifiedName = get_class() . '::$' . $name;
 +              $qualifiedName = __CLASS__ . '::$' . $name;
                if ( $this->deprecationHelperGetPropertyOwner( $name ) ) {
                        // Someone tried to access a normal non-public property. Try to behave like PHP would.
                        trigger_error( "Cannot access non-public property $qualifiedName", E_USER_ERROR );
@@@ -99,7 -99,7 +99,7 @@@
                        return;
                }
  
 -              $qualifiedName = get_class() . '::$' . $name;
 +              $qualifiedName = __CLASS__ . '::$' . $name;
                if ( $this->deprecationHelperGetPropertyOwner( $name ) ) {
                        // Someone tried to access a normal non-public property. Try to behave like PHP would.
                        trigger_error( "Cannot access non-public property $qualifiedName", E_USER_ERROR );
diff --combined includes/user/User.php
@@@ -1675,7 -1675,7 +1675,7 @@@ class User implements IDBAccessObject, 
         * @param array $conditions WHERE conditions for use with Database::update
         * @return array WHERE conditions for use with Database::update
         */
 -      protected function makeUpdateConditions( Database $db, array $conditions ) {
 +      protected function makeUpdateConditions( IDatabase $db, array $conditions ) {
                if ( $this->mTouched ) {
                        // CAS check: only update if the row wasn't changed sicne it was loaded.
                        $conditions['user_touched'] = $db->timestamp( $this->mTouched );
  
                // Set the user limit key
                if ( $userLimit !== false ) {
+                       // phan is confused because &can-bypass's value is a bool, so it assumes
+                       // that $userLimit is also a bool here.
+                       // @phan-suppress-next-line PhanTypeInvalidExpressionArrayDestructuring
                        list( $max, $period ) = $userLimit;
                        wfDebug( __METHOD__ . ": effective user limit: $max in {$period}s\n" );
                        $keys[$cache->makeKey( 'limiter', $action, 'user', $id )] = $userLimit;
  
                $triggered = false;
                foreach ( $keys as $key => $limit ) {
+                       // phan is confused because &can-bypass's value is a bool, so it assumes
+                       // that $userLimit is also a bool here.
+                       // @phan-suppress-next-line PhanTypeInvalidExpressionArrayDestructuring
                        list( $max, $period ) = $limit;
                        $summary = "(limit $max in {$period}s)";
                        $count = $cache->get( $key );