Merge "fixed php doc in ApiBase"
[lhc/web/wiklou.git] / includes / api / ApiBase.php
index 78e1eff..f386a8a 100644 (file)
@@ -80,8 +80,8 @@ abstract class ApiBase extends ContextSource {
        /**
         * Constructor
         * @param $mainModule ApiMain object
-        * @param $moduleName string Name of this module
-        * @param $modulePrefix string Prefix to use for parameter names
+        * @param string $moduleName Name of this module
+        * @param string $modulePrefix Prefix to use for parameter names
         */
        public function __construct( $mainModule, $moduleName, $modulePrefix = '' ) {
                $this->mMainModule = $mainModule;
@@ -224,7 +224,7 @@ abstract class ApiBase extends ContextSource {
         * section to notice any changes in API. Multiple calls to this
         * function will result in the warning messages being separated by
         * newlines
-        * @param $warning string Warning message
+        * @param string $warning Warning message
         */
        public function setWarning( $warning ) {
                $result = $this->getResult();
@@ -340,8 +340,8 @@ abstract class ApiBase extends ContextSource {
        }
 
        /**
-        * @param $prefix string Text to split output items
-        * @param $title string What is being output
+        * @param string $prefix Text to split output items
+        * @param string $title What is being output
         * @param $input string|array
         * @return string
         */
@@ -445,7 +445,7 @@ abstract class ApiBase extends ContextSource {
                                                                $hintPipeSeparated = false;
                                                                break;
                                                        case 'limit':
-                                                               $desc .= $paramPrefix . "No more than {$paramSettings[self :: PARAM_MAX]}";
+                                                               $desc .= $paramPrefix . "No more than {$paramSettings[self::PARAM_MAX]}";
                                                                if ( isset( $paramSettings[self::PARAM_MAX2] ) ) {
                                                                        $desc .= " ({$paramSettings[self::PARAM_MAX2]} for bots)";
                                                                }
@@ -549,7 +549,7 @@ abstract class ApiBase extends ContextSource {
         * Get final list of parameters, after hooks have had a chance to
         * tweak it as needed.
         *
-        * @param $flags int Zero or more flags like GET_VALUES_FOR_HELP
+        * @param int $flags Zero or more flags like GET_VALUES_FOR_HELP
         * @return array|Bool False on no parameters
         * @since 1.21 $flags param added
         */
@@ -631,7 +631,7 @@ abstract class ApiBase extends ContextSource {
        /**
         * This method mangles parameter name based on the prefix supplied to the constructor.
         * Override this method to change parameter name during runtime
-        * @param $paramName string Parameter name
+        * @param string $paramName Parameter name
         * @return string Prefixed parameter name
         */
        public function encodeParamName( $paramName ) {
@@ -666,8 +666,8 @@ abstract class ApiBase extends ContextSource {
 
        /**
         * Get a value for the given parameter
-        * @param $paramName string Parameter name
-        * @param $parseLimit bool see extractRequestParams()
+        * @param string $paramName Parameter name
+        * @param bool $parseLimit see extractRequestParams()
         * @return mixed Parameter value
         */
        protected function getParameter( $paramName, $parseLimit = true ) {
@@ -678,7 +678,7 @@ abstract class ApiBase extends ContextSource {
 
        /**
         * Die if none or more than one of a certain set of parameters is set and not false.
-        * @param $params array of parameter names
+        * @param array $params of parameter names
         */
        public function requireOnlyOneParameter( $params ) {
                $required = func_get_args();
@@ -746,7 +746,7 @@ abstract class ApiBase extends ContextSource {
 
        /**
         * @param $params array
-        * @param $load bool|string Whether load the object's state from the database:
+        * @param bool|string $load Whether load the object's state from the database:
         *        - false: don't load (if the pageid is given, it will still be loaded)
         *        - 'fromdb': load from a slave database
         *        - 'fromdbmaster': load from the master database
@@ -816,13 +816,13 @@ abstract class ApiBase extends ContextSource {
 
        /**
         * Return true if we're to watch the page, false if not, null if no change.
-        * @param $watchlist String Valid values: 'watch', 'unwatch', 'preferences', 'nochange'
+        * @param string $watchlist Valid values: 'watch', 'unwatch', 'preferences', 'nochange'
         * @param $titleObj Title the page under consideration
-        * @param $userOption String The user option to consider when $watchlist=preferences.
+        * @param string $userOption The user option to consider when $watchlist=preferences.
         *      If not set will magically default to either watchdefault or watchcreations
         * @return bool
         */
-       protected function getWatchlistValue ( $watchlist, $titleObj, $userOption = null ) {
+       protected function getWatchlistValue( $watchlist, $titleObj, $userOption = null ) {
 
                $userWatching = $this->getUser()->isWatched( $titleObj );
 
@@ -856,9 +856,9 @@ abstract class ApiBase extends ContextSource {
 
        /**
         * Set a watch (or unwatch) based the based on a watchlist parameter.
-        * @param $watch String Valid values: 'watch', 'unwatch', 'preferences', 'nochange'
+        * @param string $watch Valid values: 'watch', 'unwatch', 'preferences', 'nochange'
         * @param $titleObj Title the article's title to change
-        * @param $userOption String The user option to consider when $watch=preferences
+        * @param string $userOption The user option to consider when $watch=preferences
         */
        protected function setWatch( $watch, $titleObj, $userOption = null ) {
                $value = $this->getWatchlistValue( $watch, $titleObj, $userOption );
@@ -877,8 +877,8 @@ abstract class ApiBase extends ContextSource {
        /**
         * Using the settings determine the value for the given parameter
         *
-        * @param $paramName String: parameter name
-        * @param $paramSettings array|mixed default value or an array of settings
+        * @param string $paramName parameter name
+        * @param array|mixed $paramSettings default value or an array of settings
         *  using PARAM_* constants.
         * @param $parseLimit Boolean: parse limit?
         * @return mixed Parameter value
@@ -1056,10 +1056,10 @@ abstract class ApiBase extends ContextSource {
         * Return an array of values that were given in a 'a|b|c' notation,
         * after it optionally validates them against the list allowed values.
         *
-        * @param $valueName string The name of the parameter (for error
+        * @param string $valueName The name of the parameter (for error
         *  reporting)
         * @param $value mixed The value being parsed
-        * @param $allowMultiple bool Can $value contain more than one value
+        * @param bool $allowMultiple Can $value contain more than one value
         *  separated by '|'?
         * @param $allowedValues mixed An array of values to check against. If
         *  null, all values are accepted.
@@ -1081,7 +1081,7 @@ abstract class ApiBase extends ContextSource {
 
                if ( !$allowMultiple && count( $valuesList ) != 1 ) {
                        // Bug 33482 - Allow entries with | in them for non-multiple values
-                       if ( in_array( $value, $allowedValues ) ) {
+                       if ( in_array( $value, $allowedValues, true ) ) {
                                return $value;
                        }
 
@@ -1111,11 +1111,11 @@ abstract class ApiBase extends ContextSource {
        /**
         * Validate the value against the minimum and user/bot maximum limits.
         * Prints usage info on failure.
-        * @param $paramName string Parameter name
-        * @param $value int Parameter value
-        * @param $min int|null Minimum value
-        * @param $max int|null Maximum value for users
-        * @param $botMax int Maximum value for sysops/bots
+        * @param string $paramName Parameter name
+        * @param int $value Parameter value
+        * @param int|null $min Minimum value
+        * @param int|null $max Maximum value for users
+        * @param int $botMax Maximum value for sysops/bots
         * @param $enforceLimits Boolean Whether to enforce (die) if value is outside limits
         */
        function validateLimit( $paramName, &$value, $min, $max, $botMax = null, $enforceLimits = false ) {
@@ -1150,8 +1150,8 @@ abstract class ApiBase extends ContextSource {
 
        /**
         * Validate and normalize of parameters of type 'timestamp'
-        * @param $value string Parameter value
-        * @param $encParamName string Parameter name
+        * @param string $value Parameter value
+        * @param string $encParamName Parameter name
         * @return string Validated and normalized parameter
         */
        function validateTimestamp( $value, $encParamName ) {
@@ -1164,8 +1164,8 @@ abstract class ApiBase extends ContextSource {
 
        /**
         * Validate and normalize of parameters of type 'user'
-        * @param $value string Parameter value
-        * @param $encParamName string Parameter value
+        * @param string $value Parameter value
+        * @param string $encParamName Parameter name
         * @return string Validated and normalized parameter
         */
        private function validateUser( $value, $encParamName ) {
@@ -1192,8 +1192,8 @@ abstract class ApiBase extends ContextSource {
 
        /**
         * Truncate an array to a certain length.
-        * @param $arr array Array to truncate
-        * @param $limit int Maximum length
+        * @param array $arr Array to truncate
+        * @param int $limit Maximum length
         * @return bool True if the array was truncated, false otherwise
         */
        public static function truncateArray( &$arr, $limit ) {
@@ -1209,12 +1209,12 @@ abstract class ApiBase extends ContextSource {
         * Throw a UsageException, which will (if uncaught) call the main module's
         * error handler and die with an error message.
         *
-        * @param $description string One-line human-readable description of the
+        * @param string $description One-line human-readable description of the
         *   error condition, e.g., "The API requires a valid action parameter"
-        * @param $errorCode string Brief, arbitrary, stable string to allow easy
+        * @param string $errorCode Brief, arbitrary, stable string to allow easy
         *   automated identification of the error, e.g., 'unknown_action'
-        * @param $httpRespCode int HTTP response code
-        * @param $extradata array Data to add to the "<error>" element; array in ApiResult format
+        * @param int $httpRespCode HTTP response code
+        * @param array $extradata Data to add to the "<error>" element; array in ApiResult format
         * @throws UsageException
         */
        public function dieUsage( $description, $errorCode, $httpRespCode = 0, $extradata = null ) {
@@ -1439,7 +1439,7 @@ abstract class ApiBase extends ContextSource {
 
        /**
         * Return the error message related to a certain array
-        * @param $error array Element of a getUserPermissionsErrors()-style array
+        * @param array $error Element of a getUserPermissionsErrors()-style array
         * @return array('code' => code, 'info' => info)
         */
        public function parseMsg( $error ) {
@@ -1466,8 +1466,8 @@ abstract class ApiBase extends ContextSource {
 
        /**
         * Internal code errors should be reported with this method
-        * @param $method string Method or function name
-        * @param $message string Error message
+        * @param string $method Method or function name
+        * @param string $message Error message
         */
        protected static function dieDebug( $method, $message ) {
                wfDebugDieBacktrace( "Internal error in $method: $message" );
@@ -1535,7 +1535,7 @@ abstract class ApiBase extends ContextSource {
        public function getWatchlistUser( $params ) {
                if ( !is_null( $params['owner'] ) && !is_null( $params['token'] ) ) {
                        $user = User::newFromName( $params['owner'], false );
-                       if ( !($user && $user->getId()) ) {
+                       if ( !( $user && $user->getId() ) ) {
                                $this->dieUsage( 'Specified user does not exist', 'bad_wlowner' );
                        }
                        $token = $user->getOption( 'watchlisttoken' );
@@ -1568,7 +1568,7 @@ abstract class ApiBase extends ContextSource {
                $params = $this->getFinalParams();
                if ( $params ) {
                        foreach ( $params as $paramName => $paramSettings ) {
-                               if ( isset( $paramSettings[ApiBase::PARAM_REQUIRED] ) ) {
+                               if ( isset( $paramSettings[ApiBase::PARAM_REQUIRED] ) && $paramSettings[ApiBase::PARAM_REQUIRED] ) {
                                        $ret[] = array( 'missingparam', $paramName );
                                }
                        }
@@ -1604,7 +1604,7 @@ abstract class ApiBase extends ContextSource {
 
        /**
         * Parses a list of errors into a standardised format
-        * @param $errors array List of errors. Items can be in the for array( key, param1, param2, ... ) or array( 'code' => ..., 'info' => ... )
+        * @param array $errors List of errors. Items can be in the for array( key, param1, param2, ... ) or array( 'code' => ..., 'info' => ... )
         * @return array Parsed list of errors with items in the form array( 'code' => ..., 'info' => ... )
         */
        public function parseErrors( $errors ) {
@@ -1741,8 +1741,8 @@ abstract class ApiBase extends ContextSource {
        /**
         * Debugging function that prints a value and an optional backtrace
         * @param $value mixed Value to print
-        * @param $name string Description of the printed value
-        * @param $backtrace bool If true, print a backtrace
+        * @param string $name Description of the printed value
+        * @param bool $backtrace If true, print a backtrace
         */
        public static function debugPrint( $value, $name = 'unknown', $backtrace = false ) {
                print "\n\n<pre><b>Debugging value '$name':</b>\n\n";