MediaWiki\Block namespace minor tweaks
authorMax Semenik <maxsem.wiki@gmail.com>
Thu, 27 Jun 2019 20:42:54 +0000 (13:42 -0700)
committerMax Semenik <maxsem.wiki@gmail.com>
Thu, 27 Jun 2019 20:42:54 +0000 (13:42 -0700)
* Visibility
* Parameter type hints and docs
* Minor doc fixes

Change-Id: I46d4b99e18cffdf8323fb01b7ed30f3eda2906d1

includes/block/AbstractBlock.php
includes/block/BlockManager.php
includes/block/BlockRestrictionStore.php
includes/block/CompositeBlock.php
includes/block/DatabaseBlock.php
includes/block/SystemBlock.php

index c7ba68d..0357f8d 100644 (file)
@@ -84,7 +84,7 @@ abstract class AbstractBlock {
         *     timestamp string     The time at which the block comes into effect
         *     byText string        Username of the blocker (for foreign users)
         */
-       function __construct( $options = [] ) {
+       public function __construct( array $options = [] ) {
                $defaults = [
                        'address'         => '',
                        'by'              => null,
index abd2db2..dc07364 100644 (file)
@@ -76,23 +76,23 @@ class BlockManager {
         * @param bool $applyIpBlocksToXff
         * @param bool $cookieSetOnAutoblock
         * @param bool $cookieSetOnIpBlock
-        * @param array $dnsBlacklistUrls
+        * @param string[] $dnsBlacklistUrls
         * @param bool $enableDnsBlacklist
-        * @param array $proxyList
-        * @param array $proxyWhitelist
+        * @param string[] $proxyList
+        * @param string[] $proxyWhitelist
         * @param string $secretKey
         * @param array $softBlockRanges
         */
        public function __construct(
-               $currentUser,
-               $currentRequest,
+               User $currentUser,
+               WebRequest $currentRequest,
                $applyIpBlocksToXff,
                $cookieSetOnAutoblock,
                $cookieSetOnIpBlock,
-               $dnsBlacklistUrls,
+               array $dnsBlacklistUrls,
                $enableDnsBlacklist,
-               $proxyList,
-               $proxyWhitelist,
+               array $proxyList,
+               array $proxyWhitelist,
                $secretKey,
                $softBlockRanges
        ) {
@@ -232,7 +232,7 @@ class BlockManager {
         * @param AbstractBlock[] $blocks
         * @return AbstractBlock[]
         */
-       private function getUniqueBlocks( $blocks ) {
+       private function getUniqueBlocks( array $blocks ) {
                $systemBlocks = [];
                $databaseBlocks = [];
 
index 88c0951..df09ead 100644 (file)
@@ -26,6 +26,7 @@ use MediaWiki\Block\Restriction\NamespaceRestriction;
 use MediaWiki\Block\Restriction\PageRestriction;
 use MediaWiki\Block\Restriction\Restriction;
 use MWException;
+use stdClass;
 use Wikimedia\Rdbms\IResultWrapper;
 use Wikimedia\Rdbms\IDatabase;
 use Wikimedia\Rdbms\ILoadBalancer;
@@ -45,8 +46,8 @@ class BlockRestrictionStore {
         */
        private $loadBalancer;
 
-       /*
-        * @param LoadBalancer $loadBalancer load balancer for acquiring database connections
+       /**
+        * @param ILoadBalancer $loadBalancer load balancer for acquiring database connections
         */
        public function __construct( ILoadBalancer $loadBalancer ) {
                $this->loadBalancer = $loadBalancer;
@@ -224,7 +225,7 @@ class BlockRestrictionStore {
         * Delete the restrictions.
         *
         * @since 1.33
-        * @param Restriction[]|null $restrictions
+        * @param Restriction[] $restrictions
         * @throws MWException
         * @return bool
         */
@@ -435,10 +436,10 @@ class BlockRestrictionStore {
        /**
         * Convert a result row from the database into a restriction object.
         *
-        * @param \stdClass $row
+        * @param stdClass $row
         * @return Restriction|null
         */
-       private function rowToRestriction( \stdClass $row ) {
+       private function rowToRestriction( stdClass $row ) {
                if ( array_key_exists( (int)$row->ir_type, $this->types ) ) {
                        $class = $this->types[ (int)$row->ir_type ];
                        return call_user_func( [ $class, 'newFromRow' ], $row );
index 8efd7de..e0f69dd 100644 (file)
@@ -43,7 +43,7 @@ class CompositeBlock extends AbstractBlock {
         * @param array $options Parameters of the block:
         *     originalBlocks Block[] Blocks that this block is composed from
         */
-       function __construct( $options = [] ) {
+       public function __construct( array $options = [] ) {
                parent::__construct( $options );
 
                $defaults = [
index 0f19324..fbf9a07 100644 (file)
@@ -265,7 +265,7 @@ class DatabaseBlock extends AbstractBlock {
         * Load blocks from the database which target the specific target exactly, or which cover the
         * vague target.
         *
-        * @param User|String|null $specificTarget
+        * @param User|string|null $specificTarget
         * @param int|null $specificType
         * @param bool $fromMaster
         * @param User|string|null $vagueTarget Also search for blocks affecting this target.  Doesn't
@@ -369,7 +369,7 @@ class DatabaseBlock extends AbstractBlock {
         * @param DatabaseBlock[] $blocks These should not include autoblocks or ID blocks
         * @return DatabaseBlock|null The block with the most specific target
         */
-       protected static function chooseMostSpecificBlock( $blocks ) {
+       protected static function chooseMostSpecificBlock( array $blocks ) {
                if ( count( $blocks ) === 1 ) {
                        return $blocks[0];
                }
@@ -535,7 +535,7 @@ class DatabaseBlock extends AbstractBlock {
         * @return bool|array False on failure, assoc array on success:
         *      ('id' => block ID, 'autoIds' => array of autoblock IDs)
         */
-       public function insert( $dbw = null ) {
+       public function insert( IDatabase $dbw = null ) {
                global $wgBlockDisablesLogin;
 
                if ( !$this->getBlocker() || $this->getBlocker()->getName() === '' ) {
index 2a8c663..029e0b8 100644 (file)
@@ -45,7 +45,7 @@ class SystemBlock extends AbstractBlock {
         *                          in the database. Value is a string to return
         *                          from self::getSystemBlockType().
         */
-       function __construct( $options = [] ) {
+       public function __construct( array $options = [] ) {
                parent::__construct( $options );
 
                $defaults = [