r110175 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r110174‎ | r110175 | r110176 >
Date:22:07, 27 January 2012
Author:mrbluesky
Status:ok (Comments)
Tags:
Comment:
Comments only
Modified paths:
  • /trunk/phase3/includes/parser/ParserOptions.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/parser/ParserOptions.php
@@ -1,58 +1,188 @@
22 <?php
33 /**
4 - * Options for the PHP parser
 4+ * \brief Options for the PHP parser
55 *
66 * @file
77 * @ingroup Parser
88 */
99
1010 /**
11 - * Set options of the Parser
12 - * @todo document
 11+ * \brief Set options of the Parser
 12+ *
 13+ * All member variables are supposed to be private in theory, although in practise this is not the case.
 14+ *
1315 * @ingroup Parser
1416 */
1517 class ParserOptions {
16 - # All variables are supposed to be private in theory, although in practise this is not the case.
17 - var $mUseDynamicDates; # Use DateFormatter to format dates
18 - var $mInterwikiMagic; # Interlanguage links are removed and returned in an array
19 - var $mAllowExternalImages; # Allow external images inline
20 - var $mAllowExternalImagesFrom; # If not, any exception?
21 - var $mEnableImageWhitelist; # If not or it doesn't match, should we check an on-wiki whitelist?
22 - var $mDateFormat = null; # Date format index
23 - var $mEditSection = true; # Create "edit section" links
24 - var $mAllowSpecialInclusion; # Allow inclusion of special pages
25 - var $mTidy = false; # Ask for tidy cleanup
26 - var $mInterfaceMessage = false; # Which lang to call for PLURAL and GRAMMAR
27 - var $mTargetLanguage = null; # Overrides above setting with arbitrary language
28 - var $mMaxIncludeSize; # Maximum size of template expansions, in bytes
29 - var $mMaxPPNodeCount; # Maximum number of nodes touched by PPFrame::expand()
30 - var $mMaxPPExpandDepth; # Maximum recursion depth in PPFrame::expand()
31 - var $mMaxTemplateDepth; # Maximum recursion depth for templates within templates
32 - var $mRemoveComments = true; # Remove HTML comments. ONLY APPLIES TO PREPROCESS OPERATIONS
33 - var $mTemplateCallback = # Callback for template fetching
 18+
 19+ /**
 20+ * Use DateFormatter to format dates
 21+ */
 22+ var $mUseDynamicDates;
 23+
 24+ /**
 25+ * Interlanguage links are removed and returned in an array
 26+ */
 27+ var $mInterwikiMagic;
 28+
 29+ /**
 30+ * Allow external images inline?
 31+ */
 32+ var $mAllowExternalImages;
 33+
 34+ /**
 35+ * If not, any exception?
 36+ */
 37+ var $mAllowExternalImagesFrom;
 38+
 39+ /**
 40+ * If not or it doesn't match, should we check an on-wiki whitelist?
 41+ */
 42+ var $mEnableImageWhitelist;
 43+
 44+ /**
 45+ * Date format index
 46+ */
 47+ var $mDateFormat = null;
 48+
 49+ /**
 50+ * Create "edit section" links?
 51+ */
 52+ var $mEditSection = true;
 53+
 54+ /**
 55+ * Allow inclusion of special pages?
 56+ */
 57+ var $mAllowSpecialInclusion;
 58+
 59+ /**
 60+ * Use tidy to cleanup output HTML?
 61+ */
 62+ var $mTidy = false;
 63+
 64+ /**
 65+ * Which lang to call for PLURAL and GRAMMAR
 66+ */
 67+ var $mInterfaceMessage = false;
 68+
 69+ /**
 70+ * Overrides $mInterfaceMessage with arbitrary language
 71+ */
 72+ var $mTargetLanguage = null;
 73+
 74+ /**
 75+ * Maximum size of template expansions, in bytes
 76+ */
 77+ var $mMaxIncludeSize;
 78+
 79+ /**
 80+ * Maximum number of nodes touched by PPFrame::expand()
 81+ */
 82+ var $mMaxPPNodeCount;
 83+
 84+ /**
 85+ * Maximum recursion depth in PPFrame::expand()
 86+ */
 87+ var $mMaxPPExpandDepth;
 88+
 89+ /**
 90+ * Maximum recursion depth for templates within templates
 91+ */
 92+ var $mMaxTemplateDepth;
 93+
 94+ /**
 95+ * Remove HTML comments. ONLY APPLIES TO PREPROCESS OPERATIONS
 96+ */
 97+ var $mRemoveComments = true;
 98+
 99+ /**
 100+ * Callback for template fetching. Used as first argument to call_user_func().
 101+ */
 102+ var $mTemplateCallback =
34103 array( 'Parser', 'statelessFetchTemplate' );
35 - var $mEnableLimitReport = false; # Enable limit report in an HTML comment on output
36 - var $mTimestamp; # Timestamp used for {{CURRENTDAY}} etc.
37 - var $mExternalLinkTarget; # Target attribute for external links
38 - var $mCleanSignatures; #
39 - var $mPreSaveTransform = true; # Transform wiki markup when saving the page.
 104+
 105+ /**
 106+ * Enable limit report in an HTML comment on output
 107+ */
 108+ var $mEnableLimitReport = false;
 109+
 110+ /**
 111+ * Timestamp used for {{CURRENTDAY}} etc.
 112+ */
 113+ var $mTimestamp;
 114+
 115+ /**
 116+ * Target attribute for external links
 117+ */
 118+ var $mExternalLinkTarget;
 119+
 120+ /**
 121+ * Clean up signature texts?
 122+ *
 123+ * 1) Strip ~~~, ~~~~ and ~~~~~ out of signatures
 124+ * 2) Substitute all transclusions
 125+ */
 126+ var $mCleanSignatures;
 127+
 128+ /**
 129+ * Transform wiki markup when saving the page?
 130+ */
 131+ var $mPreSaveTransform = true;
40132
41 - var $mNumberHeadings; # Automatically number headings
42 - var $mMath; # User math preference (as integer)
43 - var $mThumbSize; # Thumb size preferred by the user.
44 - private $mStubThreshold; # Maximum article size of an article to be marked as "stub"
45 - var $mUserLang; # Language object of the User language.
 133+ /**
 134+ * Automatically number headings?
 135+ */
 136+ var $mNumberHeadings;
 137+
 138+ /**
 139+ * User math preference (as integer). Not used (1.19)
 140+ */
 141+ var $mMath;
 142+
 143+ /**
 144+ * Thumb size preferred by the user.
 145+ */
 146+ var $mThumbSize;
 147+
 148+ /**
 149+ * Maximum article size of an article to be marked as "stub"
 150+ */
 151+ private $mStubThreshold;
 152+
 153+ /**
 154+ * Language object of the User language.
 155+ */
 156+ var $mUserLang;
46157
47158 /**
48 - * @var User
 159+ * @var User
 160+ * Stored user object
49161 */
50 - var $mUser; # Stored user object
51 - var $mIsPreview = false; # Parsing the page for a "preview" operation
52 - var $mIsSectionPreview = false; # Parsing the page for a "preview" operation on a single section
53 - var $mIsPrintable = false; # Parsing the printable version of the page
 162+ var $mUser;
 163+
 164+ /**
 165+ * Parsing the page for a "preview" operation?
 166+ */
 167+ var $mIsPreview = false;
 168+
 169+ /**
 170+ * Parsing the page for a "preview" operation on a single section?
 171+ */
 172+ var $mIsSectionPreview = false;
 173+
 174+ /**
 175+ * Parsing the printable version of the page?
 176+ */
 177+ var $mIsPrintable = false;
54178
55 - var $mExtraKey = ''; # Extra key that should be present in the caching key.
 179+ /**
 180+ * Extra key that should be present in the caching key.
 181+ */
 182+ var $mExtraKey = '';
56183
 184+ /**
 185+ * Function to be called when an option is accessed.
 186+ */
57187 protected $onAccessCallback = null;
58188
59189 function getUseDynamicDates() { return $this->mUseDynamicDates; }
@@ -184,6 +314,11 @@
185315 $this->mExtraKey .= '!' . $key;
186316 }
187317
 318+ /**
 319+ * Constructor
 320+ * @param $user User object
 321+ * @param $lang Language object
 322+ */
188323 function __construct( $user = null, $lang = null ) {
189324 if ( $user === null ) {
190325 global $wgUser;
@@ -235,7 +370,12 @@
236371 return new ParserOptions( $context->getUser(), $context->getLanguage() );
237372 }
238373
239 - /** Get user options */
 374+ /**
 375+ * Get user options
 376+ *
 377+ * @param $user User object
 378+ * @param $lang Language object
 379+ */
240380 private function initialiseFromUser( $user, $lang ) {
241381 global $wgUseDynamicDates, $wgInterwikiMagic, $wgAllowExternalImages,
242382 $wgAllowExternalImagesFrom, $wgEnableImageWhitelist, $wgAllowSpecialInclusion,
@@ -314,7 +454,7 @@
315455 * @since 1.17
316456 * @param $forOptions Array
317457 * @param $title Title: used to get the content language of the page (since r97636)
318 - * @return \string Page rendering hash
 458+ * @return string Page rendering hash
319459 */
320460 public function optionsHash( $forOptions, $title = null ) {
321461 global $wgRenderHashAppend;

Comments

#Comment by 😂 (talk | contribs)   22:08, 27 January 2012

Never seen \brief before.

#Comment by MrBlueSky (talk | contribs)   19:20, 28 January 2012

It should also have been @brief, but it's indeed not used in any other files, so I'll remove it.

#Comment by Reedy (talk | contribs)   22:08, 27 January 2012

Would've been nice to give type hints to go with the member variable documentation

#Comment by Reedy (talk | contribs)   22:09, 27 January 2012

e.g.

	/**
	 * @var LockManagerGroup
	 */
 	protected static $instance = null;
#Comment by MrBlueSky (talk | contribs)   19:21, 28 January 2012

When 1.20 starts I will try to add a little workaround for the problem doxygen has with @var declarations. Next I'll add the type hints to this file and a bunch of others.

Status & tagging log