Code style fixes to ApiBase::requireAtLeastOneParameter
authorTyler Anthony Romeo <tylerromeo@gmail.com>
Fri, 24 Jan 2014 18:32:36 +0000 (10:32 -0800)
committerTyler Anthony Romeo <tylerromeo@gmail.com>
Fri, 24 Jan 2014 18:32:36 +0000 (10:32 -0800)
Fixes to patch that introduced ApiBase::requireAtLeastOneParameter.
Includes line breaks, code formatting, and documentation fixes.

Change-Id: I1a2faebf7cc9a2126def66d8a4ce64dbfa84059b
Follows-Up: Iae6649ed503fdbf14 (5e7a9c6f8e66de344e)

includes/api/ApiBase.php

index c1a4cd3..e610d19 100644 (file)
@@ -803,25 +803,32 @@ abstract class ApiBase extends ContextSource {
 
        /**
         * Die if none of a certain set of parameters is set and not false.
-        * @param array $params of parameter names
+        *
+        * @since 1.23
+        * @param array $params User provided set of parameters
+        * @param string ... List of parameter names to check
         */
        public function requireAtLeastOneParameter( $params ) {
                $required = func_get_args();
                array_shift( $required );
                $p = $this->getModulePrefix();
 
-               $intersection = array_intersect( array_keys( array_filter( $params,
-                       array( $this, "parameterNotEmpty" ) ) ), $required );
+               $intersection = array_intersect(
+                       array_keys( array_filter( $params, array( $this, "parameterNotEmpty" ) ) ),
+                       $required
+               );
 
                if ( count( $intersection ) == 0 ) {
-                       $this->dieUsage( "At least one of the parameters {$p}" . implode( ", {$p}", $required ) . ' is required', "{$p}missingparam" );
+                       $this->dieUsage( "At least one of the parameters {$p}" .
+                               implode( ", {$p}", $required ) . ' is required', "{$p}missingparam" );
                }
        }
 
        /**
         * Generates the possible errors requireAtLeastOneParameter() can die with
         *
-        * @param $params array
+        * @since 1.23
+        * @param $params array Array of parameter key names
         * @return array
         */
        public function getRequireAtLeastOneParameterErrorMessages( $params ) {
@@ -829,7 +836,10 @@ abstract class ApiBase extends ContextSource {
                $params = implode( ", {$p}", $params );
 
                return array(
-                       array( 'code' => "{$p}missingparam", 'info' => "At least one of the parameters {$p}{$params} is required" ),
+                       array(
+                               'code' => "{$p}missingparam",
+                               'info' => "At least one of the parameters {$p}{$params} is required",
+                       ),
                );
        }