* @since 1.17
*/
class Message {
+
/**
* In which language to get this message. True, which is the default,
* means the current interface language, false content language.
+ *
+ * @var bool
*/
protected $interface = true;
protected $language = null;
/**
- * The message key.
+ * @var string|string[] The message key or array of keys.
*/
protected $key;
/**
- * List of parameters which will be substituted into the message.
+ * @var array List of parameters which will be substituted into the message.
*/
protected $parameters = array();
* * block-parse
* * parse (default)
* * plain
+ *
+ * @var string
*/
protected $format = 'parse';
/**
- * Whether database can be used.
+ * @var bool Whether database can be used.
*/
protected $useDatabase = true;
/**
- * Title object to use as context
+ * @var Title Title object to use as context.
*/
protected $title = null;
/**
- * Content object representing the message
+ * @var Content Content object representing the message.
*/
protected $content = null;
protected $message;
/**
- * Constructor.
* @since 1.17
- * @param $key: message key, or array of message keys to try and use the first non-empty message for
- * @param array $params message parameters
- * @return Message: $this
+ *
+ * @param string|string[] $key Message key or array of message keys to try and use the first
+ * non-empty message for.
+ * @param array $params Message parameters.
*/
public function __construct( $key, $params = array() ) {
global $wgLang;
}
/**
- * Returns the message key
+ * Returns the message key or the first from an array of message keys.
*
* @since 1.21
*
}
/**
- * Returns the message parameters
+ * Returns the message parameters.
*
* @since 1.21
*
- * @return string[]
+ * @return array
*/
public function getParams() {
return $this->parameters;
}
/**
- * Returns the message format
+ * Returns the message format.
*
* @since 1.21
*
* Factory function that is just wrapper for the real constructor. It is
* intended to be used instead of the real constructor, because it allows
* chaining method calls, while new objects don't.
+ *
* @since 1.17
- * @param string $key message key
- * @param Varargs: parameters as Strings
- * @return Message: $this
+ *
+ * @param string|string[] $key Message key or array of keys.
+ * @param mixed [$param,...] Parameters as strings.
+ *
+ * @return Message
*/
public static function newFromKey( $key /*...*/ ) {
$params = func_get_args();
* Factory function accepting multiple message keys and returning a message instance
* for the first message which is non-empty. If all messages are empty then an
* instance of the first message key is returned.
+ *
* @since 1.18
- * @param Varargs: message keys (or first arg as an array of all the message keys)
- * @return Message: $this
+ *
+ * @param string|string[] [$keys,...] Message keys, or first argument as an array of all the
+ * message keys.
+ *
+ * @return Message
*/
public static function newFallbackSequence( /*...*/ ) {
$keys = func_get_args();
/**
* Adds parameters to the parameter list of this message.
+ *
* @since 1.17
- * @param Varargs: parameters as Strings, or a single argument that is an array of Strings
- * @return Message: $this
+ *
+ * @param mixed [$params,...] Parameters as strings, or a single argument that is
+ * an array of strings.
+ *
+ * @return Message $this
*/
public function params( /*...*/ ) {
$args = func_get_args();
* In other words the parsing process cannot access the contents
* of this type of parameter, and you need to make sure it is
* sanitized beforehand. The parser will see "$n", instead.
+ *
* @since 1.17
- * @param Varargs: raw parameters as Strings (or single argument that is an array of raw parameters)
- * @return Message: $this
+ *
+ * @param mixed [$params,...] Raw parameters as strings, or a single argument that is
+ * an array of raw parameters.
+ *
+ * @return Message $this
*/
public function rawParams( /*...*/ ) {
$params = func_get_args();
/**
* Add parameters that are numeric and will be passed through
* Language::formatNum before substitution
+ *
* @since 1.18
- * @param Varargs: numeric parameters (or single argument that is array of numeric parameters)
- * @return Message: $this
+ *
+ * @param mixed [$param,...] Numeric parameters, or a single argument that is
+ * an array of numeric parameters.
+ *
+ * @return Message $this
*/
public function numParams( /*...*/ ) {
$params = func_get_args();
/**
* Add parameters that are durations of time and will be passed through
* Language::formatDuration before substitution
+ *
* @since 1.22
- * @param Varargs: numeric parameters (or single argument that is array of numeric parameters)
- * @return Message: $this
+ *
+ * @param int|int[] [$param,...] Duration parameters, or a single argument that is
+ * an array of duration parameters.
+ *
+ * @return Message $this
*/
public function durationParams( /*...*/ ) {
$params = func_get_args();
/**
* Add parameters that are expiration times and will be passed through
* Language::formatExpiry before substitution
+ *
* @since 1.22
- * @param Varargs: numeric parameters (or single argument that is array of numeric parameters)
- * @return Message: $this
+ *
+ * @param string|string[] [$param,...] Expiry parameters, or a single argument that is
+ * an array of expiry parameters.
+ *
+ * @return Message $this
*/
public function expiryParams( /*...*/ ) {
$params = func_get_args();
/**
* Add parameters that are time periods and will be passed through
* Language::formatTimePeriod before substitution
+ *
* @since 1.22
- * @param Varargs: numeric parameters (or single argument that is array of numeric parameters)
- * @return Message: $this
+ *
+ * @param number|number[] [$param,...] Time period parameters, or a single argument that is
+ * an array of time period parameters.
+ *
+ * @return Message $this
*/
public function timeperiodParams( /*...*/ ) {
$params = func_get_args();
/**
* Add parameters that are file sizes and will be passed through
* Language::formatSize before substitution
+ *
* @since 1.22
- * @param Varargs: numeric parameters (or single argument that is array of numeric parameters)
- * @return Message: $this
+ *
+ * @param int|int[] [$param,...] Size parameters, or a single argument that is
+ * an array of size parameters.
+ *
+ * @return Message $this
*/
public function sizeParams( /*...*/ ) {
$params = func_get_args();
/**
* Add parameters that are bitrates and will be passed through
* Language::formatBitrate before substitution
+ *
* @since 1.22
- * @param Varargs: numeric parameters (or single argument that is array of numeric parameters)
- * @return Message: $this
+ *
+ * @param int|int[] [$param,...] Bit rate parameters, or a single argument that is
+ * an array of bit rate parameters.
+ *
+ * @return Message $this
*/
public function bitrateParams( /*...*/ ) {
$params = func_get_args();
/**
* Set the language and the title from a context object
+ *
* @since 1.19
+ *
* @param $context IContextSource
- * @return Message: $this
+ *
+ * @return Message $this
*/
public function setContext( IContextSource $context ) {
$this->inLanguage( $context->getLanguage() );
* Request the message in any language that is supported.
* As a side effect interface message status is unconditionally
* turned off.
+ *
* @since 1.17
- * @param $lang Mixed: language code or Language object.
+ *
+ * @param Language|string $lang Language code or Language object.
+ *
+ * @return Message $this
* @throws MWException
- * @return Message: $this
*/
public function inLanguage( $lang ) {
if ( $lang instanceof Language || $lang instanceof StubUserLang ) {
/**
* Request the message in the wiki's content language,
* unless it is disabled for this message.
+ *
* @since 1.17
* @see $wgForceUIMsgAsContentMsg
- * @return Message: $this
+ *
+ * @return Message $this
*/
public function inContentLanguage() {
global $wgForceUIMsgAsContentMsg;
/**
* Allows manipulating the interface message flag directly.
* Can be used to restore the flag after setting a language.
- * @param $value bool
- * @return Message: $this
+ *
* @since 1.20
+ *
+ * @param bool $interface
+ *
+ * @return Message $this
*/
- public function setInterfaceMessageFlag( $value ) {
- $this->interface = (bool)$value;
+ public function setInterfaceMessageFlag( $interface ) {
+ $this->interface = (bool)$interface;
return $this;
}
/**
* Enable or disable database use.
+ *
* @since 1.17
- * @param $value Boolean
- * @return Message: $this
+ *
+ * @param bool $useDatabase
+ *
+ * @return Message $this
*/
- public function useDatabase( $value ) {
- $this->useDatabase = (bool)$value;
+ public function useDatabase( $useDatabase ) {
+ $this->useDatabase = (bool)$useDatabase;
return $this;
}
/**
* Set the Title object to use as context when transforming the message
+ *
* @since 1.18
+ *
* @param $title Title object
- * @return Message: $this
+ *
+ * @return Message $this
*/
public function title( $title ) {
$this->title = $title;
/**
* Returns the message as a Content object.
+ *
* @return Content
*/
public function content() {
/**
* Returns the message parsed from wikitext to HTML.
+ *
* @since 1.17
- * @return String: HTML
+ *
+ * @return string HTML
*/
public function toString() {
$string = $this->fetchMessage();
* Magic method implementation of the above (for PHP >= 5.2.0), so we can do, eg:
* $foo = Message::get( $key );
* $string = "<abbr>$foo</abbr>";
+ *
* @since 1.18
- * @return String
+ *
+ * @return string
*/
public function __toString() {
// PHP doesn't allow __toString to throw exceptions and will
}
/**
- * Fully parse the text from wikitext to HTML
+ * Fully parse the text from wikitext to HTML.
+ *
* @since 1.17
- * @return String parsed HTML
+ *
+ * @return string Parsed HTML.
*/
public function parse() {
$this->format = 'parse';
/**
* Returns the message text. {{-transformation is done.
+ *
* @since 1.17
- * @return String: Unescaped message text.
+ *
+ * @return string Unescaped message text.
*/
public function text() {
$this->format = 'text';
/**
* Returns the message text as-is, only parameters are substituted.
+ *
* @since 1.17
- * @return String: Unescaped untransformed message text.
+ *
+ * @return string Unescaped untransformed message text.
*/
public function plain() {
$this->format = 'plain';
/**
* Returns the parsed message text which is always surrounded by a block element.
+ *
* @since 1.17
- * @return String: HTML
+ *
+ * @return string HTML
*/
public function parseAsBlock() {
$this->format = 'block-parse';
/**
* Returns the message text. {{-transformation is done and the result
* is escaped excluding any raw parameters.
+ *
* @since 1.17
- * @return String: Escaped message text.
+ *
+ * @return string Escaped message text.
*/
public function escaped() {
$this->format = 'escaped';
/**
* Check whether a message key has been defined currently.
+ *
* @since 1.17
- * @return Bool: true if it is and false if not.
+ *
+ * @return bool
*/
public function exists() {
return $this->fetchMessage() !== false;
/**
* Check whether a message does not exist, or is an empty string
+ *
* @since 1.18
- * @return Bool: true if is is and false if not
* @todo FIXME: Merge with isDisabled()?
+ *
+ * @return bool
*/
public function isBlank() {
$message = $this->fetchMessage();
}
/**
- * Check whether a message does not exist, is an empty string, or is "-"
+ * Check whether a message does not exist, is an empty string, or is "-".
+ *
* @since 1.18
- * @return Bool: true if it is and false if not
+ *
+ * @return bool
*/
public function isDisabled() {
$message = $this->fetchMessage();
/**
* @since 1.17
- * @param $value
- * @return array
+ *
+ * @param mixed $raw
+ *
+ * @return array Array with a single "raw" key.
*/
- public static function rawParam( $value ) {
- return array( 'raw' => $value );
+ public static function rawParam( $raw ) {
+ return array( 'raw' => $raw );
}
/**
* @since 1.18
- * @param $value
- * @return array
+ *
+ * @param mixed $num
+ *
+ * @return array Array with a single "num" key.
*/
- public static function numParam( $value ) {
- return array( 'num' => $value );
+ public static function numParam( $num ) {
+ return array( 'num' => $num );
}
/**
* @since 1.22
- * @param $value
- * @return array
+ *
+ * @param int $duration
+ *
+ * @return int[] Array with a single "duration" key.
*/
- public static function durationParam( $value ) {
- return array( 'duration' => $value );
+ public static function durationParam( $duration ) {
+ return array( 'duration' => $duration );
}
/**
* @since 1.22
- * @param $value
- * @return array
+ *
+ * @param string $expiry
+ *
+ * @return string[] Array with a single "expiry" key.
*/
- public static function expiryParam( $value ) {
- return array( 'expiry' => $value );
+ public static function expiryParam( $expiry ) {
+ return array( 'expiry' => $expiry );
}
/**
* @since 1.22
- * @param $value
- * @return array
+ *
+ * @param number $period
+ *
+ * @return number[] Array with a single "period" key.
*/
- public static function timeperiodParam( $value ) {
- return array( 'period' => $value );
+ public static function timeperiodParam( $period ) {
+ return array( 'period' => $period );
}
/**
* @since 1.22
- * @param $value
- * @return array
+ *
+ * @param int $size
+ *
+ * @return int[] Array with a single "size" key.
*/
- public static function sizeParam( $value ) {
- return array( 'size' => $value );
+ public static function sizeParam( $size ) {
+ return array( 'size' => $size );
}
/**
* @since 1.22
- * @param $value
- * @return array
+ *
+ * @param int $bitrate
+ *
+ * @return int[] Array with a single "bitrate" key.
*/
- public static function bitrateParam( $value ) {
- return array( 'bitrate' => $value );
+ public static function bitrateParam( $bitrate ) {
+ return array( 'bitrate' => $bitrate );
}
/**
* Substitutes any parameters into the message text.
+ *
* @since 1.17
- * @param string $message the message text
- * @param string $type either before or after
+ *
+ * @param string $message The message text.
+ * @param string $type Either "before" or "after".
+ *
* @return String
*/
protected function replaceParameters( $message, $type = 'before' ) {
/**
* Extracts the parameter type and preprocessed the value if needed.
+ *
* @since 1.18
- * @param string|array $param Parameter as defined in this class.
- * @return Tuple(type, value)
+ *
+ * @param mixed $param Parameter as defined in this class.
+ *
+ * @return array Array with the parameter type (either "before" or "after") and the value.
*/
protected function extractParam( $param ) {
if ( is_array( $param ) ) {
/**
* Wrapper for what ever method we use to parse wikitext.
+ *
* @since 1.17
- * @param string $string Wikitext message contents
- * @return string Wikitext parsed into HTML
+ *
+ * @param string $string Wikitext message contents.
+ *
+ * @return string Wikitext parsed into HTML.
*/
protected function parseText( $string ) {
$out = MessageCache::singleton()->parse( $string, $this->title, /*linestart*/true, $this->interface, $this->language );
/**
* Wrapper for what ever method we use to {{-transform wikitext.
+ *
* @since 1.17
- * @param string $string Wikitext message contents
+ *
+ * @param string $string Wikitext message contents.
+ *
* @return string Wikitext with {{-constructs replaced with their values.
*/
protected function transformText( $string ) {
}
/**
- * Wrapper for what ever method we use to get message contents
+ * Wrapper for what ever method we use to get message contents.
+ *
* @since 1.17
- * @throws MWException
+ *
* @return string
+ * @throws MWException If message key array is empty.
*/
protected function fetchMessage() {
if ( !isset( $this->message ) ) {
* @since 1.21
*/
class RawMessage extends Message {
+
/**
* Call the parent constructor, then store the key as
* the message.
*
- * @param string $key Message to use
- * @param array $params Parameters for the message
* @see Message::__construct
+ *
+ * @param string|string[] $key Message to use.
+ * @param array $params Parameters for the message.
*/
public function __construct( $key, $params = array() ) {
parent::__construct( $key, $params );
}
return $this->message;
}
+
}
protected $model_id;
/**
- * @param string|null $modelId
+ * @param string $modelId
*
* @since 1.21
*/
}
/**
- * @see Content::getModel
- *
* @since 1.21
+ *
+ * @see Content::getModel
*/
public function getModel() {
return $this->model_id;
}
/**
- * Throws an MWException if $model_id is not the id of the content model
- * supported by this Content object.
- *
* @since 1.21
*
* @param string $modelId The model to check
*
- * @throws MWException
+ * @throws MWException If the provided ID is not the ID of the content model supported by this
+ * Content object.
*/
protected function checkModelID( $modelId ) {
if ( $modelId !== $this->model_id ) {
}
/**
- * @see Content::getContentHandler
- *
* @since 1.21
+ *
+ * @see Content::getContentHandler
*/
public function getContentHandler() {
return ContentHandler::getForContent( $this );
}
/**
- * @see Content::getDefaultFormat
- *
* @since 1.21
+ *
+ * @see Content::getDefaultFormat
*/
public function getDefaultFormat() {
return $this->getContentHandler()->getDefaultFormat();
}
/**
- * @see Content::getSupportedFormats
- *
* @since 1.21
+ *
+ * @see Content::getSupportedFormats
*/
public function getSupportedFormats() {
return $this->getContentHandler()->getSupportedFormats();
}
/**
- * @see Content::isSupportedFormat
+ * @since 1.21
*
* @param string $format
*
- * @since 1.21
+ * @return bool
*
- * @return boolean
+ * @see Content::isSupportedFormat
*/
public function isSupportedFormat( $format ) {
if ( !$format ) {
}
/**
- * Throws an MWException if $this->isSupportedFormat( $format ) does not
- * return true.
- *
* @since 1.21
*
- * @param string $format
- * @throws MWException
+ * @param string $format The serialization format to check.
+ *
+ * @throws MWException If the format is not supported by this content handler.
*/
protected function checkFormat( $format ) {
if ( !$this->isSupportedFormat( $format ) ) {
}
/**
- * @see Content::serialize
- *
- * @param string|null $format
- *
* @since 1.21
*
+ * @param string $format
+ *
* @return string
+ *
+ * @see Content::serialize
*/
public function serialize( $format = null ) {
return $this->getContentHandler()->serializeContent( $this, $format );
}
/**
- * @see Content::isEmpty
- *
* @since 1.21
*
- * @return boolean
+ * @return bool
+ *
+ * @see Content::isEmpty
*/
public function isEmpty() {
return $this->getSize() === 0;
}
/**
- * @see Content::isValid
+ * Subclasses may override this to implement (light weight) validation.
*
* @since 1.21
*
- * @return boolean
+ * @return bool Always true.
+ *
+ * @see Content::isValid
*/
public function isValid() {
return true;
}
/**
- * @see Content::equals
- *
* @since 1.21
*
- * @param Content|null $that
+ * @param Content $that
*
- * @return boolean
+ * @return bool
+ *
+ * @see Content::equals
*/
public function equals( Content $that = null ) {
if ( is_null( $that ) ) {
* Subclasses may override this to determine the secondary data updates more
* efficiently, preferably without the need to generate a parser output object.
*
- * @see Content::getSecondaryDataUpdates()
+ * @since 1.21
*
- * @param $title Title The context for determining the necessary updates
- * @param $old Content|null An optional Content object representing the
- * previous content, i.e. the content being replaced by this Content
- * object.
- * @param $recursive boolean Whether to include recursive updates (default:
- * false).
- * @param $parserOutput ParserOutput|null Optional ParserOutput object.
- * Provide if you have one handy, to avoid re-parsing of the content.
+ * @param Title $title
+ * @param Content $old
+ * @param bool $recursive
+ * @param ParserOutput $parserOutput
*
- * @return Array. A list of DataUpdate objects for putting information
- * about this content object somewhere.
+ * @return DataUpdate[]
*
- * @since 1.21
+ * @see Content::getSecondaryDataUpdates()
*/
- public function getSecondaryDataUpdates( Title $title,
- Content $old = null,
- $recursive = true, ParserOutput $parserOutput = null
- ) {
+ public function getSecondaryDataUpdates( Title $title, Content $old = null,
+ $recursive = true, ParserOutput $parserOutput = null ) {
if ( $parserOutput === null ) {
$parserOutput = $this->getParserOutput( $title, null, null, false );
}
}
/**
- * @see Content::getRedirectChain
- *
* @since 1.21
+ *
+ * @return Title[]|null
+ *
+ * @see Content::getRedirectChain
*/
public function getRedirectChain() {
global $wgMaxRedirects;
}
/**
- * @see Content::getRedirectTarget
+ * Subclasses that implement redirects should override this.
*
* @since 1.21
+ *
+ * @return null
+ *
+ * @see Content::getRedirectTarget
*/
public function getRedirectTarget() {
return null;
}
/**
- * @see Content::getUltimateRedirectTarget
- * @note: migrated here from Title::newFromRedirectRecurse
+ * @note Migrated here from Title::newFromRedirectRecurse.
*
* @since 1.21
+ *
+ * @return Title|null
+ *
+ * @see Content::getUltimateRedirectTarget
*/
public function getUltimateRedirectTarget() {
$titles = $this->getRedirectChain();
}
/**
- * @see Content::isRedirect
- *
* @since 1.21
*
* @return bool
+ *
+ * @see Content::isRedirect
*/
public function isRedirect() {
return $this->getRedirectTarget() !== null;
}
/**
- * @see Content::updateRedirect
- *
* This default implementation always returns $this.
- *
- * @param Title $target
+ * Subclasses that implement redirects should override this.
*
* @since 1.21
*
+ * @param Title $target
+ *
* @return Content $this
+ *
+ * @see Content::updateRedirect
*/
public function updateRedirect( Title $target ) {
return $this;
}
/**
- * @see Content::getSection
- *
* @since 1.21
+ *
+ * @return null
+ *
+ * @see Content::getSection
*/
public function getSection( $sectionId ) {
return null;
}
/**
- * @see Content::replaceSection
- *
* @since 1.21
+ *
+ * @return null
+ *
+ * @see Content::replaceSection
*/
public function replaceSection( $section, Content $with, $sectionTitle = '' ) {
return null;
}
/**
- * @see Content::preSaveTransform
- *
* @since 1.21
+ *
+ * @return Content $this
+ *
+ * @see Content::preSaveTransform
*/
public function preSaveTransform( Title $title, User $user, ParserOptions $popts ) {
return $this;
}
/**
- * @see Content::addSectionHeader
- *
* @since 1.21
+ *
+ * @return Content $this
+ *
+ * @see Content::addSectionHeader
*/
public function addSectionHeader( $header ) {
return $this;
}
/**
- * @see Content::preloadTransform
- *
* @since 1.21
+ *
+ * @return Content $this
+ *
+ * @see Content::preloadTransform
*/
public function preloadTransform( Title $title, ParserOptions $popts ) {
return $this;
}
/**
- * @see Content::prepareSave
- *
* @since 1.21
+ *
+ * @return Status
+ *
+ * @see Content::prepareSave
*/
public function prepareSave( WikiPage $page, $flags, $baseRevId, User $user ) {
if ( $this->isValid() ) {
}
/**
- * @see Content::getDeletionUpdates
- *
* @since 1.21
*
- * @param $page WikiPage the deleted page
- * @param $parserOutput null|ParserOutput optional parser output object
- * for efficient access to meta-information about the content object.
- * Provide if you have one handy.
+ * @param WikiPage $page
+ * @param ParserOutput $parserOutput
*
- * @return array A list of DataUpdate instances that will clean up the
- * database after deletion.
+ * @return LinksDeletionUpdate[]
+ *
+ * @see Content::getDeletionUpdates
*/
- public function getDeletionUpdates( WikiPage $page,
- ParserOutput $parserOutput = null
- ) {
+ public function getDeletionUpdates( WikiPage $page, ParserOutput $parserOutput = null ) {
return array(
new LinksDeletionUpdate( $page ),
);
* This default implementation always returns false. Subclasses may override
* this to supply matching logic.
*
- * @see Content::matchMagicWord
- *
* @since 1.21
*
* @param MagicWord $word
*
- * @return bool
+ * @return bool Always false.
+ *
+ * @see Content::matchMagicWord
*/
public function matchMagicWord( MagicWord $word ) {
return false;
}
/**
- * @see Content::convert()
- *
* This base implementation calls the hook ConvertContent to enable custom conversions.
* Subclasses may override this to implement conversion for "their" content model.
*
- * @param string $toModel the desired content model, use the CONTENT_MODEL_XXX flags.
- * @param string $lossy flag, set to "lossy" to allow lossy conversion. If lossy conversion is
- * not allowed, full round-trip conversion is expected to work without losing information.
+ * @param string $toModel
+ * @param string $lossy
+ *
+ * @return Content|bool
*
- * @return Content|bool A content object with the content model $toModel, or false if
- * that conversion is not supported.
+ * @see Content::convert()
*/
public function convert( $toModel, $lossy = '' ) {
if ( $this->getModel() === $toModel ) {
* @ingroup Content
*/
interface Content {
+
/**
* @since 1.21
*
*
* @since 1.21
*
- * @param int $maxLength Maximum length of the summary text
- * @return string The summary text
+ * @param int $maxLength Maximum length of the summary text.
+ *
+ * @return string The summary text.
*/
public function getTextForSummary( $maxLength = 250 );
*
* @since 1.21
*
- * @return Array of supported serialization formats
+ * @return string[] List of supported serialization formats
*/
public function getSupportedFormats();
*
* @since 1.21
*
- * @param string $format The format to check
+ * @param string $format The serialization format to check.
+ *
* @return bool Whether the format is supported
*/
public function isSupportedFormat( $format );
*
* @since 1.21
*
- * @param $format null|string The desired serialization format (or null for
- * the default format).
- * @return string Serialized form of this Content object
+ * @param string $format The desired serialization format, or null for the default format.
+ *
+ * @return string Serialized form of this Content object.
*/
public function serialize( $format = null );
*
* @since 1.21
*
- * @return boolean
+ * @return bool
*/
public function isValid();
*
* @since 1.21
*
- * @param $that Content The Content object to compare to
+ * @param Content $that The Content object to compare to.
+ *
* @return bool True if this Content object is equal to $that, false otherwise.
*/
public function equals( Content $that = null );
* @param bool $hasLinks If it is known whether this content contains
* links, provide this information here, to avoid redundant parsing to
* find out.
- * @return boolean
+ *
+ * @return bool
*/
public function isCountable( $hasLinks = null );
* generated parser output, implementations of this method
* may call ParserOutput::recordOption() on the output object.
*
- * @param $title Title The page title to use as a context for rendering
- * @param $revId null|int The revision being rendered (optional)
- * @param $options null|ParserOptions Any parser options
- * @param $generateHtml Boolean Whether to generate HTML (default: true). If false,
+ * @param Title $title The page title to use as a context for rendering.
+ * @param int $revId Optional revision ID being rendered.
+ * @param ParserOptions $options Any parser options.
+ * @param bool $generateHtml Whether to generate HTML (default: true). If false,
* the result of calling getText() on the ParserOutput object returned by
* this method is undefined.
*
*
* @return ParserOutput
*/
- public function getParserOutput( Title $title,
- $revId = null,
+ public function getParserOutput( Title $title, $revId = null,
ParserOptions $options = null, $generateHtml = true );
// TODO: make RenderOutput and RenderOptions base classes
* Subclasses may implement this to determine the necessary updates more
* efficiently, or make use of information about the old content.
*
- * @param $title Title The context for determining the necessary updates
- * @param $old Content|null An optional Content object representing the
+ * @param Title $title The context for determining the necessary updates
+ * @param Content $old An optional Content object representing the
* previous content, i.e. the content being replaced by this Content
* object.
- * @param $recursive boolean Whether to include recursive updates (default:
+ * @param bool $recursive Whether to include recursive updates (default:
* false).
- * @param $parserOutput ParserOutput|null Optional ParserOutput object.
+ * @param ParserOutput $parserOutput Optional ParserOutput object.
* Provide if you have one handy, to avoid re-parsing of the content.
*
- * @return Array. A list of DataUpdate objects for putting information
+ * @return DataUpdate[] A list of DataUpdate objects for putting information
* about this content object somewhere.
*
* @since 1.21
*/
- public function getSecondaryDataUpdates( Title $title,
- Content $old = null,
- $recursive = true, ParserOutput $parserOutput = null
- );
+ public function getSecondaryDataUpdates( Title $title, Content $old = null,
+ $recursive = true, ParserOutput $parserOutput = null );
/**
* Construct the redirect destination from this content and return an
*
* @since 1.21
*
- * @return Array of Titles, with the destination last
+ * @return Title[]|null List of Titles, with the destination last.
*/
public function getRedirectChain();
*
* @since 1.21
*
- * @return Title: The corresponding Title
+ * @return Title|null The corresponding Title.
*/
public function getRedirectTarget();
*
* @since 1.21
*
- * @return Title
+ * @return Title|null
*/
public function getUltimateRedirectTarget();
*
* @since 1.21
*
- * @param Title $target the new redirect target
+ * @param Title $target The new redirect target
*
- * @return Content a new Content object with the updated redirect (or $this
+ * @return Content A new Content object with the updated redirect (or $this
* if this Content object isn't a redirect)
*/
public function updateRedirect( Title $target );
* The ID "0" retrieves the section before the first heading, "1" the
* text between the first heading (included) and the second heading
* (excluded), etc.
- * @return Content|Boolean|null The section, or false if no such section
+ *
+ * @return Content|bool|null The section, or false if no such section
* exist, or null if sections are not supported.
*/
public function getSection( $sectionId );
*
* @since 1.21
*
- * @param $section null/false or a section number (0, 1, 2, T1, T2...), or "new"
- * @param $with Content: new content of the section
- * @param string $sectionTitle new section's subject, only if $section is 'new'
- * @return string Complete article text, or null if error
+ * @param mixed $section Null/false or a section number (0, 1, 2, T1, T2...), or "new"
+ * @param Content $with New content of the section
+ * @param string $sectionTitle New section's subject, only if $section is 'new'
+ *
+ * @return string|null Complete article text, or null if error
*/
public function replaceSection( $section, Content $with, $sectionTitle = '' );
*
* @since 1.21
*
- * @param $title Title
- * @param $user User
- * @param $parserOptions null|ParserOptions
+ * @param Title $title
+ * @param User $user
+ * @param ParserOptions $parserOptions
+ *
* @return Content
*/
public function preSaveTransform( Title $title, User $user, ParserOptions $parserOptions );
*
* @since 1.21
*
- * @param $header string
+ * @param string $header
+ *
* @return Content
*/
public function addSectionHeader( $header );
*
* @since 1.21
*
- * @param $title Title
- * @param $parserOptions null|ParserOptions
+ * @param Title $title
+ * @param ParserOptions $parserOptions
+ *
* @return Content
*/
public function preloadTransform( Title $title, ParserOptions $parserOptions );
* @since 1.21
*
* @param WikiPage $page The page to be saved.
- * @param int $flags bitfield for use with EDIT_XXX constants, see WikiPage::doEditContent()
- * @param int $baseRevId the ID of the current revision
+ * @param int $flags Bitfield for use with EDIT_XXX constants, see WikiPage::doEditContent()
+ * @param int $baseRevId The ID of the current revision
* @param User $user
*
* @return Status A status object indicating whether the content was
* successfully prepared for saving. If the returned status indicates
* an error, a rollback will be performed and the transaction aborted.
*
- * @see see WikiPage::doEditContent()
+ * @see WikiPage::doEditContent()
*/
public function prepareSave( WikiPage $page, $flags, $baseRevId, User $user );
*
* @since 1.21
*
- * @param $page WikiPage the deleted page
- * @param $parserOutput null|ParserOutput optional parser output object
+ * @param WikiPage $page The deleted page
+ * @param ParserOutput $parserOutput Optional parser output object
* for efficient access to meta-information about the content object.
* Provide if you have one handy.
*
- * @return array A list of DataUpdate instances that will clean up the
+ * @return DataUpdate[] A list of DataUpdate instances that will clean up the
* database after deletion.
*/
public function getDeletionUpdates( WikiPage $page,
*
* @since 1.21
*
- * @param MagicWord $word the magic word to match
+ * @param MagicWord $word The magic word to match
*
- * @return bool whether this Content object matches the given magic word.
+ * @return bool Whether this Content object matches the given magic word.
*/
public function matchMagicWord( MagicWord $word );
* Converts this content object into another content object with the given content model,
* if that is possible.
*
- * @param string $toModel the desired content model, use the CONTENT_MODEL_XXX flags.
- * @param string $lossy flag, set to "lossy" to allow lossy conversion. If lossy conversion is
- * not allowed, full round-trip conversion is expected to work without losing information.
+ * @param string $toModel The desired content model, use the CONTENT_MODEL_XXX flags.
+ * @param string $lossy Optional flag, set to "lossy" to allow lossy conversion. If lossy
+ * conversion is not allowed, full round-trip conversion is expected to work without losing
+ * information.
*
* @return Content|bool A content object with the content model $toModel, or false if
* that conversion is not supported.
// [11:59] <vvv> Hooks are ugly; make CodeHighlighter interface and a
// config to set the class which handles syntax highlighting
// [12:00] <vvv> And default it to a DummyHighlighter
+
}
*
* @since 1.21
*
- * @param $content Content|null
- * @return null|string the textual form of $content, if available
- * @throws MWException if $content is not an instance of TextContent and
- * $wgContentHandlerTextFallback was set to 'fail'.
+ * @param Content $content
+ *
+ * @throws MWException If the content is not an instance of TextContent and
+ * wgContentHandlerTextFallback was set to 'fail'.
+ * @return string|null Textual form of the content, if available.
*/
public static function getContentText( Content $content = null ) {
global $wgContentHandlerTextFallback;
*
* @since 1.21
*
- * @param string $text the textual representation, will be
+ * @param string $text The textual representation, will be
* unserialized to create the Content object
- * @param $title null|Title the title of the page this text belongs to.
+ * @param Title $title The title of the page this text belongs to.
* Required if $modelId is not provided.
- * @param $modelId null|string the model to deserialize to. If not provided,
+ * @param string $modelId The model to deserialize to. If not provided,
* $title->getContentModel() is used.
- * @param $format null|string the format to use for deserialization. If not
+ * @param string $format The format to use for deserialization. If not
* given, the model's default format is used.
*
- * @throws MWException
- * @return Content a Content object representing $text
- *
- * @throws MWException if $model or $format is not supported or if $text can
- * not be unserialized using $format.
+ * @throws MWException If model ID or format is not supported or if the text can not be
+ * unserialized using the format.
+ * @return Content A Content object representing the text.
*/
public static function makeContent( $text, Title $title = null,
- $modelId = null, $format = null
- ) {
+ $modelId = null, $format = null ) {
if ( is_null( $modelId ) ) {
if ( is_null( $title ) ) {
throw new MWException( "Must provide a Title object or a content model ID." );
*
* @since 1.21
*
- * @param $title Title
- * @return null|string default model name for the page given by $title
+ * @param Title $title
+ *
+ * @return string Default model name for the page given by $title
*/
public static function getDefaultModelFor( Title $title ) {
// NOTE: this method must not rely on $title->getContentModel() directly or indirectly,
*
* @since 1.21
*
- * @param $title Title
+ * @param Title $title
+ *
* @return ContentHandler
*/
public static function getForTitle( Title $title ) {
*
* @since 1.21
*
- * @param $content Content
+ * @param Content $content
+ *
* @return ContentHandler
*/
public static function getForContent( Content $content ) {
*
* @param string $modelId The ID of the content model for which to get a
* handler. Use CONTENT_MODEL_XXX constants.
- * @return ContentHandler The ContentHandler singleton for handling the
- * model given by $modelId
- * @throws MWException if no handler is known for $modelId.
+ *
+ * @throws MWException If no handler is known for the model ID.
+ * @return ContentHandler The ContentHandler singleton for handling the model given by the ID.
*/
public static function getForModelID( $modelId ) {
global $wgContentHandlers;
* @param string $name The content model ID, as given by a CONTENT_MODEL_XXX
* constant or returned by Revision::getContentModel().
*
+ * @throws MWException If the model ID isn't known.
* @return string The content model's localized name.
- * @throws MWException if the model id isn't known.
*/
public static function getLocalizedName( $name ) {
// Messages: content-model-wikitext, content-model-text,
// ------------------------------------------------------------------------
+ /**
+ * @var string
+ */
protected $mModelID;
+
+ /**
+ * @var string[]
+ */
protected $mSupportedFormats;
/**
* provided as literals by subclass's constructors.
*
* @param string $modelId (use CONTENT_MODEL_XXX constants).
- * @param array $formats List for supported serialization formats
+ * @param string[] $formats List for supported serialization formats
* (typically as MIME types)
*/
public function __construct( $modelId, $formats ) {
*
* @since 1.21
*
- * @param $content Content The Content object to serialize
- * @param $format null|String The desired serialization format
+ * @param Content $content The Content object to serialize
+ * @param string $format The desired serialization format
+ *
* @return string Serialized form of the content
*/
abstract public function serializeContent( Content $content, $format = null );
*
* @since 1.21
*
- * @param string $blob serialized form of the content
- * @param $format null|String the format used for serialization
- * @return Content the Content object created by deserializing $blob
+ * @param string $blob Serialized form of the content
+ * @param string $format The format used for serialization
+ *
+ * @return Content The Content object created by deserializing $blob
*/
abstract public function unserializeContent( $blob, $format = null );
*
* @since 1.21
*
- * @param Title $destination the page to redirect to.
- * @param string $text text to include in the redirect, if possible.
+ * @param Title $destination The page to redirect to.
+ * @param string $text Text to include in the redirect, if possible.
*
- * @return Content
+ * @return Content Always null.
*/
public function makeRedirectContent( Title $destination, $text = '' ) {
return null;
*
* @since 1.21
*
- * @return String The model ID
+ * @return string The model ID
*/
public function getModelID() {
return $this->mModelID;
}
/**
- * Throws an MWException if $model_id is not the ID of the content model
- * supported by this ContentHandler.
- *
* @since 1.21
*
* @param string $model_id The model to check
*
- * @throws MWException
+ * @throws MWException If the model ID is not the ID of the content model supported by this
+ * ContentHandler.
*/
protected function checkModelID( $model_id ) {
if ( $model_id !== $this->mModelID ) {
*
* @since 1.21
*
- * @return array of serialization formats as MIME type like strings
+ * @return string[] List of serialization formats as MIME type like strings
*/
public function getSupportedFormats() {
return $this->mSupportedFormats;
*
* @since 1.21
*
- * @return string the name of the default serialization format as a MIME type
+ * @return string The name of the default serialization format as a MIME type
*/
public function getDefaultFormat() {
return $this->mSupportedFormats[0];
*
* @since 1.21
*
- * @param string $format the serialization format to check
+ * @param string $format The serialization format to check
+ *
* @return bool
*/
public function isSupportedFormat( $format ) {
-
if ( !$format ) {
return true; // this means "use the default"
}
}
/**
- * Throws an MWException if isSupportedFormat( $format ) is not true.
- * Convenient for checking whether a format provided as a parameter is
- * actually supported.
+ * Convenient for checking whether a format provided as a parameter is actually supported.
*
- * @param string $format the serialization format to check
+ * @param string $format The serialization format to check
*
- * @throws MWException
+ * @throws MWException If the format is not supported by this content handler.
*/
protected function checkFormat( $format ) {
if ( !$this->isSupportedFormat( $format ) ) {
*
* @since 1.21
*
- * @return Array
+ * @return array Always an empty array.
*/
public function getActionOverrides() {
return array();
*
* @since 1.21
*
- * @param $context IContextSource context to use, anything else will be
- * ignored
- * @param $old Integer Old ID we want to show and diff with.
- * @param int|string $new String either 'prev' or 'next'.
- * @param $rcid Integer ??? FIXME (default 0)
- * @param $refreshCache boolean If set, refreshes the diff cache
- * @param $unhide boolean If set, allow viewing deleted revs
+ * @param IContextSource $context Context to use, anything else will be ignored.
+ * @param int $old Revision ID we want to show and diff with.
+ * @param int|string $new Either a revision ID or one of the strings 'cur', 'prev' or 'next'.
+ * @param int $rcid FIXME: Deprecated, no longer used. Defaults to 0.
+ * @param bool $refreshCache If set, refreshes the diff cache. Defaults to false.
+ * @param bool $unhide If set, allow viewing deleted revs. Defaults to false.
*
* @return DifferenceEngine
*/
- public function createDifferenceEngine( IContextSource $context,
- $old = 0, $new = 0,
- $rcid = 0, # FIXME: use everywhere!
- $refreshCache = false, $unhide = false
- ) {
+ public function createDifferenceEngine( IContextSource $context, $old = 0, $new = 0,
+ $rcid = 0, //FIXME: Deprecated, no longer used
+ $refreshCache = false, $unhide = false ) {
$diffEngineClass = $this->getDiffEngineClass();
return new $diffEngineClass( $context, $old, $new, $rcid, $refreshCache, $unhide );
*
* @since 1.21
*
- * @param Title $title the page to determine the language for.
- * @param Content|null $content the page's content, if you have it handy, to avoid reloading it.
+ * @param Title $title The page to determine the language for.
+ * @param Content $content The page's content, if you have it handy, to avoid reloading it.
*
- * @return Language the page's language
+ * @return Language The page's language
*/
public function getPageLanguage( Title $title, Content $content = null ) {
global $wgContLang, $wgLang;
*
* @since 1.21
*
- * @param Title $title the page to determine the language for.
- * @param Content|null $content the page's content, if you have it handy, to avoid reloading it.
+ * @param Title $title The page to determine the language for.
+ * @param Content $content The page's content, if you have it handy, to avoid reloading it.
*
- * @return Language the page's language for viewing
+ * @return Language The page's language for viewing
*/
public function getPageViewLanguage( Title $title, Content $content = null ) {
$pageLang = $this->getPageLanguage( $title, $content );
* @note: this calls the ContentHandlerCanBeUsedOn hook which may be used to override which
* content model can be used where.
*
- * @param Title $title the page's title.
+ * @param Title $title The page's title.
*
- * @return bool true if content of this kind can be used on the given page, false otherwise.
+ * @return bool True if content of this kind can be used on the given page, false otherwise.
*/
public function canBeUsedOn( Title $title ) {
$ok = true;
}
/**
- * Attempts to merge differences between three versions.
- * Returns a new Content object for a clean merge and false for failure or
- * a conflict.
+ * Attempts to merge differences between three versions. Returns a new
+ * Content object for a clean merge and false for failure or a conflict.
*
* This default implementation always returns false.
*
* @since 1.21
*
- * @param $oldContent Content|string String
- * @param $myContent Content|string String
- * @param $yourContent Content|string String
+ * @param Content|string $oldContent The page's previous content.
+ * @param Content|string $myContent One of the page's conflicting contents.
+ * @param Content|string $yourContent One of the page's conflicting contents.
*
- * @return Content|Bool
+ * @return Content|bool Always false.
*/
public function merge3( Content $oldContent, Content $myContent, Content $yourContent ) {
return false;
*
* @since 1.21
*
- * @param $oldContent Content|null: the previous text of the page.
- * @param $newContent Content|null: The submitted text of the page.
+ * @param Content $oldContent The previous text of the page.
+ * @param Content $newContent The submitted text of the page.
* @param int $flags Bit mask: a bit mask of flags submitted for the edit.
*
* @return string An appropriate auto-summary, or an empty string.
*/
- public function getAutosummary( Content $oldContent = null, Content $newContent = null, $flags ) {
+ public function getAutosummary( Content $oldContent = null, Content $newContent = null,
+ $flags ) {
// Decide what kind of auto-summary is needed.
// Redirect auto-summaries
*
* @since 1.21
*
- * @param $title Title: the page's title
- * @param &$hasHistory Boolean: whether the page has a history
+ * @param Title $title The page's title
+ * @param bool &$hasHistory Whether the page has a history
+ *
* @return mixed String containing deletion reason or empty string, or
* boolean false if no revision occurred
*
*
* @since 1.21
*
- * @param $current Revision The current text
- * @param $undo Revision The revision to undo
- * @param $undoafter Revision Must be an earlier revision than $undo
+ * @param Revision $current The current text
+ * @param Revision $undo The revision to undo
+ * @param Revision $undoafter Must be an earlier revision than $undo
*
* @return mixed String on success, false on failure
*/
*
* @since 1.21
*
- * @return bool
+ * @return bool Always false.
*/
public function isParserCacheSupported() {
return false;
* Content models that return true here should also implement
* Content::getSection, Content::replaceSection, etc. to handle sections..
*
- * @return boolean whether sections are supported.
+ * @return bool Always false.
*/
public function supportsSections() {
return false;
* Content models that return true here should also implement
* ContentHandler::makeRedirectContent to return a Content object.
*
- * @return boolean whether redirects are supported.
+ * @return bool Always false.
*/
public function supportsRedirects() {
return false;
* hook function, a new Content object is constructed from the new
* text.
*
- * @param string $event event name
- * @param array $args parameters passed to hook functions
- * @param bool $warn whether to log a warning.
+ * @param string $event Event name
+ * @param array $args Parameters passed to hook functions
+ * @param bool $warn Whether to log a warning.
* Default to self::$enableDeprecationWarnings.
* May be set to false for testing.
*
- * @return Boolean True if no handler aborted the hook
+ * @return bool True if no handler aborted the hook
*
* @see ContentHandler::$enableDeprecationWarnings
*/
* @ingroup Content
*/
class CssContent extends TextContent {
+
+ /**
+ * @param string $text CSS code.
+ */
public function __construct( $text ) {
parent::__construct( $text, CONTENT_MODEL_CSS );
}
* Returns a Content object with pre-save transformations applied using
* Parser::preSaveTransform().
*
- * @param $title Title
- * @param $user User
- * @param $popts ParserOptions
- * @return Content
+ * @param Title $title
+ * @param User $user
+ * @param ParserOptions $popts
+ *
+ * @return CssContent
+ *
+ * @see TextContent::preSaveTransform
*/
public function preSaveTransform( Title $title, User $user, ParserOptions $popts ) {
global $wgParser;
return new CssContent( $pst );
}
+ /**
+ * @return string CSS wrapped in a <pre> tag.
+ */
protected function getHtml() {
$html = "";
$html .= "<pre class=\"mw-code mw-css\" dir=\"ltr\">\n";
return $html;
}
+
}
* @ingroup Content
*/
class CssContentHandler extends TextContentHandler {
+
+ /**
+ * @param string $modelId
+ */
public function __construct( $modelId = CONTENT_MODEL_CSS ) {
parent::__construct( $modelId, array( CONTENT_FORMAT_CSS ) );
}
+ /**
+ * @param string $text
+ * @param string $format
+ *
+ * @return CssContent
+ *
+ * @see ContentHandler::unserializeContent()
+ */
public function unserializeContent( $text, $format = null ) {
$this->checkFormat( $format );
return new CssContent( $text );
}
+ /**
+ * @return CssContent A new CssContent object with empty text.
+ *
+ * @see ContentHandler::makeEmptyContent()
+ */
public function makeEmptyContent() {
return new CssContent( '' );
}
*
* @param Title $title
* @param Content $content
+ *
* @return Language wfGetLangObj( 'en' )
*
* @see ContentHandler::getPageLanguage()
*
* @param Title $title
* @param Content $content
+ *
* @return Language wfGetLangObj( 'en' )
*
* @see ContentHandler::getPageViewLanguage()
public function getPageViewLanguage( Title $title, Content $content = null ) {
return wfGetLangObj( 'en' );
}
+
}
* @ingroup Content
*/
class JavaScriptContent extends TextContent {
+
+ /**
+ * @param string $text JavaScript code.
+ */
public function __construct( $text ) {
parent::__construct( $text, CONTENT_MODEL_JAVASCRIPT );
}
* @param Title $title
* @param User $user
* @param ParserOptions $popts
- * @return Content
+ *
+ * @return JavaScriptContent
*/
public function preSaveTransform( Title $title, User $user, ParserOptions $popts ) {
global $wgParser;
return new JavaScriptContent( $pst );
}
+ /**
+ * @return string JavaScript wrapped in a <pre> tag.
+ */
protected function getHtml() {
$html = "";
$html .= "<pre class=\"mw-code mw-js\" dir=\"ltr\">\n";
return $html;
}
+
}
* @todo make ScriptContentHandler base class, do highlighting stuff there?
*/
class JavaScriptContentHandler extends TextContentHandler {
+
+ /**
+ * @param string $modelId
+ */
public function __construct( $modelId = CONTENT_MODEL_JAVASCRIPT ) {
parent::__construct( $modelId, array( CONTENT_FORMAT_JAVASCRIPT ) );
}
+ /**
+ * @param string $text
+ * @param string $format
+ *
+ * @return JavaScriptContent
+ *
+ * @see ContentHandler::unserializeContent()
+ */
public function unserializeContent( $text, $format = null ) {
$this->checkFormat( $format );
return new JavaScriptContent( $text );
}
+ /**
+ * @return JavaScriptContent A new JavaScriptContent object with empty text.
+ *
+ * @see ContentHandler::makeEmptyContent()
+ */
public function makeEmptyContent() {
return new JavaScriptContent( '' );
}
*
* @param Title $title
* @param Content $content
+ *
* @return Language wfGetLangObj( 'en' )
*
* @see ContentHandler::getPageLanguage()
*
* @param Title $title
* @param Content $content
+ *
* @return Language wfGetLangObj( 'en' )
*
* @see ContentHandler::getPageViewLanguage()
public function getPageViewLanguage( Title $title, Content $content = null ) {
return wfGetLangObj( 'en' );
}
+
}
* @ingroup Content
*/
class MessageContent extends AbstractContent {
+
/**
* @var Message
*/
protected $mMessage;
/**
- * @param Message|String $msg A Message object, or a message key
- * @param array|null $params An optional array of message parameters
+ * @param Message|string $msg A Message object, or a message key.
+ * @param string[] $params An optional array of message parameters.
*/
public function __construct( $msg, $params = null ) {
# XXX: messages may be wikitext, html or plain text! and maybe even something else entirely.
}
/**
- * Returns the message as rendered HTML
+ * Fully parse the text from wikitext to HTML.
*
- * @return string The message text, parsed into html
+ * @return string Parsed HTML.
*/
public function getHtml() {
return $this->mMessage->parse();
}
/**
- * Returns the message as rendered HTML
+ * Returns the message text. {{-transformation is done.
*
- * @return string The message text, parsed into html
+ * @return string Unescaped message text.
*/
public function getWikitext() {
return $this->mMessage->text();
}
/**
+ * @return string
+ *
* @see Content::getTextForSearchIndex
*/
public function getTextForSearchIndex() {
}
/**
+ * @return string
+ *
* @see Content::getWikitextForTransclusion
*/
public function getWikitextForTransclusion() {
}
/**
+ * @param int $maxLength Maximum length of the summary text, defaults to 250.
+ *
+ * @return string The summary text.
+ *
* @see Content::getTextForSummary
*/
public function getTextForSummary( $maxlength = 250 ) {
}
/**
- * @see Content::getSize
- *
* @return int
+ *
+ * @see Content::getSize
*/
public function getSize() {
return strlen( $this->mMessage->plain() );
}
/**
- * @see Content::copy
- *
* @return Content. A copy of this object
+ *
+ * @see Content::copy
*/
public function copy() {
// MessageContent is immutable (because getNativeData() returns a clone of the Message object)
}
/**
- * @see Content::isCountable
- *
* @param bool $hasLinks
- * @return bool false
+ *
+ * @return bool Always false.
+ *
+ * @see Content::isCountable
*/
public function isCountable( $hasLinks = null ) {
return false;
}
/**
- * @see Content::getParserOutput
+ * @param Title $title Unused.
+ * @param int $revId Unused.
+ * @param ParserOptions $options Unused.
+ * @param bool $generateHtml Whether to generate HTML (default: true).
*
- * @param Title $title
- * @param int $revId Optional revision ID
- * @param ParserOptions $options
- * @param bool $generateHtml Wether to generate HTML
* @return ParserOutput
+ *
+ * @see Content::getParserOutput
*/
- public function getParserOutput(
- Title $title, $revId = null,
- ParserOptions $options = null, $generateHtml = true
- ) {
-
+ public function getParserOutput( Title $title, $revId = null,
+ ParserOptions $options = null, $generateHtml = true ) {
if ( $generateHtml ) {
$html = $this->getHtml();
} else {
return $po;
}
+
}
* @ingroup Content
*/
class TextContent extends AbstractContent {
+
+ /**
+ * @param string $text
+ * @param string $model_id
+ */
public function __construct( $text, $model_id = CONTENT_MODEL_TEXT ) {
parent::__construct( $model_id );
$this->mText = $text;
}
+ /**
+ * @note Mutable subclasses MUST override this to return a copy!
+ *
+ * @return Content $this
+ */
public function copy() {
return $this; # NOTE: this is ok since TextContent are immutable.
}
* Returns true if this content is not a redirect, and $wgArticleCountMethod
* is "any".
*
- * @param bool $hasLinks if it is known whether this content contains links,
+ * @param bool $hasLinks If it is known whether this content contains links,
* provide this information here, to avoid redundant parsing to find out.
*
- * @return bool True if the content is countable
+ * @return bool
*/
public function isCountable( $hasLinks = null ) {
global $wgArticleCountMethod;
/**
* Returns the text represented by this Content object, as a string.
*
- * @return string: the raw text
+ * @return string The raw text.
*/
public function getNativeData() {
$text = $this->mText;
/**
* Returns the text represented by this Content object, as a string.
*
- * @return string: the raw text
+ * @return string The raw text.
*/
public function getTextForSearchIndex() {
return $this->getNativeData();
*
* @note: this allows any text-based content to be transcluded as if it was wikitext.
*
- * @return string|false: the raw text, or null if the conversion failed
+ * @return string|false The raw text, or false if the conversion failed.
*/
public function getWikitextForTransclusion() {
$wikitext = $this->convert( CONTENT_MODEL_WIKITEXT, 'lossy' );
* Returns a Content object with pre-save transformations applied.
* This implementation just trims trailing whitespace.
*
- * @param $title Title
- * @param $user User
- * @param $popts ParserOptions
+ * @param Title $title
+ * @param User $user
+ * @param ParserOptions $popts
+ *
* @return Content
*/
public function preSaveTransform( Title $title, User $user, ParserOptions $popts ) {
*
* @since 1.21
*
- * @param $that Content: The other content object to compare this content
+ * @param Content $that The other content object to compare this content
* object to.
- * @param $lang Language: The language object to use for text segmentation.
+ * @param Language $lang The language object to use for text segmentation.
* If not given, $wgContentLang is used.
*
* @return Diff A diff representing the changes that would have to be
* Returns a generic ParserOutput object, wrapping the HTML returned by
* getHtml().
*
- * @param $title Title Context title for parsing
- * @param int|null $revId Revision ID (for {{REVISIONID}})
- * @param $options ParserOptions|null Parser options
+ * @param Title $title Context title for parsing
+ * @param int $revId Revision ID (for {{REVISIONID}})
+ * @param ParserOptions $options Parser options
* @param bool $generateHtml Whether or not to generate HTML
*
- * @return ParserOutput representing the HTML form of the text
+ * @return ParserOutput Representing the HTML form of the text.
*/
- public function getParserOutput( Title $title,
- $revId = null,
- ParserOptions $options = null, $generateHtml = true
- ) {
+ public function getParserOutput( Title $title, $revId = null,
+ ParserOptions $options = null, $generateHtml = true ) {
global $wgParser, $wgTextModelsToParse;
if ( !$options ) {
* Generates a syntax-highlighted version of the content, as HTML.
* Used by the default implementation of getHtml().
*
- * @return string an HTML representation of the content's markup
+ * @return string A HTML representation of the content's markup
*/
protected function getHighlightHtml() {
# TODO: make Highlighter interface, use highlighter here, if available
}
/**
- * @see Content::convert()
- *
* This implementation provides lossless conversion between content models based
* on TextContent.
*
- * @param string $toModel the desired content model, use the CONTENT_MODEL_XXX flags.
- * @param string $lossy flag, set to "lossy" to allow lossy conversion. If lossy conversion is
- * not allowed, full round-trip conversion is expected to work without losing information.
+ * @param string $toModel
+ * @param string $lossy
*
- * @return Content|bool A content object with the content model $toModel, or false if
- * that conversion is not supported.
+ * @return Content|bool
+ *
+ * @see Content::convert()
*/
public function convert( $toModel, $lossy = '' ) {
$converted = parent::convert( $toModel, $lossy );
return $converted;
}
+
}
* @ingroup Content
*/
class TextContentHandler extends ContentHandler {
+
// @codingStandardsIgnoreStart bug 57585
public function __construct( $modelId = CONTENT_MODEL_TEXT,
- $formats = array( CONTENT_FORMAT_TEXT )
- ) {
+ $formats = array( CONTENT_FORMAT_TEXT ) ) {
parent::__construct( $modelId, $formats );
}
// @codingStandardsIgnoreEnd
/**
* Returns the content's text as-is.
*
- * @param $content Content
- * @param $format string|null
+ * @param Content $content
+ * @param string $format The serialization format to check
+ *
* @return mixed
*/
public function serializeContent( Content $content, $format = null ) {
*
* This text-based implementation uses wfMerge().
*
- * @param $oldContent Content|string String
- * @param $myContent Content|string String
- * @param $yourContent Content|string String
+ * @param Content|string $oldContent The page's previous content.
+ * @param Content|string $myContent One of the page's conflicting contents.
+ * @param Content|string $yourContent One of the page's conflicting contents.
*
- * @return Content|Bool
+ * @return Content|bool
*/
public function merge3( Content $oldContent, Content $myContent, Content $yourContent ) {
$this->checkModelID( $oldContent->getModel() );
*
* @since 1.21
*
- * @param $text string serialized form of the content
- * @param $format null|String the format used for serialization
+ * @param string $text Serialized form of the content
+ * @param string $format The format used for serialization
*
- * @return Content the TextContent object wrapping $text
+ * @return Content The TextContent object wrapping $text
*/
public function unserializeContent( $text, $format = null ) {
$this->checkFormat( $format );
*
* @since 1.21
*
- * @return Content
+ * @return Content A new TextContent object with empty text.
*/
public function makeEmptyContent() {
return new TextContent( '' );
}
+
}
* @ingroup Content
*/
class WikitextContent extends TextContent {
+
public function __construct( $text ) {
parent::__construct( $text, CONTENT_MODEL_WIKITEXT );
}
/**
+ * @param string $section
+ *
+ * @return Content|bool|null
+ *
* @see Content::getSection()
*/
public function getSection( $section ) {
}
/**
+ * @param string $section
+ * @param Content $with
+ * @param string $sectionTitle
+ *
+ * @throws MWException
+ * @return Content
+ *
* @see Content::replaceSection()
*/
public function replaceSection( $section, Content $with, $sectionTitle = '' ) {
* Returns a new WikitextContent object with the given section heading
* prepended.
*
- * @param $header string
+ * @param string $header
+ *
* @return Content
*/
public function addSectionHeader( $header ) {
* Returns a Content object with pre-save transformations applied using
* Parser::preSaveTransform().
*
- * @param $title Title
- * @param $user User
- * @param $popts ParserOptions
+ * @param Title $title
+ * @param User $user
+ * @param ParserOptions $popts
+ *
* @return Content
*/
public function preSaveTransform( Title $title, User $user, ParserOptions $popts ) {
* Returns a Content object with preload transformations applied (or this
* object if no transformations apply).
*
- * @param $title Title
- * @param $popts ParserOptions
+ * @param Title $title
+ * @param ParserOptions $popts
+ *
* @return Content
*/
public function preloadTransform( Title $title, ParserOptions $popts ) {
* @note: migrated here from Title::newFromRedirectInternal()
*
* @since 1.23
- * @return array 2 elements: Title|null and string
+ *
+ * @return array List of two elements: Title|null and string.
*/
protected function getRedirectTargetAndText() {
global $wgMaxRedirects;
/**
* Implement redirect extraction for wikitext.
*
- * @return null|Title
+ * @return Title|null
*
* @see Content::getRedirectTarget
- * @see AbstractContent::getRedirectTarget
*/
public function getRedirectTarget() {
list( $title, ) = $this->getRedirectTargetAndText();
}
/**
- * @see Content::updateRedirect()
- *
* This implementation replaces the first link on the page with the given new target
* if this Content object is a redirect. Otherwise, this method returns $this.
*
*
* @param Title $target
*
- * @return Content a new Content object with the updated redirect (or $this
- * if this Content object isn't a redirect)
+ * @return Content
+ *
+ * @see Content::updateRedirect()
*/
public function updateRedirect( Title $target ) {
if ( !$this->isRedirect() ) {
* Returns true if this content is not a redirect, and this content's text
* is countable according to the criteria defined by $wgArticleCountMethod.
*
- * @param bool $hasLinks if it is known whether this content contains
+ * @param bool $hasLinks If it is known whether this content contains
* links, provide this information here, to avoid redundant parsing to
* find out (default: null).
- * @param $title Title: (default: null)
+ * @param Title $title Optional title, defaults to the title from the current main request.
*
* @internal param \IContextSource $context context for parsing if necessary
*
- * @return bool True if the content is countable
+ * @return bool
*/
public function isCountable( $hasLinks = null, Title $title = null ) {
global $wgArticleCountMethod;
return false;
}
+ /**
+ * @param int $maxlength
+ * @return string
+ */
public function getTextForSummary( $maxlength = 250 ) {
$truncatedtext = parent::getTextForSummary( $maxlength );
* Returns a ParserOutput object resulting from parsing the content's text
* using $wgParser.
*
- * @since 1.21
+ * @since 1.21
*
- * @param $title Title
- * @param int $revId Revision to pass to the parser (default: null)
- * @param $options ParserOptions (default: null)
+ * @param Title $title * @param int $revId Revision to pass to the parser (default: null)
+ * @param ParserOptions $options (default: null)
* @param bool $generateHtml (default: false)
- *
* @internal param \IContextSource|null $context
- * @return ParserOutput representing the HTML form of the text
+ *
+ * @return ParserOutput Representing the HTML form of the text
*/
- public function getParserOutput( Title $title,
- $revId = null,
- ParserOptions $options = null, $generateHtml = true
- ) {
+ public function getParserOutput( Title $title, $revId = null,
+ ParserOptions $options = null, $generateHtml = true ) {
global $wgParser;
if ( !$options ) {
return $po;
}
+ /**
+ * @throws MWException
+ */
protected function getHtml() {
throw new MWException(
"getHtml() not implemented for wikitext. "
}
/**
- * @see Content::matchMagicWord()
- *
* This implementation calls $word->match() on the this TextContent object's text.
*
* @param MagicWord $word
*
- * @return bool whether this Content object matches the given magic word.
+ * @return bool
+ *
+ * @see Content::matchMagicWord()
*/
public function matchMagicWord( MagicWord $word ) {
return $word->match( $this->getNativeData() );
}
+
}
* @ingroup Content
*/
class WikitextContentHandler extends TextContentHandler {
+
public function __construct( $modelId = CONTENT_MODEL_WIKITEXT ) {
parent::__construct( $modelId, array( CONTENT_FORMAT_WIKITEXT ) );
}
}
/**
- * @see ContentHandler::makeEmptyContent
+ * @return Content A new WikitextContent object with empty text.
*
- * @return Content
+ * @see ContentHandler::makeEmptyContent
*/
public function makeEmptyContent() {
return new WikitextContent( '' );
/**
* Returns a WikitextContent object representing a redirect to the given destination page.
*
- * @see ContentHandler::makeRedirectContent
- *
- * @param Title $destination the page to redirect to.
- * @param string $text text to include in the redirect, if possible.
+ * @param Title $destination The page to redirect to.
+ * @param string $text Text to include in the redirect, if possible.
*
* @return Content
+ *
+ * @see ContentHandler::makeRedirectContent
*/
public function makeRedirectContent( Title $destination, $text = '' ) {
$optionalColon = '';
/**
* Returns true because wikitext supports redirects.
*
- * @see ContentHandler::supportsRedirects
+ * @return bool Always true.
*
- * @return boolean whether redirects are supported.
+ * @see ContentHandler::supportsRedirects
*/
public function supportsRedirects() {
return true;
/**
* Returns true because wikitext supports sections.
*
- * @return boolean whether sections are supported.
+ * @return bool Always true.
+ *
+ * @see ContentHandler::supportsSections
*/
public function supportsSections() {
return true;
* ParserCache mechanism.
*
* @since 1.21
- * @return bool
+ *
+ * @return bool Always true.
+ *
+ * @see ContentHandler::isParserCacheSupported
*/
public function isParserCacheSupported() {
return true;
}
+
}
/**
* @param Diff $diff A Diff object.
- * @return array
+ *
+ * @return array[] List of associative arrays, each describing a difference.
*/
public function format( $diff ) {
$oldline = 1;
return $retval;
}
+
}
*/
abstract class DiffOp {
+ /**
+ * @var string
+ */
public $type;
+
+ /**
+ * @var string[]
+ */
public $orig;
+
+ /**
+ * @var string[]
+ */
public $closing;
+ /**
+ * @return string
+ */
public function getType() {
return $this->type;
}
+ /**
+ * @return string[]
+ */
public function getOrig() {
return $this->orig;
}
+ /**
+ * @param int $i
+ * @return string|null
+ */
public function getClosing( $i = null ) {
if( $i === null ) {
return $this->closing;
protected $lcs = 0;
/**
- * @param $from_lines
- * @param $to_lines
- * @return array
+ * @param string[] $from_lines
+ * @param string[] $to_lines
+ *
+ * @return DiffOp[]
*/
public function diff( $from_lines, $to_lines ) {
wfProfileIn( __METHOD__ );
}
/**
- * @param $from_lines
- * @param $to_lines
+ * @param string[] $from_lines
+ * @param string[] $to_lines
*/
private function diffLocal( $from_lines, $to_lines ) {
global $wgExternalDiffEngine;
/**
* Returns the whole line if it's small enough, or the MD5 hash otherwise
- * @param $line string
+ *
+ * @param string $line
+ *
* @return string
*/
private function lineHash( $line ) {
* of the two files do not match, and likewise that the last lines do not
* match. The caller must trim matching lines from the beginning and end
* of the portions it is going to specify.
- * @param $xoff
- * @param $xlim
- * @param $yoff
- * @param $ylim
- * @param $nchunks
- * @return array
+ *
+ * @param int $xoff
+ * @param int $xlim
+ * @param int $yoff
+ * @param int $ylim
+ * @param int $nchunks
+ *
+ * @return array List of two elements, integer and array[].
*/
private function diag( $xoff, $xlim, $yoff, $ylim, $nchunks ) {
$flip = false;
}
$x1 = $xoff + (int)( ( $numer + ( $xlim - $xoff ) * $chunk ) / $nchunks );
- for ( ; $x < $x1; $x++ ) {
+ for (; $x < $x1; $x++ ) {
$line = $flip ? $this->yv[$x] : $this->xv[$x];
if ( empty( $ymatches[$line] ) ) {
continue;
}
/**
- * @param $ypos
+ * @param int $ypos
+ *
* @return int
*/
private function lcsPos( $ypos ) {
*
* Note that XLIM, YLIM are exclusive bounds.
* All line numbers are origin-0 and discarded lines are not counted.
- * @param $xoff
- * @param $xlim
- * @param $yoff
- * @param $ylim
+ *
+ * @param int $xoff
+ * @param int $xlim
+ * @param int $yoff
+ * @param int $ylim
*/
private function compareSeq( $xoff, $xlim, $yoff, $ylim ) {
// Slide down the bottom initial diagonal.
* Constructor.
* Computes diff between sequences of strings.
*
- * @param $from_lines array An array of strings.
+ * @param string[] $from_lines An array of strings.
* Typically these are lines from a file.
- * @param $to_lines array An array of strings.
+ * @param string[] $to_lines An array of strings.
*/
public function __construct( $from_lines, $to_lines ) {
$eng = new DiffEngine;
}
/**
- * @return array|DiffOp[]
+ * @return DiffOp[]
*/
public function getEdits() {
return $this->edits;
*
* $diff = new Diff($lines1, $lines2);
* $rev = $diff->reverse();
+ *
* @return Object A Diff object representing the inverse of the
* original diff.
*/
* This reconstructs the $from_lines parameter passed to the
* constructor.
*
- * @return array The original sequence of strings.
+ * @return string[] The original sequence of strings.
*/
public function orig() {
$lines = array();
* This reconstructs the $to_lines parameter passed to the
* constructor.
*
- * @return array The sequence of strings.
+ * @return string[] The sequence of strings.
*/
public function closing() {
$lines = array();
* case-insensitve diffs, or diffs which ignore
* changes in white-space.
*
- * @param $from_lines array An array of strings.
+ * @param string[] $from_lines An array of strings.
* Typically these are lines from a file.
- *
- * @param $to_lines array An array of strings.
- *
- * @param $mapped_from_lines array This array should
+ * @param string[] $to_lines An array of strings.
+ * @param string[] $mapped_from_lines This array should
* have the same size number of elements as $from_lines.
* The elements in $mapped_from_lines and
* $mapped_to_lines are what is actually compared
* when computing the diff.
- *
- * @param $mapped_to_lines array This array should
+ * @param string[] $mapped_to_lines This array should
* have the same number of elements as $to_lines.
*/
public function __construct( $from_lines, $to_lines,
private $tag = '';
/**
- * @param $new_tag
+ * @param string $new_tag
*/
private function flushGroup( $new_tag ) {
if ( $this->group !== '' ) {
}
/**
- * @param $new_tag
+ * @param string $new_tag
*/
private function flushLine( $new_tag ) {
$this->flushGroup( $new_tag );
}
/**
- * @param $words
- * @param $tag string
+ * @param string[] $words
+ * @param string $tag
*/
public function addWords( $words, $tag = '' ) {
if ( $tag != $this->tag ) {
}
/**
- * @return array
+ * @return string[]
*/
public function getLines() {
$this->flushLine( '~done' );
const MAX_LINE_LENGTH = 10000;
/**
- * @param $orig_lines
- * @param $closing_lines
+ * @param string[] $orig_lines
+ * @param string[] $closing_lines
*/
public function __construct( $orig_lines, $closing_lines ) {
wfProfileIn( __METHOD__ );
}
/**
- * @param $lines
- * @return array
+ * @param string[] $lines
+ *
+ * @return array[]
*/
private function split( $lines ) {
wfProfileIn( __METHOD__ );
}
/**
- * @return array
+ * @return string[]
*/
public function orig() {
wfProfileIn( __METHOD__ );
}
/**
- * @return array
+ * @return string[]
*/
public function closing() {
wfProfileIn( __METHOD__ );
return $lines;
}
+
}
* @ingroup DifferenceEngine
*/
abstract class DiffFormatter {
+
/** @var int Number of leading context "lines" to preserve.
*
* This should be left at zero for this class, but subclasses
/**
* Format a diff.
*
- * @param $diff Diff A Diff object.
+ * @param Diff $diff A Diff object.
+ *
* @return string The formatted output.
*/
public function format( $diff ) {
* @param int $ybeg
* @param int $ylen
* @param $edits
- * @throws MWException
+ *
+ * @throws MWException If the edit type is not known.
*/
protected function block( $xbeg, $xlen, $ybeg, $ylen, &$edits ) {
wfProfileIn( __METHOD__ );
}
/**
- * @param $xbeg
- * @param $xlen
- * @param $ybeg
- * @param $ylen
+ * @param int $xbeg
+ * @param int $xlen
+ * @param int $ybeg
+ * @param int $ylen
+ *
* @return string
*/
protected function blockHeader( $xbeg, $xlen, $ybeg, $ylen ) {
return $xbeg . ( $xlen ? ( $ylen ? 'c' : 'd' ) : 'a' ) . $ybeg;
}
+ /**
+ * Called at the start of a block of connected edits.
+ * This default implementation writes the header and a newline to the output buffer.
+ *
+ * @param string $header
+ */
protected function startBlock( $header ) {
echo $header . "\n";
}
+ /**
+ * Called at the end of a block of connected edits.
+ * This default implementation does nothing.
+ */
protected function endBlock() {
}
/**
- * @param $lines
- * @param $prefix string
+ * Writes all (optionally prefixed) lines to the output buffer, separated by newlines.
+ *
+ * @param string[] $lines
+ * @param string $prefix
*/
protected function lines( $lines, $prefix = ' ' ) {
foreach ( $lines as $line ) {
}
/**
- * @param $lines
+ * @param string[] $lines
*/
protected function context( $lines ) {
$this->lines( $lines );
}
/**
- * @param $lines
+ * @param string[] $lines
*/
protected function added( $lines ) {
$this->lines( $lines, '>' );
}
/**
- * @param $lines
+ * @param string[] $lines
*/
protected function deleted( $lines ) {
$this->lines( $lines, '<' );
}
/**
- * @param $orig
- * @param $closing
+ * Writes the two sets of lines to the output buffer, separated by "---" and a newline.
+ *
+ * @param string[] $orig
+ * @param string[] $closing
*/
protected function changed( $orig, $closing ) {
$this->deleted( $orig );
echo "---\n";
$this->added( $closing );
}
+
}
* @ingroup DifferenceEngine
*/
class DifferenceEngine extends ContextSource {
+
/** @var int */
public $mOldid;
/**
* Constructor
- * @param $context IContextSource context to use, anything else will be ignored
- * @param $old Integer old ID we want to show and diff with.
- * @param $new String|int either revision ID or 'prev' or 'next'. Default: 0.
- * @param $rcid Integer Deprecated, no longer used!
- * @param $refreshCache boolean If set, refreshes the diff cache
- * @param $unhide boolean If set, allow viewing deleted revs
+ * @param IContextSource $context context to use, anything else will be ignored
+ * @param int $old old ID we want to show and diff with.
+ * @param string|int $new either revision ID or 'prev' or 'next'. Default: 0.
+ * @param int $rcid Deprecated, no longer used!
+ * @param bool $refreshCache If set, refreshes the diff cache
+ * @param bool $unhide If set, allow viewing deleted revs
*/
function __construct( $context = null, $old = 0, $new = 0, $rcid = 0,
- $refreshCache = false, $unhide = false
- ) {
+ $refreshCache = false, $unhide = false ) {
if ( $context instanceof IContextSource ) {
$this->setContext( $context );
}
}
/**
- * @param $value bool
+ * @param bool $value
*/
function setReducedLineNumbers( $value = true ) {
$this->mReducedLineNumbers = $value;
}
/**
- * @return Bool|int
+ * @return bool|int
*/
function getNewid() {
$this->loadRevisionIds();
* Look up a special:Undelete link to the given deleted revision id,
* as a workaround for being unable to load deleted diffs in currently.
*
- * @param int $id revision ID
+ * @param int $id Revision ID
+ *
* @return mixed URL or false
*/
function deletedLink( $id ) {
/**
* Build a wikitext link toward a deleted revision, if viewable.
*
- * @param int $id revision ID
- * @return string wikitext fragment
+ * @param int $id Revision ID
+ *
+ * @return string Wikitext fragment
*/
function deletedIdMarker( $id ) {
$link = $this->deletedLink( $id );
* Side effect: When the patrol link is build, this method will call
* OutputPage::preventClickjacking() and load mediawiki.page.patrol.ajax.
*
- * @return String
+ * @return string
*/
protected function markPatrolledLink() {
global $wgUseRCPatrol, $wgEnableAPI, $wgEnableWriteAPI;
}
/**
- * @param $rev Revision
- * @return String
+ * @param Revision $rev
+ *
+ * @return string
*/
protected function revisionDeleteLink( $rev ) {
$link = Linker::getRevDeleteLink( $this->getUser(), $rev, $rev->getTitle() );
* @param string|bool $otitle Header for old text or false
* @param string|bool $ntitle Header for new text or false
* @param string $notice HTML between diff header and body
+ *
* @return mixed
*/
function getDiff( $otitle, $ntitle, $notice = '' ) {
/**
* Returns the cache key for diff body text or content.
*
- * @return string
* @since 1.23
+ *
* @throws MWException
+ * @return string
*/
protected function getDiffBodyCacheKey() {
if ( !$this->mOldid || !$this->mNewid ) {
* perhaps taking advantage of the content's native form. This is required for all content
* models that are not text based.
*
- * @param $old Content: old content
- * @param $new Content: new content
+ * @since 1.21
+ *
+ * @param Content $old Old content
+ * @param Content $new New content
*
+ * @throws MWException If old or new content is not an instance of TextContent.
* @return bool|string
- * @since 1.21
- * @throws MWException if $old or $new are not instances of TextContent.
*/
function generateContentDiffBody( Content $old, Content $new ) {
if ( !( $old instanceof TextContent ) ) {
/**
* Generate a diff, no caching
*
- * @param string $otext old text, must be already segmented
- * @param string $ntext new text, must be already segmented
+ * @param string $otext Old text, must be already segmented
+ * @param string $ntext New text, must be already segmented
+ *
* @return bool|string
* @deprecated since 1.21, use generateContentDiffBody() instead!
*/
*
* @param string $otext old text, must be already segmented
* @param string $ntext new text, must be already segmented
+ *
* @return bool|string
*/
function generateTextDiffBody( $otext, $ntext ) {
* Generate a debug comment indicating diff generating time,
* server node, and generator backend.
*
- * @param String $generator : What diff engine was used
+ * @param string $generator : What diff engine was used
*
* @return string
*/
/**
* Replace line numbers with the text in the user's language
*
- * @param String $text
+ * @param string $text
*
* @return mixed
*/
/**
* If there are revisions between the ones being compared, return a note saying so.
+ *
* @return string
*/
function getMultiNotice() {
/**
* Get a notice about how many intermediate edits and users there are
- * @param $numEdits int
- * @param $numUsers int
- * @param $limit int
+ *
+ * @param int $numEdits
+ * @param int $numUsers
+ * @param int $limit
+ *
* @return string
*/
public static function intermediateEditsMsg( $numEdits, $numUsers, $limit ) {
/**
* Get a header for a specified revision.
*
- * @param $rev Revision
+ * @param Revision $rev
* @param string $complete 'complete' to get the header wrapped depending
* the visibility of the revision and a link to edit the page.
- * @return String HTML fragment
+ *
+ * @return string HTML fragment
*/
protected function getRevisionHeader( Revision $rev, $complete = '' ) {
$lang = $this->getLanguage();
*
* @param int $old Revision id, e.g. from URL parameter 'oldid'
* @param int|string $new Revision id or strings 'next' or 'prev', e.g. from URL parameter 'diff'
- * @return array Array of two revision ids, older first, later second.
+ *
+ * @return int[] List of two revision ids, older first, later second.
* Zero signifies invalid argument passed.
* false signifies that there is no previous/next revision ($old is the oldest/newest one).
*/
return true;
}
+
}
* @ingroup DifferenceEngine
*/
class TableDiffFormatter extends DiffFormatter {
+
function __construct() {
$this->leadingContextLines = 2;
$this->trailingContextLines = 2;
/**
* @static
- * @param $msg
+ * @param string $msg
+ *
* @return mixed
*/
public static function escapeWhiteSpace( $msg ) {
}
/**
- * @param $xbeg
- * @param $xlen
- * @param $ybeg
- * @param $ylen
+ * @param int $xbeg
+ * @param int $xlen
+ * @param int $ybeg
+ * @param int $ylen
+ *
* @return string
*/
protected function blockHeader( $xbeg, $xlen, $ybeg, $ylen ) {
}
/**
- * @param $header
+ * Writes the header to the output buffer.
+ *
+ * @param string $header
*/
protected function startBlock( $header ) {
echo $header;
protected function endBlock() {
}
+ /**
+ * @param string[] $lines
+ * @param string $prefix
+ * @param string $color
+ */
protected function lines( $lines, $prefix = ' ', $color = 'white' ) {
}
/**
* HTML-escape parameter before calling this
- * @param $line
+ *
+ * @param string $line
+ *
* @return string
*/
protected function addedLine( $line ) {
/**
* HTML-escape parameter before calling this
- * @param $line
+ *
+ * @param string $line
+ *
* @return string
*/
protected function deletedLine( $line ) {
/**
* HTML-escape parameter before calling this
- * @param $line
+ *
+ * @param string $line
+ *
* @return string
*/
protected function contextLine( $line ) {
}
/**
- * @param $marker
- * @param $class
- * @param $line
+ * @param string $marker
+ * @param string $class Unused
+ * @param string $line
+ *
* @return string
*/
protected function wrapLine( $marker, $class, $line ) {
}
/**
- * @param $lines array
+ * Writes all lines to the output buffer, each enclosed in <tr>.
+ *
+ * @param string[] $lines
*/
protected function added( $lines ) {
foreach ( $lines as $line ) {
}
/**
- * @param $lines
+ * Writes all lines to the output buffer, each enclosed in <tr>.
+ *
+ * @param string[] $lines
*/
protected function deleted( $lines ) {
foreach ( $lines as $line ) {
}
/**
- * @param $lines
+ * Writes all lines to the output buffer, each enclosed in <tr>.
+ *
+ * @param string[] $lines
*/
protected function context( $lines ) {
foreach ( $lines as $line ) {
}
/**
- * @param $orig
- * @param $closing
+ * Writes the two sets of lines to the output buffer, each enclosed in <tr>.
+ *
+ * @param string[] $orig
+ * @param string[] $closing
*/
protected function changed( $orig, $closing ) {
wfProfileIn( __METHOD__ );
}
wfProfileOut( __METHOD__ );
}
+
}
* @ingroup DifferenceEngine
*/
class UnifiedDiffFormatter extends DiffFormatter {
+
/** @var int */
protected $leadingContextLines = 2;
protected $trailingContextLines = 2;
/**
- * @param $lines
+ * @param string[] $lines
*/
protected function added( $lines ) {
$this->lines( $lines, '+' );
}
/**
- * @param $lines
+ * @param string[] $lines
*/
protected function deleted( $lines ) {
$this->lines( $lines, '-' );
}
/**
- * @param $orig
- * @param $closing
+ * @param string[] $orig
+ * @param string[] $closing
*/
protected function changed( $orig, $closing ) {
$this->deleted( $orig );
}
/**
- * @param $xbeg
- * @param $xlen
- * @param $ybeg
- * @param $ylen
+ * @param int $xbeg
+ * @param int $xlen
+ * @param int $ybeg
+ * @param int $ylen
+ *
* @return string
*/
protected function blockHeader( $xbeg, $xlen, $ybeg, $ylen ) {
return "@@ -$xbeg,$xlen +$ybeg,$ylen @@";
}
+
}
return $this->length;
}
+
}
/**
* @ingroup DifferenceEngine
*/
class RangeDifference {
+
/** @var int */
public $leftstart;
$this->rightend = $rightend;
$this->rightlength = $rightend - $rightstart;
}
+
}