Convert remaining array() to [] in API
[lhc/web/wiklou.git] / includes / api / ApiBlock.php
index 26b5f0e..e4c9d0a 100644 (file)
@@ -52,7 +52,13 @@ class ApiBlock extends ApiBase {
                if ( $user->isBlocked() ) {
                        $status = SpecialBlock::checkUnblockSelf( $params['user'], $user );
                        if ( $status !== true ) {
-                               $this->dieUsageMsg( array( $status ) );
+                               $msg = $this->parseMsg( $status );
+                               $this->dieUsage(
+                                       $msg['info'],
+                                       $msg['code'],
+                                       0,
+                                       [ 'blockinfo' => ApiQueryUserInfo::getBlockInfo( $user->getBlock() ) ]
+                               );
                        }
                }
 
@@ -62,7 +68,7 @@ class ApiBlock extends ApiBase {
                if ( $target instanceof User &&
                        ( $target->isAnon() /* doesn't exist */ || !User::isUsableName( $target->getName() ) )
                ) {
-                       $this->dieUsageMsg( array( 'nosuchuser', $params['user'] ) );
+                       $this->dieUsageMsg( [ 'nosuchuser', $params['user'] ] );
                }
 
                if ( $params['hidename'] && !$user->isAllowed( 'hideuser' ) ) {
@@ -72,14 +78,14 @@ class ApiBlock extends ApiBase {
                        $this->dieUsageMsg( 'cantblock-email' );
                }
 
-               $data = array(
+               $data = [
                        'PreviousTarget' => $params['user'],
                        'Target' => $params['user'],
-                       'Reason' => array(
+                       'Reason' => [
                                $params['reason'],
                                'other',
                                $params['reason']
-                       ),
+                       ],
                        'Expiry' => $params['expiry'],
                        'HardBlock' => !$params['anononly'],
                        'CreateAccount' => $params['nocreate'],
@@ -90,7 +96,7 @@ class ApiBlock extends ApiBase {
                        'Reblock' => $params['reblock'],
                        'Watch' => $params['watchuser'],
                        'Confirm' => true,
-               );
+               ];
 
                $retval = SpecialBlock::processForm( $data, $this->getContext() );
                if ( $retval !== true ) {
@@ -133,11 +139,11 @@ class ApiBlock extends ApiBase {
        }
 
        public function getAllowedParams() {
-               return array(
-                       'user' => array(
-                               ApiBase::PARAM_TYPE => 'string',
+               return [
+                       'user' => [
+                               ApiBase::PARAM_TYPE => 'user',
                                ApiBase::PARAM_REQUIRED => true
-                       ),
+                       ],
                        'expiry' => 'never',
                        'reason' => '',
                        'anononly' => false,
@@ -148,7 +154,7 @@ class ApiBlock extends ApiBase {
                        'allowusertalk' => false,
                        'reblock' => false,
                        'watchuser' => false,
-               );
+               ];
        }
 
        public function needsToken() {
@@ -156,12 +162,14 @@ class ApiBlock extends ApiBase {
        }
 
        protected function getExamplesMessages() {
-               return array(
+               // @codingStandardsIgnoreStart Generic.Files.LineLength
+               return [
                        'action=block&user=192.0.2.5&expiry=3%20days&reason=First%20strike&token=123ABC'
                                => 'apihelp-block-example-ip-simple',
                        'action=block&user=Vandal&expiry=never&reason=Vandalism&nocreate=&autoblock=&noemail=&token=123ABC'
                                => 'apihelp-block-example-user-complex',
-               );
+               ];
+               // @codingStandardsIgnoreEnd
        }
 
        public function getHelpUrls() {