/**
* This class represents the result of the API operations.
- * It simply wraps a nested array() structure, adding some functions to simplify array's modifications.
- * As various modules execute, they add different pieces of information to this result,
- * structuring it as it will be given to the client.
+ * It simply wraps a nested array() structure, adding some functions to simplify
+ * array's modifications. As various modules execute, they add different pieces
+ * of information to this result, structuring it as it will be given to the client.
*
* Each subarray may either be a dictionary - key-value pairs with unique keys,
* or lists, where the items are added using $data[] = $value notation.
* There are two special key values that change how XML output is generated:
* '_element' This key sets the tag name for the rest of the elements in the current array.
* It is only inserted if the formatter returned true for getNeedsRawData()
- * '*' This key has special meaning only to the XML formatter, and is outputed as is
- * for all others. In XML it becomes the content of the current element.
+ * '*' This key has special meaning only to the XML formatter, and is outputted as is
+ * for all others. In XML it becomes the content of the current element.
*
* @ingroup API
*/
// Objects can't always be cast to string
$s = strlen( $value );
}
+
return $s;
}
/**
* Add an output value to the array by name.
* Verifies that value with the same name has not been added before.
- * @param $arr array to add $value to
- * @param $name string Index of $arr to add $value at
+ * @param array $arr to add $value to
+ * @param string $name Index of $arr to add $value at
* @param $value mixed
- * @param $flags int Zero or more OR-ed flags like OVERRIDE | ADD_ON_TOP. This parameter used to be
- * boolean, and the value of OVERRIDE=1 was specifically chosen so that it would be backwards
- * compatible with the new method signature.
+ * @param int $flags Zero or more OR-ed flags like OVERRIDE | ADD_ON_TOP.
+ * This parameter used to be boolean, and the value of OVERRIDE=1 was
+ * specifically chosen so that it would be backwards compatible with the
+ * new method signature.
*
* @since 1.21 int $flags replaced boolean $override
*/
public static function setElement( &$arr, $name, $value, $flags = 0 ) {
- if ( $arr === null || $name === null || $value === null || !is_array( $arr ) || is_array( $name ) ) {
+ if ( $arr === null || $name === null || $value === null
+ || !is_array( $arr ) || is_array( $name )
+ ) {
ApiBase::dieDebug( __METHOD__, 'Bad parameter' );
}
ApiBase::dieDebug( __METHOD__, "Attempting to merge element $name" );
}
} else {
- ApiBase::dieDebug( __METHOD__, "Attempting to add element $name=$value, existing value is {$arr[$name]}" );
+ ApiBase::dieDebug(
+ __METHOD__,
+ "Attempting to add element $name=$value, existing value is {$arr[$name]}"
+ );
}
}
/**
* Adds a content element to an array.
* Use this function instead of hardcoding the '*' element.
- * @param $arr array to add the content element to
+ * @param array $arr to add the content element to
* @param $value Mixed
- * @param $subElemName string when present, content element is created
+ * @param string $subElemName when present, content element is created
* as a sub item of $arr. Use this parameter to create elements in
* format "<elem>text</elem>" without attributes.
*/
* give all indexed values the given tag name. This function MUST be
* called on every array that has numerical indexes.
* @param $arr array
- * @param $tag string Tag name
+ * @param string $tag Tag name
*/
public function setIndexedTagName( &$arr, $tag ) {
// In raw mode, add the '_element', otherwise just ignore
/**
* Calls setIndexedTagName() on each sub-array of $arr
* @param $arr array
- * @param $tag string Tag name
+ * @param string $tag Tag name
*/
public function setIndexedTagName_recursive( &$arr, $tag ) {
if ( !is_array( $arr ) ) {
* Calls setIndexedTagName() on an array already in the result.
* Don't specify a path to a value that's not in the result, or
* you'll get nasty errors.
- * @param $path array Path to the array, like addValue()'s $path
+ * @param array $path Path to the array, like addValue()'s $path
* @param $tag string
*/
public function setIndexedTagName_internal( $path, $tag ) {
* @param $path array|string|null
* @param $name string
* @param $value mixed
- * @param $flags int Zero or more OR-ed flags like OVERRIDE | ADD_ON_TOP. This parameter used to be
- * boolean, and the value of OVERRIDE=1 was specifically chosen so that it would be backwards
- * compatible with the new method signature.
+ * @param int $flags Zero or more OR-ed flags like OVERRIDE | ADD_ON_TOP. This
+ * parameter used to be boolean, and the value of OVERRIDE=1 was specifically
+ * chosen so that it would be backwards compatible with the new method
+ * signature.
* @return bool True if $value fits in the result, false if not
*
* @since 1.21 int $flags replaced boolean $override
if ( $newsize > $wgAPIMaxResultSize ) {
$this->setWarning(
"This result was truncated because it would otherwise be larger than the " .
- "limit of {$wgAPIMaxResultSize} bytes" );
+ "limit of {$wgAPIMaxResultSize} bytes" );
+
return false;
}
$this->mSize = $newsize;
// Add named element
self::setElement( $data, $name, $value, $flags );
}
+
return true;
}
$result[] = $error;
}
$this->setIndexedTagName( $result, $errorType );
+
return $result;
}