r67834 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r67833‎ | r67834 | r67835 >
Date:21:05, 10 June 2010
Author:ialex
Status:ok (Comments)
Tags:
Comment:
* Fixed some doxygen warnings
* Groupped some related functions
Modified paths:
  • /trunk/phase3/includes/parser/Parser.php (modified) (history)
  • /trunk/phase3/includes/parser/Parser_LinkHooks.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/parser/Parser.php
@@ -239,53 +239,7 @@
240240 wfProfileOut( __METHOD__ );
241241 }
242242
243 - function setOutputType( $ot ) {
244 - $this->mOutputType = $ot;
245 - # Shortcut alias
246 - $this->ot = array(
247 - 'html' => $ot == self::OT_HTML,
248 - 'wiki' => $ot == self::OT_WIKI,
249 - 'pre' => $ot == self::OT_PREPROCESS,
250 - 'plain' => $ot == self::OT_PLAIN,
251 - );
252 - }
253 -
254243 /**
255 - * Set the context title
256 - */
257 - function setTitle( $t ) {
258 - if ( !$t || $t instanceof FakeTitle ) {
259 - $t = Title::newFromText( 'NO TITLE' );
260 - }
261 -
262 - if ( strval( $t->getFragment() ) !== '' ) {
263 - # Strip the fragment to avoid various odd effects
264 - $this->mTitle = clone $t;
265 - $this->mTitle->setFragment( '' );
266 - } else {
267 - $this->mTitle = $t;
268 - }
269 - }
270 -
271 - /**
272 - * Accessor for mUniqPrefix.
273 - *
274 - * @public
275 - */
276 - function uniqPrefix() {
277 - if ( !isset( $this->mUniqPrefix ) ) {
278 - # @todo Fixme: this is probably *horribly wrong*
279 - # LanguageConverter seems to want $wgParser's uniqPrefix, however
280 - # if this is called for a parser cache hit, the parser may not
281 - # have ever been initialized in the first place.
282 - # Not really sure what the heck is supposed to be going on here.
283 - return '';
284 - # throw new MWException( "Accessing uninitialized mUniqPrefix" );
285 - }
286 - return $this->mUniqPrefix;
287 - }
288 -
289 - /**
290244 * Convert wikitext to HTML
291245 * Do not call this function recursively.
292246 *
@@ -481,7 +435,7 @@
482436 * If $frame is not provided, then template variables (e.g., {{{1}}}) within $text are not expanded
483437 *
484438 * @param $text String: text extension wants to have parsed
485 - * @param PPFrame $frame: The frame to use for expanding any template variables
 439+ * @param $frame PPFrame: The frame to use for expanding any template variables
486440 */
487441 function recursiveTagParse( $text, $frame=false ) {
488442 wfProfileIn( __METHOD__ );
@@ -541,12 +495,118 @@
542496 return dechex( mt_rand( 0, 0x7fffffff ) ) . dechex( mt_rand( 0, 0x7fffffff ) );
543497 }
544498
545 - function &getTitle() { return $this->mTitle; }
546 - function getOptions() { return $this->mOptions; }
547 - function getRevisionId() { return $this->mRevisionId; }
548 - function getOutput() { return $this->mOutput; }
549 - function nextLinkID() { return $this->mLinkID++; }
 499+ /**
 500+ * Accessor for mUniqPrefix.
 501+ *
 502+ * @return String
 503+ */
 504+ public function uniqPrefix() {
 505+ if ( !isset( $this->mUniqPrefix ) ) {
 506+ # @todo Fixme: this is probably *horribly wrong*
 507+ # LanguageConverter seems to want $wgParser's uniqPrefix, however
 508+ # if this is called for a parser cache hit, the parser may not
 509+ # have ever been initialized in the first place.
 510+ # Not really sure what the heck is supposed to be going on here.
 511+ return '';
 512+ # throw new MWException( "Accessing uninitialized mUniqPrefix" );
 513+ }
 514+ return $this->mUniqPrefix;
 515+ }
550516
 517+ /**
 518+ * Set the context title
 519+ */
 520+ function setTitle( $t ) {
 521+ if ( !$t || $t instanceof FakeTitle ) {
 522+ $t = Title::newFromText( 'NO TITLE' );
 523+ }
 524+
 525+ if ( strval( $t->getFragment() ) !== '' ) {
 526+ # Strip the fragment to avoid various odd effects
 527+ $this->mTitle = clone $t;
 528+ $this->mTitle->setFragment( '' );
 529+ } else {
 530+ $this->mTitle = $t;
 531+ }
 532+ }
 533+
 534+ /**
 535+ * Accessor for the Title object
 536+ *
 537+ * @return Title object
 538+ */
 539+ function &getTitle() {
 540+ return $this->mTitle;
 541+ }
 542+
 543+ /**
 544+ * Accessor/mutator for the Title object
 545+ *
 546+ * @param $x New Title object or null to just get the current one
 547+ * @return Title object
 548+ */
 549+ function Title( $x = null ) {
 550+ return wfSetVar( $this->mTitle, $x );
 551+ }
 552+
 553+ /**
 554+ * Set the output type
 555+ *
 556+ * @param $ot Integer: new value
 557+ */
 558+ function setOutputType( $ot ) {
 559+ $this->mOutputType = $ot;
 560+ # Shortcut alias
 561+ $this->ot = array(
 562+ 'html' => $ot == self::OT_HTML,
 563+ 'wiki' => $ot == self::OT_WIKI,
 564+ 'pre' => $ot == self::OT_PREPROCESS,
 565+ 'plain' => $ot == self::OT_PLAIN,
 566+ );
 567+ }
 568+
 569+ /**
 570+ * Accessor/mutator for the output type
 571+ *
 572+ * @param $x New value or null to just get the current one
 573+ * @return Integer
 574+ */
 575+ function OutputType( $x = null ) {
 576+ return wfSetVar( $this->mOutputType, $x );
 577+ }
 578+
 579+ /**
 580+ * Get the ParserOutput object
 581+ *
 582+ * @return ParserOutput object
 583+ */
 584+ function getOutput() {
 585+ return $this->mOutput;
 586+ }
 587+
 588+ /**
 589+ * Get the ParserOptions object
 590+ *
 591+ * @return ParserOptions object
 592+ */
 593+ function getOptions() {
 594+ return $this->mOptions;
 595+ }
 596+
 597+ /**
 598+ * Accessor/mutator for the ParserOptions object
 599+ *
 600+ * @param $x New value or null to just get the current one
 601+ * @return Current ParserOptions object
 602+ */
 603+ function Options( $x = null ) {
 604+ return wfSetVar( $this->mOptions, $x );
 605+ }
 606+
 607+ function nextLinkID() {
 608+ return $this->mLinkID++;
 609+ }
 610+
551611 function getFunctionLang() {
552612 global $wgLang, $wgContLang;
553613
@@ -560,6 +620,8 @@
561621
562622 /**
563623 * Get a preprocessor object
 624+ *
 625+ * @return Preprocessor instance
564626 */
565627 function getPreprocessor() {
566628 if ( !isset( $this->mPreprocessor ) ) {
@@ -582,12 +644,13 @@
583645 *
584646 * @param $elements list of element names. Comments are always extracted.
585647 * @param $text Source text string.
 648+ * @param $matches Out parameter, Array: extarcted tags
586649 * @param $uniq_prefix
 650+ * @return String: stripped text
587651 *
588 - * @public
589652 * @static
590653 */
591 - function extractTagsAndParams( $elements, $text, &$matches, $uniq_prefix = '' ) {
 654+ public function extractTagsAndParams( $elements, $text, &$matches, $uniq_prefix = '' ) {
592655 static $n = 1;
593656 $stripped = '';
594657 $matches = array();
@@ -1388,9 +1451,9 @@
13891452 * (depending on configuration, namespace, and the URL's domain) and/or a
13901453 * target attribute (depending on configuration).
13911454 *
1392 - * @param string $url Optional URL, to extract the domain from for rel =>
 1455+ * @param $url String: optional URL, to extract the domain from for rel =>
13931456 * nofollow if appropriate
1394 - * @return array Associative array of HTML attributes
 1457+ * @return Array: associative array of HTML attributes
13951458 */
13961459 function getExternalLinkAttribs( $url = false ) {
13971460 $attribs = array();
@@ -1421,9 +1484,10 @@
14221485
14231486 /**
14241487 * Replace unusual URL escape codes with their equivalent characters
1425 - * @param string
1426 - * @return string
1427 - * @static
 1488+ *
 1489+ * @param $url String
 1490+ * @return String
 1491+ *
14281492 * @todo This can merge genuinely required bits in the path or query string,
14291493 * breaking legit URLs. A proper fix would treat the various parts of
14301494 * the URL differently; as a workaround, just use the output for
@@ -1437,8 +1501,6 @@
14381502 /**
14391503 * Callback function used in replaceUnusualEscapes().
14401504 * Replaces unusual URL escape codes with their equivalent character
1441 - * @static
1442 - * @private
14431505 */
14441506 private static function replaceUnusualEscapesCallback( $matches ) {
14451507 $char = urldecode( $matches[0] );
@@ -1864,12 +1926,12 @@
18651927 * breaking URLs in the following text without breaking trails on the
18661928 * wiki links, it's been made into a horrible function.
18671929 *
1868 - * @param Title $nt
1869 - * @param string $text
1870 - * @param string $query
1871 - * @param string $trail
1872 - * @param string $prefix
1873 - * @return string HTML-wikitext mix oh yuck
 1930+ * @param $nt Title
 1931+ * @param $text String
 1932+ * @param $query String
 1933+ * @param $trail String
 1934+ * @param $prefix String
 1935+ * @return String: HTML-wikitext mix oh yuck
18741936 */
18751937 function makeKnownLinkHolder( $nt, $text = '', $query = '', $trail = '', $prefix = '' ) {
18761938 list( $inside, $trail ) = Linker::splitTrail( $trail );
@@ -1886,8 +1948,8 @@
18871949 * Not needed quite as much as it used to be since free links are a bit
18881950 * more sensible these days. But bracketed links are still an issue.
18891951 *
1890 - * @param string more-or-less HTML
1891 - * @return string less-or-more HTML with NOPARSE bits
 1952+ * @param $text String: more-or-less HTML
 1953+ * @return String: less-or-more HTML with NOPARSE bits
18921954 */
18931955 function armorLinks( $text ) {
18941956 return preg_replace( '/\b(' . wfUrlProtocols() . ')/',
@@ -1896,7 +1958,7 @@
18971959
18981960 /**
18991961 * Return true if subpage links should be expanded on this page.
1900 - * @return bool
 1962+ * @return Boolean
19011963 */
19021964 function areSubpagesAllowed() {
19031965 # Some namespaces don't allow subpages
@@ -1905,8 +1967,9 @@
19061968
19071969 /**
19081970 * Handle link to subpage if necessary
1909 - * @param string $target the source of the link
1910 - * @param string &$text the link text, modified as necessary
 1971+ *
 1972+ * @param $target String: the source of the link
 1973+ * @param &$text String: the link text, modified as necessary
19111974 * @return string the full name of the link
19121975 * @private
19131976 */
@@ -1927,6 +1990,7 @@
19281991 $this->mLastSection = '';
19291992 return $result;
19301993 }
 1994+
19311995 /**
19321996 * getCommon() returns the length of the longest common substring
19331997 * of both arguments, starting at the beginning of both.
@@ -1946,6 +2010,7 @@
19472011 }
19482012 return $i;
19492013 }
 2014+
19502015 /**
19512016 * These next three functions open, continue, and close the list
19522017 * element appropriate to the prefix character passed into them.
@@ -2021,7 +2086,8 @@
20222087 /**
20232088 * Make lists from lines starting with ':', '*', '#', etc. (DBL)
20242089 *
2025 - * @param $linestart bool whether or not this is at the start of a line.
 2090+ * @param $text String
 2091+ * @param $linestart Boolean: whether or not this is at the start of a line.
20262092 * @private
20272093 * @return string the lists rendered as HTML
20282094 */
@@ -2210,10 +2276,11 @@
22112277 /**
22122278 * Split up a string on ':', ignoring any occurences inside tags
22132279 * to prevent illegal overlapping.
2214 - * @param string $str the string to split
2215 - * @param string &$before set to everything before the ':'
2216 - * @param string &$after set to everything after the ':'
2217 - * return string the position of the ':', or false if none found
 2280+ *
 2281+ * @param $str String: the string to split
 2282+ * @param &$before String: set to everything before the ':'
 2283+ * @param &$after String: set to everything after the ':'
 2284+ * return String: the position of the ':', or false if none found
22182285 */
22192286 function findColonNoLinks( $str, &$before, &$after ) {
22202287 wfProfileIn( __METHOD__ );
@@ -2700,8 +2767,8 @@
27012768 * Preprocess some wikitext and return the document tree.
27022769 * This is the ghost of replace_variables().
27032770 *
2704 - * @param string $text The text to parse
2705 - * @param integer flags Bitwise combination of:
 2771+ * @param $text String: The text to parse
 2772+ * @param $flags Integer: bitwise combination of:
27062773 * self::PTD_FOR_INCLUSION Handle <noinclude>/<includeonly> as if the text is being
27072774 * included. Default is to assume a direct page view.
27082775 *
@@ -2749,11 +2816,11 @@
27502817 * self::OT_PREPROCESS: templates but not extension tags
27512818 * self::OT_HTML: all templates and extension tags
27522819 *
2753 - * @param string $tex The text to transform
2754 - * @param PPFrame $frame Object describing the arguments passed to the template.
 2820+ * @param $text String: the text to transform
 2821+ * @param $frame PPFrame Object describing the arguments passed to the template.
27552822 * Arguments may also be provided as an associative array, as was the usual case before MW1.12.
27562823 * Providing arguments this way may be useful for extensions wishing to perform variable replacement explicitly.
2757 - * @param bool $argsOnly Only do argument (triple-brace) expansion, not double-brace expansion
 2824+ * @param $argsOnly Boolean: only do argument (triple-brace) expansion, not double-brace expansion
27582825 * @private
27592826 */
27602827 function replaceVariables( $text, $frame = false, $argsOnly = false ) {
@@ -2805,7 +2872,7 @@
28062873 * Warn the user when a parser limitation is reached
28072874 * Will warn at most once the user per limitation type
28082875 *
2809 - * @param string $limitationType, should be one of:
 2876+ * @param $limitationType String: should be one of:
28102877 * 'expensive-parserfunction' (corresponding messages:
28112878 * 'expensive-parserfunction-warning',
28122879 * 'expensive-parserfunction-category')
@@ -2815,7 +2882,8 @@
28162883 * 'post-expand-template-inclusion' (corresponding messages:
28172884 * 'post-expand-template-inclusion-warning',
28182885 * 'post-expand-template-inclusion-category')
2819 - * @params int $current, $max When an explicit limit has been
 2886+ * @param $current Current value
 2887+ * @param $max Maximum allowed, when an explicit limit has been
28202888 * exceeded, provide the values (optional)
28212889 */
28222890 function limitationWarn( $limitationType, $current=null, $max=null) {
@@ -2829,12 +2897,12 @@
28302898 * Return the text of a template, after recursively
28312899 * replacing any variables or templates within the template.
28322900 *
2833 - * @param array $piece The parts of the template
 2901+ * @param $piece Array: the parts of the template
28342902 * $piece['title']: the title, i.e. the part before the |
28352903 * $piece['parts']: the parameter array
28362904 * $piece['lineStart']: whether the brace was at the start of a line
2837 - * @param PPFrame The current frame, contains template arguments
2838 - * @return string the text of the template
 2905+ * @param $frame PPFrame The current frame, contains template arguments
 2906+ * @return String: the text of the template
28392907 * @private
28402908 */
28412909 function braceSubstitution( $piece, $frame ) {
@@ -3366,13 +3434,13 @@
33673435 * Return the text to be used for a given extension tag.
33683436 * This is the ghost of strip().
33693437 *
3370 - * @param array $params Associative array of parameters:
 3438+ * @param $params Associative array of parameters:
33713439 * name PPNode for the tag name
33723440 * attr PPNode for unparsed text where tag attributes are thought to be
33733441 * attributes Optional associative array of parsed attributes
33743442 * inner Contents of extension element
33753443 * noClose Original text did not have a close tag
3376 - * @param PPFrame $frame
 3444+ * @param $frame PPFrame
33773445 */
33783446 function extensionSubstitution( $params, $frame ) {
33793447 global $wgRawHtml, $wgContLang;
@@ -3455,9 +3523,9 @@
34563524 /**
34573525 * Increment an include size counter
34583526 *
3459 - * @param string $type The type of expansion
3460 - * @param integer $size The size of the text
3461 - * @return boolean False if this inclusion would take it over the maximum, true otherwise
 3527+ * @param $type String: the type of expansion
 3528+ * @param $size Integer: the size of the text
 3529+ * @return Boolean: false if this inclusion would take it over the maximum, true otherwise
34623530 */
34633531 function incrementIncludeSize( $type, $size ) {
34643532 if ( $this->mIncludeSizes[$type] + $size > $this->mOptions->getMaxIncludeSize( $type ) ) {
@@ -3471,7 +3539,7 @@
34723540 /**
34733541 * Increment the expensive function count
34743542 *
3475 - * @return boolean False if the limit has been exceeded
 3543+ * @return Boolean: false if the limit has been exceeded
34763544 */
34773545 function incrementExpensiveFunctionCount() {
34783546 global $wgExpensiveParserFunctionLimit;
@@ -3536,8 +3604,9 @@
35373605 /**
35383606 * Add a tracking category, getting the title from a system message,
35393607 * or print a debug message if the title is invalid.
3540 - * @param $msg String message key
3541 - * @return Bool whether the addition was successful
 3608+ *
 3609+ * @param $msg String: message key
 3610+ * @return Boolean: whether the addition was successful
35423611 */
35433612 protected function addTrackingCategory( $msg ) {
35443613 $cat = wfMsgForContent( $msg );
@@ -3567,9 +3636,9 @@
35683637 * It loops through all headlines, collects the necessary data, then splits up the
35693638 * string and re-inserts the newly formatted headlines.
35703639 *
3571 - * @param string $text
3572 - * @param string $origText Original, untouched wikitext
3573 - * @param boolean $isMain
 3640+ * @param $text String
 3641+ * @param $origText String: original, untouched wikitext
 3642+ * @param $isMain Boolean
35743643 * @private
35753644 */
35763645 function formatHeadings( $text, $origText, $isMain=true ) {
@@ -3913,12 +3982,13 @@
39143983 * $section in $tree1 and its descendants with the sections in $tree2.
39153984 * Note that in the returned section tree, only the 'index' and
39163985 * 'byteoffset' fields are guaranteed to be correct.
3917 - * @param $tree1 array Section tree from ParserOutput::getSectons()
3918 - * @param $tree2 array Section tree
3919 - * @param $section int Section index
3920 - * @param $title Title Title both section trees come from
3921 - * @param $len2 int Length of the original wikitext for $tree2
3922 - * @return array Merged section tree
 3986+ *
 3987+ * @param $tree1 Array: section tree from ParserOutput::getSectons()
 3988+ * @param $tree2 Array: section tree
 3989+ * @param $section Integer: section index
 3990+ * @param $title Title: Title both section trees come from
 3991+ * @param $len2 Integer: length of the original wikitext for $tree2
 3992+ * @return Array: merged section tree
39233993 */
39243994 public static function mergeSectionTrees( $tree1, $tree2, $section, $title, $len2 ) {
39253995 global $wgContLang;
@@ -3984,9 +4054,10 @@
39854055
39864056 /**
39874057 * Increment a section number. Helper function for mergeSectionTrees()
3988 - * @param $number array Array representing a section number
3989 - * @param $level int Current TOC level (depth)
3990 - * @param $lastLevel int Level of previous TOC entry
 4058+ *
 4059+ * @param $number Array representing a section number
 4060+ * @param $level Integer: current TOC level (depth)
 4061+ * @param $lastLevel Integer: level of previous TOC entry
39914062 */
39924063 private static function incrementNumbering( &$number, $level, $lastLevel ) {
39934064 if ( $level > $lastLevel ) {
@@ -4006,15 +4077,14 @@
40074078 * Transform wiki markup when saving a page by doing \r\n -> \n
40084079 * conversion, substitting signatures, {{subst:}} templates, etc.
40094080 *
4010 - * @param string $text the text to transform
4011 - * @param Title &$title the Title object for the current article
4012 - * @param User $user the User object describing the current user
4013 - * @param ParserOptions $options parsing options
4014 - * @param bool $clearState whether to clear the parser state first
4015 - * @return string the altered wiki markup
4016 - * @public
 4081+ * @param $text String: the text to transform
 4082+ * @param &$title Title: the Title object for the current article
 4083+ * @param $user User: the User object describing the current user
 4084+ * @param $options ParserOptions: parsing options
 4085+ * @param $clearState Boolean: whether to clear the parser state first
 4086+ * @return String: the altered wiki markup
40174087 */
4018 - function preSaveTransform( $text, Title $title, $user, $options, $clearState = true ) {
 4088+ public function preSaveTransform( $text, Title $title, $user, $options, $clearState = true ) {
40194089 $this->mOptions = $options;
40204090 $this->setTitle( $title );
40214091 $this->setOutputType( self::OT_WIKI );
@@ -4120,7 +4190,10 @@
41214191 * If you have pre-fetched the nickname or the fancySig option, you can
41224192 * specify them here to save a database query.
41234193 *
4124 - * @param User $user
 4194+ * @param $user User
 4195+ * @param $nickname String: nickname to use or false to use user's default nickname
 4196+ * @param $fancySig Boolean: whether the nicknname is the complete signature
 4197+ * or null to use default value
41254198 * @return string
41264199 */
41274200 function getUserSig( &$user, $nickname = false, $fancySig = null ) {
@@ -4169,7 +4242,7 @@
41704243 /**
41714244 * Check that the user's signature contains no bad XML
41724245 *
4173 - * @param string $text
 4246+ * @param $text String
41744247 * @return mixed An expanded string, or false if invalid.
41754248 */
41764249 function validateSig( $text ) {
@@ -4182,9 +4255,9 @@
41834256 * 1) Strip ~~~, ~~~~ and ~~~~~ out of signatures @see cleanSigInSig
41844257 * 2) Substitute all transclusions
41854258 *
4186 - * @param string $text
 4259+ * @param $text String
41874260 * @param $parsing Whether we're cleaning (preferences save) or parsing
4188 - * @return string Signature text
 4261+ * @return String: signature text
41894262 */
41904263 function cleanSig( $text, $parsing = false ) {
41914264 if ( !$parsing ) {
@@ -4221,8 +4294,9 @@
42224295
42234296 /**
42244297 * Strip ~~~, ~~~~ and ~~~~~ out of signatures
4225 - * @param string $text
4226 - * @return string Signature text with /~{3,5}/ removed
 4298+ *
 4299+ * @param $text String
 4300+ * @return String: signature text with /~{3,5}/ removed
42274301 */
42284302 function cleanSigInSig( $text ) {
42294303 $text = preg_replace( '/~{3,5}/', '', $text );
@@ -4232,9 +4306,8 @@
42334307 /**
42344308 * Set up some variables which are usually set up in parse()
42354309 * so that an external function can call some class members with confidence
4236 - * @public
42374310 */
4238 - function startExternalParse( &$title, $options, $outputType, $clearState = true ) {
 4311+ public function startExternalParse( &$title, $options, $outputType, $clearState = true ) {
42394312 $this->setTitle( $title );
42404313 $this->mOptions = $options;
42414314 $this->setOutputType( $outputType );
@@ -4246,12 +4319,11 @@
42474320 /**
42484321 * Wrapper for preprocess()
42494322 *
4250 - * @param string $text the text to preprocess
4251 - * @param ParserOptions $options options
4252 - * @return string
4253 - * @public
 4323+ * @param $text String: the text to preprocess
 4324+ * @param $options ParserOptions: options
 4325+ * @return String
42544326 */
4255 - function transformMsg( $text, $options ) {
 4327+ public function transformMsg( $text, $options ) {
42564328 global $wgTitle;
42574329 static $executing = false;
42584330
@@ -4277,14 +4349,11 @@
42784350 * Transform and return $text. Use $parser for any required context, e.g. use
42794351 * $parser->getTitle() and $parser->getOptions() not $wgTitle or $wgOut->mParserOptions
42804352 *
4281 - * @public
4282 - *
4283 - * @param mixed $tag The tag to use, e.g. 'hook' for <hook>
4284 - * @param mixed $callback The callback function (and object) to use for the tag
4285 - *
 4353+ * @param $tag Mixed: the tag to use, e.g. 'hook' for <hook>
 4354+ * @param $callback Mixed: the callback function (and object) to use for the tag
42864355 * @return The old value of the mTagHooks array associated with the hook
42874356 */
4288 - function setHook( $tag, $callback ) {
 4357+ public function setHook( $tag, $callback ) {
42894358 $tag = strtolower( $tag );
42904359 $oldVal = isset( $this->mTagHooks[$tag] ) ? $this->mTagHooks[$tag] : null;
42914360 $this->mTagHooks[$tag] = $callback;
@@ -4327,11 +4396,9 @@
43284397 * nowiki Wiki markup in the return value should be escaped
43294398 * isHTML The returned text is HTML, armour it against wikitext transformation
43304399 *
4331 - * @public
4332 - *
4333 - * @param string $id The magic word ID
4334 - * @param mixed $callback The callback function (and object) to use
4335 - * @param integer $flags a combination of the following flags:
 4400+ * @param $id String: The magic word ID
 4401+ * @param $callback Mixed: the callback function (and object) to use
 4402+ * @param $flags Integer: a combination of the following flags:
43364403 * SFH_NO_HASH No leading hash, i.e. {{plural:...}} instead of {{#if:...}}
43374404 *
43384405 * SFH_OBJECT_ARGS Pass the template arguments as PPNode objects instead of text. This
@@ -4355,7 +4422,7 @@
43564423 *
43574424 * @return The old callback function for this name, if any
43584425 */
4359 - function setFunctionHook( $id, $callback, $flags = 0 ) {
 4426+ public function setFunctionHook( $id, $callback, $flags = 0 ) {
43604427 global $wgContLang;
43614428
43624429 $oldVal = isset( $this->mFunctionHooks[$id] ) ? $this->mFunctionHooks[$id][0] : null;
@@ -4390,7 +4457,7 @@
43914458 /**
43924459 * Get all registered function hook identifiers
43934460 *
4394 - * @return array
 4461+ * @return Array
43954462 */
43964463 function getFunctionHooks() {
43974464 return array_keys( $this->mFunctionHooks );
@@ -4427,8 +4494,9 @@
44284495 /**
44294496 * Replace <!--LINK--> link placeholders with plain text of links
44304497 * (not HTML-formatted).
4431 - * @param string $text
4432 - * @return string
 4498+ *
 4499+ * @param $text String
 4500+ * @return String
44334501 */
44344502 function replaceLinkHoldersText( $text ) {
44354503 return $this->mLinkHolders->replaceText( $text );
@@ -4557,9 +4625,10 @@
45584626
45594627 /**
45604628 * Parse image options text and use it to make an image
4561 - * @param Title $title
4562 - * @param string $options
4563 - * @param LinkHolderArray $holders
 4629+ *
 4630+ * @param $title Title
 4631+ * @param $options String
 4632+ * @param $holders LinkHolderArray
45644633 */
45654634 function makeImage( $title, $options, $holders = false ) {
45664635 # Check if the options text is of the form "options|alt text"
@@ -4791,12 +4860,13 @@
47924861 $this->mOutput->updateCacheExpiry( 0 ); // new style, for consistency
47934862 }
47944863
4795 - /**#@+
 4864+ /**
47964865 * Callback from the Sanitizer for expanding items found in HTML attribute
47974866 * values, so they can be safely tested and escaped.
4798 - * @param string $text
4799 - * @param PPFrame $frame
4800 - * @return string
 4867+ *
 4868+ * @param $text String
 4869+ * @param $frame PPFrame
 4870+ * @return String
48014871 * @private
48024872 */
48034873 function attributeStripCallback( &$text, $frame = false ) {
@@ -4805,33 +4875,21 @@
48064876 return $text;
48074877 }
48084878
4809 - /**#@-*/
4810 -
4811 - /**#@+
4812 - * Accessor/mutator
4813 - */
4814 - function Title( $x = null ) { return wfSetVar( $this->mTitle, $x ); }
4815 - function Options( $x = null ) { return wfSetVar( $this->mOptions, $x ); }
4816 - function OutputType( $x = null ) { return wfSetVar( $this->mOutputType, $x ); }
4817 - /**#@-*/
4818 -
4819 - /**#@+
 4879+ /**
48204880 * Accessor
48214881 */
48224882 function getTags() {
48234883 return array_merge( array_keys( $this->mTransparentTagHooks ), array_keys( $this->mTagHooks ) );
48244884 }
4825 - /**#@-*/
48264885
4827 -
48284886 /**
48294887 * Break wikitext input into sections, and either pull or replace
48304888 * some particular section's text.
48314889 *
48324890 * External callers should use the getSection and replaceSection methods.
48334891 *
4834 - * @param string $text Page wikitext
4835 - * @param string $section A section identifier string of the form:
 4892+ * @param $text String: Page wikitext
 4893+ * @param $section String: a section identifier string of the form:
48364894 * <flag1> - <flag2> - ... - <section number>
48374895 *
48384896 * Currently the only recognised flag is "T", which means the target section number
@@ -4844,10 +4902,10 @@
48454903 * pull the given section along with its lower-level subsections. If the section is
48464904 * not found, $mode=get will return $newtext, and $mode=replace will return $text.
48474905 *
4848 - * @param string $mode One of "get" or "replace"
4849 - * @param string $newText Replacement text for section data.
4850 - * @return string for "get", the extracted section text.
4851 - * for "replace", the whole page with the section replaced.
 4906+ * @param $mode String: one of "get" or "replace"
 4907+ * @param $newText String: replacement text for section data.
 4908+ * @return String: for "get", the extracted section text.
 4909+ * for "replace", the whole page with the section replaced.
48524910 */
48534911 private function extractSections( $text, $section, $mode, $newText='' ) {
48544912 global $wgTitle;
@@ -4879,11 +4937,11 @@
48804938 # Section zero doesn't nest, level=big
48814939 $targetLevel = 1000;
48824940 } else {
4883 - while ( $node ) {
4884 - if ( $node->getName() === 'h' ) {
4885 - $bits = $node->splitHeading();
 4941+ while ( $node ) {
 4942+ if ( $node->getName() === 'h' ) {
 4943+ $bits = $node->splitHeading();
48864944 if ( $bits['i'] == $sectionIndex ) {
4887 - $targetLevel = $bits['level'];
 4945+ $targetLevel = $bits['level'];
48884946 break;
48894947 }
48904948 }
@@ -4949,9 +5007,9 @@
49505008 *
49515009 * If a section contains subsections, these are also returned.
49525010 *
4953 - * @param string $text text to look in
4954 - * @param string $section section identifier
4955 - * @param string $deftext default to return if section is not found
 5011+ * @param $text String: text to look in
 5012+ * @param $section String: section identifier
 5013+ * @param $deftext String: default to return if section is not found
49565014 * @return string text of the requested section
49575015 */
49585016 public function getSection( $text, $section, $deftext='' ) {
@@ -4963,6 +5021,15 @@
49645022 }
49655023
49665024 /**
 5025+ * Get the ID of the revision we are parsing
 5026+ *
 5027+ * @return Mixed: integer or null
 5028+ */
 5029+ function getRevisionId() {
 5030+ return $this->mRevisionId;
 5031+ }
 5032+
 5033+ /**
49675034 * Get the timestamp associated with the current revision, adjusted for
49685035 * the default server-local timestamp
49695036 */
@@ -4995,6 +5062,8 @@
49965063
49975064 /**
49985065 * Get the name of the user that edited the last revision
 5066+ *
 5067+ * @return String: user name
49995068 */
50005069 function getRevisionUser() {
50015070 # if this template is subst: the revision id will be blank,
@@ -5080,7 +5149,7 @@
50815150 * to create valid section anchors by mimicing the output of the
50825151 * parser when headings are parsed.
50835152 *
5084 - * @param $text string Text string to be stripped of wikitext
 5153+ * @param $text String: text string to be stripped of wikitext
50855154 * for use in a Section anchor
50865155 * @return Filtered text string
50875156 */
Index: trunk/phase3/includes/parser/Parser_LinkHooks.php
@@ -78,9 +78,9 @@
7979 *
8080 * @public
8181 *
82 - * @param integer|string $ns The Namespace ID or regex pattern if SLH_PATTERN is set
83 - * @param mixed $callback The callback function (and object) to use
84 - * @param integer $flags a combination of the following flags:
 82+ * @param $ns Integer or String: the Namespace ID or regex pattern if SLH_PATTERN is set
 83+ * @param $callback Mixed: the callback function (and object) to use
 84+ * @param $flags Integer: a combination of the following flags:
8585 * SLH_PATTERN Use a regex link pattern rather than a namespace
8686 *
8787 * @return The old callback function for this name, if any

Follow-up revisions

RevisionCommit summaryAuthorDate
r74851Per Platonides, follow-up to r67834: fix doc and removed no more needed retur...ialex18:58, 16 October 2010

Comments

#Comment by Platonides (talk | contribs)   22:58, 15 October 2010

+ function &getTitle() { I don't think this & is needed anymore.

+	 * @param &$title Title: the Title object for the current article

That & should have been removed in r49142, too.

+	 * @param $matches Out parameter, Array: extarcted tags

You mean extracted? :)

Minor issues, and mostly not actually caused by this revision.

This would have been much easier to review without the reordering, though.

#Comment by IAlex (talk | contribs)   18:58, 16 October 2010

Done in r74851.

Status & tagging log