From f359cdf61462782743a87943938ef4cce78b2647 Mon Sep 17 00:00:00 2001 From: Siebrand Mazeland Date: Sun, 11 May 2014 00:52:21 +0200 Subject: [PATCH] Declare visibility on class properties of includes/parser/ Change-Id: If03a9bd5eb83be4d15f54e73f49f42540fb7d5fc --- includes/parser/CacheTime.php | 22 ++- includes/parser/DateFormatter.php | 37 ++++- includes/parser/LinkHolderArray.php | 16 +- includes/parser/Parser.php | 230 ++++++++++++++++++-------- includes/parser/ParserOptions.php | 211 ++++++++--------------- includes/parser/ParserOutput.php | 138 ++++++++++++---- includes/parser/Parser_DiffTest.php | 16 +- includes/parser/Preprocessor_DOM.php | 122 ++++++++------ includes/parser/Preprocessor_Hash.php | 89 ++++++---- 9 files changed, 542 insertions(+), 339 deletions(-) diff --git a/includes/parser/CacheTime.php b/includes/parser/CacheTime.php index 464bacdb8e..b44a20fba3 100644 --- a/includes/parser/CacheTime.php +++ b/includes/parser/CacheTime.php @@ -32,11 +32,23 @@ class CacheTime { */ public $mUsedOptions; - var $mVersion = Parser::VERSION, # Compatibility check - $mCacheTime = '', # Time when this object was generated, or -1 for uncacheable. Used in ParserCache. - $mCacheExpiry = null, # Seconds after which the object should expire, use 0 for uncachable. Used in ParserCache. - $mContainsOldMagic, # Boolean variable indicating if the input contained variables like {{CURRENTDAY}} - $mCacheRevisionId = null; # Revision ID that was parsed + /** @var string Compatibility check */ + protected $mVersion = Parser::VERSION; + + /** @var string Time when this object was generated, or -1 for uncacheable. Used in ParserCache. */ + protected $mCacheTime = ''; + + /** + * @var int Seconds after which the object should expire, use 0 for uncachable. + * Used in ParserCache. + */ + protected $mCacheExpiry = null; + + /** @var bool Boolean variable indicating if the input contained variables like {{CURRENTDAY}} */ + protected $mContainsOldMagic; + + /** @var int Revision ID that was parsed */ + protected $mCacheRevisionId = null; /** * @return string TS_MW timestamp diff --git a/includes/parser/DateFormatter.php b/includes/parser/DateFormatter.php index 3ddc9d4764..a6092a3fe3 100644 --- a/includes/parser/DateFormatter.php +++ b/includes/parser/DateFormatter.php @@ -27,11 +27,40 @@ * @ingroup Parser */ class DateFormatter { - var $mSource, $mTarget; - var $monthNames = '', $rxDM, $rxMD, $rxDMY, $rxYDM, $rxMDY, $rxYMD; + protected $mSource; - var $regexes, $pDays, $pMonths, $pYears; - var $rules, $xMonths, $preferences; + protected $mTarget; + + /** @var string */ + protected $monthNames = ''; + + /** @todo Are these unused? */ + private $rxDM; + private $rxMD; + private $rxDMY; + private $rxYDM; + private $rxMDY; + private $rxYMD; + + /** @var array */ + protected $regexes; + + /** @todo Are these unused? */ + private $pDays; + private $pMonths; + private $pYears; + + /** @var array */ + protected $rules; + + /** @var array */ + protected $xMonths; + + /** @var array */ + protected $preferences; + + /** @var bool */ + protected $mLinked; protected $lang; diff --git a/includes/parser/LinkHolderArray.php b/includes/parser/LinkHolderArray.php index 2f95af2eed..00c5a6c066 100644 --- a/includes/parser/LinkHolderArray.php +++ b/includes/parser/LinkHolderArray.php @@ -25,9 +25,19 @@ * @ingroup Parser */ class LinkHolderArray { - var $internals = array(), $interwikis = array(); - var $size = 0; - var $parent; + /** @var array */ + public $internals = array(); + + /** @var array */ + public $interwikis = array(); + + /** @var int */ + protected $size = 0; + + /** @var Parser */ + protected $parent; + + /** @var int */ protected $tempIdOffset; function __construct( $parent ) { diff --git a/includes/parser/Parser.php b/includes/parser/Parser.php index 227937ae24..9866008c57 100644 --- a/includes/parser/Parser.php +++ b/includes/parser/Parser.php @@ -119,103 +119,203 @@ class Parser { const TOC_START = ''; const TOC_END = ''; - # Persistent: - var $mTagHooks = array(); - var $mTransparentTagHooks = array(); - var $mFunctionHooks = array(); - var $mFunctionSynonyms = array( 0 => array(), 1 => array() ); - var $mFunctionTagHooks = array(); - var $mStripList = array(); - var $mDefaultStripList = array(); - var $mVarCache = array(); - var $mImageParams = array(); - var $mImageParamsMagicArray = array(); - var $mMarkerIndex = 0; - var $mFirstCall = true; + # Persistent - # Initialised by initialiseVariables() + /** @var array */ + public $mTagHooks = array(); - /** - * @var MagicWordArray - */ - var $mVariables; + /** @var array */ + public $mTransparentTagHooks = array(); + + /** @var array */ + public $mFunctionHooks = array(); + + /** @var array */ + protected $mFunctionSynonyms = array( 0 => array(), 1 => array() ); + + /** @var array */ + protected $mFunctionTagHooks = array(); + + /** @var array */ + protected $mStripList = array(); /** - * @var MagicWordArray + * @var array + * @todo Unused? */ - var $mSubstWords; - var $mConf, $mPreprocessor, $mExtLinkBracketedRegex, $mUrlProtocols; # Initialised in constructor + private $mDefaultStripList = array(); + + /** @var array */ + protected $mVarCache = array(); + + /** @var array */ + protected $mImageParams = array(); + + /** @var array */ + protected $mImageParamsMagicArray = array(); + + /** @var int */ + public $mMarkerIndex = 0; + + /** @var bool */ + protected $mFirstCall = true; + + # Initialised by initialiseVariables() + + /** @var MagicWordArray */ + public $mVariables; + + /** @var MagicWordArray */ + protected $mSubstWords; + + # Initialised in constructor + + /** @var array */ + protected $mConf; + + /** @var Parser */ + public $mPreprocessor; + + /** @var string */ + protected $mExtLinkBracketedRegex; + + /** @var string */ + protected $mUrlProtocols; # Cleared with clearState(): - /** - * @var ParserOutput - */ - var $mOutput; - var $mAutonumber, $mDTopen; + + /** @var ParserOutput */ + public $mOutput; + + /** @var int */ + protected $mAutonumber; + + /** @var bool */ + protected $mDTopen; + + /** @var StripState */ + public $mStripState; /** - * @var StripState + * @var array + * @todo Unused? */ - var $mStripState; + private $mIncludeCount; - var $mIncludeCount, $mArgStack, $mLastSection, $mInPre; /** - * @var LinkHolderArray + * @var bool + * @todo Unused? */ - var $mLinkHolders; + private $mArgStack; - var $mLinkID; - var $mIncludeSizes, $mPPNodeCount, $mGeneratedPPNodeCount, $mHighestExpansionDepth; - var $mDefaultSort; - var $mTplExpandCache; # empty-frame expansion cache - var $mTplRedirCache, $mTplDomCache, $mHeadings, $mDoubleUnderscores; - var $mExpensiveFunctionCount; # number of expensive parser function calls - var $mShowToc, $mForceTocPosition; + /** @var string */ + protected $mLastSection; - /** - * @var User - */ - var $mUser; # User object; only used when doing pre-save transform + /** @var bool */ + protected $mInPre; + + /** @var LinkHolderArray */ + protected $mLinkHolders; + + /** @var int */ + protected $mLinkID; + + /** @var array */ + protected $mIncludeSizes; + + /** @var int */ + public $mPPNodeCount; + + /** @var int */ + public $mGeneratedPPNodeCount; + + /** @var int */ + public $mHighestExpansionDepth; + + /** @var bool|string */ + protected $mDefaultSort; + + /** @var array Empty-frame expansion cache */ + protected $mTplExpandCache; + + /** @var array */ + protected $mTplRedirCache; + + /** @var array */ + protected $mTplDomCache; + + /** @var array */ + public $mHeadings; + + /** @var array */ + protected $mDoubleUnderscores; + + /** @var int Number of expensive parser function calls */ + protected $mExpensiveFunctionCount; + + /** @var bool */ + protected $mShowToc; + + /** @var bool */ + protected $mForceTocPosition; + + /** @var User User object; only used when doing pre-save transform */ + protected $mUser; # Temporary # These are variables reset at least once per parse regardless of $clearState - /** - * @var ParserOptions - */ - var $mOptions; + /** @var ParserOptions */ + public $mOptions; - /** - * @var Title - */ - var $mTitle; # Title context, used for self-link rendering and similar things - var $mOutputType; # Output type, one of the OT_xxx constants - var $ot; # Shortcut alias, see setOutputType() - var $mRevisionObject; # The revision object of the specified revision ID - var $mRevisionId; # ID to display in {{REVISIONID}} tags - var $mRevisionTimestamp; # The timestamp of the specified revision ID - var $mRevisionUser; # User to display in {{REVISIONUSER}} tag - var $mRevisionSize; # Size to display in {{REVISIONSIZE}} variable - var $mRevIdForTs; # The revision ID which was used to fetch the timestamp - var $mInputSize = false; # For {{PAGESIZE}} on current page. + /** @var Title Title context, used for self-link rendering and similar things */ + public $mTitle; + + /** @var array Shortcut alias, see setOutputType() */ + public $ot; + + /** @var string The timestamp of the specified revision ID */ + public $mRevisionTimestamp; + + /** @var string */ + public $mUniqPrefix; /** - * @var string + * @var boolean Recursive call protection. + * This variable should be treated as if it were private. */ - var $mUniqPrefix; + public $mInParse = false; + + /** @var int Output type, one of the OT_xxx constants */ + protected $mOutputType; + + /** @var Revision The revision object of the specified revision ID */ + protected $mRevisionObject; + + /** @var int ID to display in {{REVISIONID}} tags */ + protected $mRevisionId; + + /** @var string User to display in {{REVISIONUSER}} tag */ + protected $mRevisionUser; + + /** @var int Size to display in {{REVISIONSIZE}} variable */ + protected $mRevisionSize; + + /** @var bool|int For {{PAGESIZE}} on current page. */ + protected $mInputSize = false; /** * @var array Array with the language name of each language link (i.e. the * interwiki prefix) in the key, value arbitrary. Used to avoid sending * duplicate language links to the ParserOutput. */ - var $mLangLinkLanguages; + protected $mLangLinkLanguages; /** - * @var boolean Recursive call protection. - * This variable should be treated as if it were private. + * @var int The revision ID which was used to fetch the timestamp + * @todo Unused? */ - public $mInParse = false; + private $mRevIdForTs; /** * Constructor diff --git a/includes/parser/ParserOptions.php b/includes/parser/ParserOptions.php index 7c84b6734b..ba85a669aa 100644 --- a/includes/parser/ParserOptions.php +++ b/includes/parser/ParserOptions.php @@ -29,187 +29,120 @@ * @ingroup Parser */ class ParserOptions { + /** @var bool Parsing the page for a "preview" operation? */ + public $mIsPreview = false; - /** - * Interlanguage links are removed and returned in an array - */ - var $mInterwikiMagic; + /** @var bool Interlanguage links are removed and returned in an array */ + protected $mInterwikiMagic; - /** - * Allow external images inline? - */ - var $mAllowExternalImages; + /** @var bool Allow external images inline? */ + protected $mAllowExternalImages; - /** - * If not, any exception? - */ - var $mAllowExternalImagesFrom; + /** @var string|array If not, any exception? */ + protected $mAllowExternalImagesFrom; - /** - * If not or it doesn't match, should we check an on-wiki whitelist? - */ - var $mEnableImageWhitelist; + /** @var bool If not or it doesn't match, should we check an on-wiki whitelist? */ + protected $mEnableImageWhitelist; - /** - * Date format index - */ - var $mDateFormat = null; + /** @var string Date format index */ + protected $mDateFormat = null; - /** - * Create "edit section" links? - */ - var $mEditSection = true; + /** @var bool Create "edit section" links? */ + protected $mEditSection = true; - /** - * Allow inclusion of special pages? - */ - var $mAllowSpecialInclusion; + /** @var bool Allow inclusion of special pages? */ + protected $mAllowSpecialInclusion; - /** - * Use tidy to cleanup output HTML? - */ - var $mTidy = false; + /** @var bool Use tidy to cleanup output HTML? */ + protected $mTidy = false; /** - * Which lang to call for PLURAL and GRAMMAR + * @var bool Which lang to call for PLURAL and GRAMMAR + * @todo FIXME: This comment doesn't appear to be correct. + * Should be this? Whether this is an interface message. */ - var $mInterfaceMessage = false; + protected $mInterfaceMessage = false; - /** - * Overrides $mInterfaceMessage with arbitrary language - */ - var $mTargetLanguage = null; + /** @var string|Language Overrides $mInterfaceMessage with arbitrary language */ + protected $mTargetLanguage = null; - /** - * Maximum size of template expansions, in bytes - */ - var $mMaxIncludeSize; + /** @var int Maximum size of template expansions, in bytes */ + protected $mMaxIncludeSize; - /** - * Maximum number of nodes touched by PPFrame::expand() - */ - var $mMaxPPNodeCount; + /** @var int Maximum number of nodes touched by PPFrame::expand() */ + protected $mMaxPPNodeCount; - /** - * Maximum number of nodes generated by Preprocessor::preprocessToObj() - */ - var $mMaxGeneratedPPNodeCount; + /** @var int Maximum number of nodes generated by Preprocessor::preprocessToObj() */ + protected $mMaxGeneratedPPNodeCount; - /** - * Maximum recursion depth in PPFrame::expand() - */ - var $mMaxPPExpandDepth; + /** @var int Maximum recursion depth in PPFrame::expand() */ + protected $mMaxPPExpandDepth; - /** - * Maximum recursion depth for templates within templates - */ - var $mMaxTemplateDepth; + /** @var int Maximum recursion depth for templates within templates */ + protected $mMaxTemplateDepth; - /** - * Maximum number of calls per parse to expensive parser functions - */ - var $mExpensiveParserFunctionLimit; + /** @var int Maximum number of calls per parse to expensive parser functions */ + protected $mExpensiveParserFunctionLimit; - /** - * Remove HTML comments. ONLY APPLIES TO PREPROCESS OPERATIONS - */ - var $mRemoveComments = true; + /** @var bool Remove HTML comments. ONLY APPLIES TO PREPROCESS OPERATIONS */ + protected $mRemoveComments = true; - /** - * Callback for template fetching. Used as first argument to call_user_func(). - */ - var $mTemplateCallback = - array( 'Parser', 'statelessFetchTemplate' ); + /** @var array Callback for template fetching. Used as first argument to call_user_func(). */ + protected $mTemplateCallback = array( 'Parser', 'statelessFetchTemplate' ); - /** - * Enable limit report in an HTML comment on output - */ - var $mEnableLimitReport = false; + /** @var bool Enable limit report in an HTML comment on output */ + protected $mEnableLimitReport = false; - /** - * Timestamp used for {{CURRENTDAY}} etc. - */ - var $mTimestamp; + /** @var string Timestamp used for {{CURRENTDAY}} etc. */ + protected $mTimestamp; - /** - * Target attribute for external links - */ - var $mExternalLinkTarget; + /** @var bool|string Target attribute for external links */ + protected $mExternalLinkTarget; /** - * Clean up signature texts? + * @var bool Clean up signature texts? * * 1) Strip ~~~, ~~~~ and ~~~~~ out of signatures * 2) Substitute all transclusions */ - var $mCleanSignatures; + protected $mCleanSignatures; - /** - * Transform wiki markup when saving the page? - */ - var $mPreSaveTransform = true; + /** @var bool Transform wiki markup when saving the page? */ + protected $mPreSaveTransform = true; - /** - * Whether content conversion should be disabled - */ - var $mDisableContentConversion; + /** @var bool Whether content conversion should be disabled */ + protected $mDisableContentConversion; - /** - * Whether title conversion should be disabled - */ - var $mDisableTitleConversion; + /** @var bool Whether title conversion should be disabled */ + protected $mDisableTitleConversion; - /** - * Automatically number headings? - */ - var $mNumberHeadings; + /** @var string Automatically number headings? */ + protected $mNumberHeadings; - /** - * Thumb size preferred by the user. - */ - var $mThumbSize; + /** @var string Thumb size preferred by the user. */ + protected $mThumbSize; - /** - * Maximum article size of an article to be marked as "stub" - */ - private $mStubThreshold; + /** @var Language Language object of the User language. */ + protected $mUserLang; - /** - * Language object of the User language. - */ - var $mUserLang; + /** @var User Stored user object */ + protected $mUser; - /** - * @var User - * Stored user object - */ - var $mUser; + /** @var bool Parsing the page for a "preview" operation on a single section? */ + protected $mIsSectionPreview = false; - /** - * Parsing the page for a "preview" operation? - */ - var $mIsPreview = false; + /** @var bool Parsing the printable version of the page? */ + protected $mIsPrintable = false; - /** - * Parsing the page for a "preview" operation on a single section? - */ - var $mIsSectionPreview = false; + /** @var string Extra key that should be present in the caching key. */ + protected $mExtraKey = ''; - /** - * Parsing the printable version of the page? - */ - var $mIsPrintable = false; - - /** - * Extra key that should be present in the caching key. - */ - var $mExtraKey = ''; - - /** - * Function to be called when an option is accessed. - */ + /** @var callable Function to be called when an option is accessed. */ protected $onAccessCallback = null; + /** @var int Maximum article size of an article to be marked as "stub" */ + private $mStubThreshold; + function getInterwikiMagic() { return $this->mInterwikiMagic; } function getAllowExternalImages() { return $this->mAllowExternalImages; } function getAllowExternalImagesFrom() { return $this->mAllowExternalImagesFrom; } diff --git a/includes/parser/ParserOutput.php b/includes/parser/ParserOutput.php index b7cc490ff8..324a2dddc4 100644 --- a/includes/parser/ParserOutput.php +++ b/includes/parser/ParserOutput.php @@ -22,40 +22,110 @@ * @ingroup Parser */ class ParserOutput extends CacheTime { - var $mText, # The output text - $mLanguageLinks, # List of the full text of language links, in the order they appear - $mCategories, # Map of category names to sort keys - $mTitleText, # title text of the chosen language variant - $mLinks = array(), # 2-D map of NS/DBK to ID for the links in the document. ID=zero for broken. - $mTemplates = array(), # 2-D map of NS/DBK to ID for the template references. ID=zero for broken. - $mTemplateIds = array(), # 2-D map of NS/DBK to rev ID for the template references. ID=zero for broken. - $mImages = array(), # DB keys of the images used, in the array key only - $mFileSearchOptions = array(), # DB keys of the images used mapped to sha1 and MW timestamp - $mExternalLinks = array(), # External link URLs, in the key only - $mInterwikiLinks = array(), # 2-D map of prefix/DBK (in keys only) for the inline interwiki links in the document. - $mNewSection = false, # Show a new section link? - $mHideNewSection = false, # Hide the new section link? - $mNoGallery = false, # No gallery on category page? (__NOGALLERY__) - $mHeadItems = array(), # Items to put in the section - $mModules = array(), # Modules to be loaded by the resource loader - $mModuleScripts = array(), # Modules of which only the JS will be loaded by the resource loader - $mModuleStyles = array(), # Modules of which only the CSSS will be loaded by the resource loader - $mModuleMessages = array(), # Modules of which only the messages will be loaded by the resource loader - $mJsConfigVars = array(), # JavaScript config variable for mw.config combined with this page - $mOutputHooks = array(), # Hook tags as per $wgParserOutputHooks - $mWarnings = array(), # Warning text to be returned to the user. Wikitext formatted, in the key only - $mSections = array(), # Table of contents - $mEditSectionTokens = false, # prefix/suffix markers if edit sections were output as tokens - $mProperties = array(), # Name/value pairs to be cached in the DB - $mTOCHTML = '', # HTML of the TOC - $mTimestamp, # Timestamp of the revision - $mTOCEnabled = true; # Whether TOC should be shown, can't override __NOTOC__ - private $mIndexPolicy = ''; # 'index' or 'noindex'? Any other value will result in no change. - private $mAccessedOptions = array(); # List of ParserOptions (stored in the keys) - private $mSecondaryDataUpdates = array(); # List of DataUpdate, used to save info from the page somewhere else. - private $mExtensionData = array(); # extra data used by extensions - private $mLimitReportData = array(); # Parser limit report data - private $mParseStartTime = array(); # Timestamps for getTimeSinceStart() + /** @var string The output text */ + public $mText; + + /** @var array List of the full text of language links; in the order they appear */ + public $mLanguageLinks; + + /** @var array Map of category names to sort keys */ + public $mCategories; + + /** @var array DB keys of the images used; in the array key only */ + public $mImages = array(); + + /** @var array Modules to be loaded by the resource loader */ + public $mModules = array(); + + /** @var array Name/value pairs to be cached in the DB */ + public $mProperties = array(); + + /** @var string Title text of the chosen language variant */ + protected $mTitleText; + + /** @var array 2-D map of NS/DBK to ID for the links in the document. ID=zero for broken. */ + protected $mLinks = array(); + + /** @var array 2-D map of NS/DBK to ID for the template references. ID=zero for broken. */ + protected $mTemplates = array(); + + /** @var array 2-D map of NS/DBK to rev ID for the template references. ID=zero for broken. */ + protected $mTemplateIds = array(); + + /** @var array DB keys of the images used mapped to sha1 and MW timestamp */ + protected $mFileSearchOptions = array(); + + /** @var array External link URLs; in the key only */ + protected $mExternalLinks = array(); + + /** + * @var array 2-D map of prefix/DBK (in keys only) for the inline interwiki + * links in the document. + */ + protected $mInterwikiLinks = array(); + + /** @var bool Show a new section link? */ + protected $mNewSection = false; + + /** @var bool Hide the new section link? */ + protected $mHideNewSection = false; + + /** @var bool No gallery on category page? (__NOGALLERY__) */ + public $mNoGallery = false; + + /** @var array Items to put in the section */ + protected $mHeadItems = array(); + + /** @var array Modules of which only the JS will be loaded by the resource loader */ + protected $mModuleScripts = array(); + + /** @var array Modules of which only the CSSS will be loaded by the resource loader */ + protected $mModuleStyles = array(); + + /** @var array Modules of which only the messages will be loaded by the resource loader */ + protected $mModuleMessages = array(); + + /** @var array JavaScript config variable for mw.config combined with this page */ + protected $mJsConfigVars = array(); + + /** @var array Hook tags as per $wgParserOutputHooks */ + protected $mOutputHooks = array(); + + /** @var array Warning text to be returned to the user. Wikitext formatted; in the key only */ + protected $mWarnings = array(); + + /** @var array Table of contents */ + protected $mSections = array(); + + /** @var bool Prefix/suffix markers if edit sections were output as tokens */ + protected $mEditSectionTokens = false; + + /** @var string HTML of the TOC */ + protected $mTOCHTML = ''; + + /** @var string Timestamp of the revision */ + protected $mTimestamp; + + /** @var bool Whether TOC should be shown, can't override __NOTOC__ */ + protected $mTOCEnabled = true; + + /** @var string 'index' or 'noindex'? Any other value will result in no change. */ + private $mIndexPolicy = ''; + + /** @var array List of ParserOptions (stored in the keys) */ + private $mAccessedOptions = array(); + + /** @var array List of DataUpdate, used to save info from the page somewhere else. */ + private $mSecondaryDataUpdates = array(); + + /** @var array Extra data used by extensions */ + private $mExtensionData = array(); + + /** @var array Parser limit report data */ + private $mLimitReportData = array(); + + /** @var array Timestamps for getTimeSinceStart() */ + private $mParseStartTime = array(); const EDITSECTION_REGEX = '#<(?:mw:)?editsection page="(.*?)" section="(.*?)"(?:/>|>(.*?)())#'; diff --git a/includes/parser/Parser_DiffTest.php b/includes/parser/Parser_DiffTest.php index 920b6f6621..4d821cada5 100644 --- a/includes/parser/Parser_DiffTest.php +++ b/includes/parser/Parser_DiffTest.php @@ -24,12 +24,18 @@ /** * @ingroup Parser */ -class Parser_DiffTest -{ - var $parsers, $conf; - var $shortOutput = false; +class Parser_DiffTest { + /** @var array */ + protected $parsers; - var $dtUniqPrefix; + /** @var array */ + protected $conf; + + /** @var bool */ + protected $shortOutput = false; + + /** @var string */ + protected $dtUniqPrefix; function __construct( $conf ) { if ( !isset( $conf['parsers'] ) ) { diff --git a/includes/parser/Preprocessor_DOM.php b/includes/parser/Preprocessor_DOM.php index df3cbeb76e..c5f482d2fd 100644 --- a/includes/parser/Preprocessor_DOM.php +++ b/includes/parser/Preprocessor_DOM.php @@ -25,13 +25,10 @@ * @ingroup Parser */ class Preprocessor_DOM implements Preprocessor { + /** @var Parser */ + public $parser; - /** - * @var Parser - */ - var $parser; - - var $memoryLimit; + protected $memoryLimit; const CACHE_VERSION = 1; @@ -736,16 +733,22 @@ class Preprocessor_DOM implements Preprocessor { * @ingroup Parser */ class PPDStack { - var $stack, $rootAccum; + /** @var array */ + public $stack; - /** - * @var PPDStack - */ - var $top; - var $out; - var $elementClass = 'PPDStackElement'; + /** @var string */ + public $rootAccum; + + /** @var bool|PPDStack */ + public $top; + + /** @var */ + public $out; + + /** @var string */ + protected $elementClass = 'PPDStackElement'; - static $false = false; + protected static $false = false; function __construct() { $this->stack = array(); @@ -825,13 +828,26 @@ class PPDStack { * @ingroup Parser */ class PPDStackElement { - var $open, // Opening character (\n for heading) - $close, // Matching closing character - $count, // Number of opening characters found (number of "=" for heading) - $parts, // Array of PPDPart objects describing pipe-separated parts. - $lineStart; // True if the open char appeared at the start of the input line. Not set for headings. + /** @var string Opening character (\n for heading) */ + public $open; - var $partClass = 'PPDPart'; + /** @var string Matching closing character */ + public $close; + + /** @var int Number of opening characters found (number of "=" for heading) */ + public $count; + + /** @var array PPDPart objects describing pipe-separated parts. */ + public $parts; + + /** + * @var bool True if the open char appeared at the start of the input line. + * Not set for headings. + */ + public $lineStart; + + /** @var string */ + protected $partClass = 'PPDPart'; function __construct( $data = array() ) { $class = $this->partClass; @@ -899,7 +915,8 @@ class PPDStackElement { * @ingroup Parser */ class PPDPart { - var $out; // Output accumulator string + /** @var string */ + public $out; // Optional member variables: // eqpos Position of equals sign in output accumulator @@ -916,34 +933,29 @@ class PPDPart { * @ingroup Parser */ class PPFrame_DOM implements PPFrame { + /** @var array */ + public $titleCache; /** - * @var Preprocessor + * @var array Hashtable listing templates which are disallowed for expansion + * in this frame, having been encountered previously in parent frames. */ - var $preprocessor; + public $loopCheckHash; /** - * @var Parser + * @var int Recursion depth of this frame, top = 0. + * Note that this is NOT the same as expansion depth in expand() */ - var $parser; + public $depth; - /** - * @var Title - */ - var $title; - var $titleCache; + /** @var Preprocessor */ + protected $preprocessor; - /** - * Hashtable listing templates which are disallowed for expansion in this frame, - * having been encountered previously in parent frames. - */ - var $loopCheckHash; + /** @var Parser */ + protected $parser; - /** - * Recursion depth of this frame, top = 0 - * Note that this is NOT the same as expansion depth in expand() - */ - var $depth; + /** @var Title */ + protected $title; /** * Construct a new preprocessor frame. @@ -1433,13 +1445,20 @@ class PPFrame_DOM implements PPFrame { * @ingroup Parser */ class PPTemplateFrame_DOM extends PPFrame_DOM { - var $numberedArgs, $namedArgs; + /** @var PPFrame_DOM */ + public $parent; - /** - * @var PPFrame_DOM - */ - var $parent; - var $numberedExpansionCache, $namedExpansionCache; + /** @var array */ + protected $numberedArgs; + + /** @var array */ + protected $namedArgs; + + /** @var array */ + protected $numberedExpansionCache; + + /** @var string[] */ + protected $namedExpansionCache; /** * @param Preprocessor $preprocessor @@ -1564,7 +1583,7 @@ class PPTemplateFrame_DOM extends PPFrame_DOM { * @ingroup Parser */ class PPCustomFrame_DOM extends PPFrame_DOM { - var $args; + protected $args; function __construct( $preprocessor, $args ) { parent::__construct( $preprocessor ); @@ -1610,12 +1629,11 @@ class PPCustomFrame_DOM extends PPFrame_DOM { * @ingroup Parser */ class PPNode_DOM implements PPNode { + /** @var DOMElement */ + public $node; - /** - * @var DOMElement - */ - var $node; - var $xpath; + /** @var DOMXPath */ + protected $xpath; function __construct( $node, $xpath = false ) { $this->node = $node; diff --git a/includes/parser/Preprocessor_Hash.php b/includes/parser/Preprocessor_Hash.php index aebb98e5b8..27577669ec 100644 --- a/includes/parser/Preprocessor_Hash.php +++ b/includes/parser/Preprocessor_Hash.php @@ -28,10 +28,8 @@ * @ingroup Parser */ class Preprocessor_Hash implements Preprocessor { - /** - * @var Parser - */ - var $parser; + /** @var Parser */ + public $parser; const CACHE_VERSION = 1; @@ -805,7 +803,9 @@ class PPDPart_Hash extends PPDPart { * @ingroup Parser */ class PPDAccum_Hash { - var $firstNode, $lastNode; + public $firstNode; + + public $lastNode; function __construct() { $this->firstNode = $this->lastNode = false; @@ -873,34 +873,30 @@ class PPDAccum_Hash { * @ingroup Parser */ class PPFrame_Hash implements PPFrame { - /** - * @var Parser + * @var int Recursion depth of this frame, top = 0 + * Note that this is NOT the same as expansion depth in expand() */ - var $parser; + public $depth; - /** - * @var Preprocessor - */ - var $preprocessor; + /** @var Parser */ + protected $parser; - /** - * @var Title - */ - var $title; - var $titleCache; + /** @var Preprocessor */ + protected $preprocessor; - /** - * Hashtable listing templates which are disallowed for expansion in this frame, - * having been encountered previously in parent frames. - */ - var $loopCheckHash; + /** @var Title */ + protected $title; + + /** @var array */ + protected $titleCache; /** - * Recursion depth of this frame, top = 0 - * Note that this is NOT the same as expansion depth in expand() + * @var array Hashtable listing templates which are disallowed for + * expansion in this frame, having been encountered previously in + * parent frames. */ - var $depth; + protected $loopCheckHash; /** * Construct a new preprocessor frame. @@ -1351,8 +1347,20 @@ class PPFrame_Hash implements PPFrame { * @ingroup Parser */ class PPTemplateFrame_Hash extends PPFrame_Hash { - var $numberedArgs, $namedArgs, $parent; - var $numberedExpansionCache, $namedExpansionCache; + /** @var array */ + protected $numberedArgs; + + /** @var array */ + protected $namedArgs; + + /** @var bool|PPFrame */ + protected $parent; + + /** @var array */ + protected $numberedExpansionCache; + + /** @var */ + protected $namedExpansionCache; /** * @param Preprocessor $preprocessor @@ -1498,7 +1506,8 @@ class PPTemplateFrame_Hash extends PPFrame_Hash { * @ingroup Parser */ class PPCustomFrame_Hash extends PPFrame_Hash { - var $args; + /** @var array */ + protected $args; function __construct( $preprocessor, $args ) { parent::__construct( $preprocessor ); @@ -1548,7 +1557,13 @@ class PPCustomFrame_Hash extends PPFrame_Hash { * @ingroup Parser */ class PPNode_Hash_Tree implements PPNode { - var $name, $firstChild, $lastChild, $nextSibling; + public $name; + + public $firstChild; + + public $lastChild; + + public $nextSibling; function __construct( $name ) { $this->name = $name; @@ -1770,7 +1785,9 @@ class PPNode_Hash_Tree implements PPNode { * @ingroup Parser */ class PPNode_Hash_Text implements PPNode { - var $value, $nextSibling; + public $value; + + public $nextSibling; function __construct( $value ) { if ( is_object( $value ) ) { @@ -1802,7 +1819,9 @@ class PPNode_Hash_Text implements PPNode { * @ingroup Parser */ class PPNode_Hash_Array implements PPNode { - var $value, $nextSibling; + public $value; + + public $nextSibling; function __construct( $value ) { $this->value = $value; @@ -1838,7 +1857,13 @@ class PPNode_Hash_Array implements PPNode { * @ingroup Parser */ class PPNode_Hash_Attr implements PPNode { - var $name, $value, $nextSibling; + /** @var string */ + public $name; + + /** @var string */ + public $value; + + public $nextSibling; function __construct( $name, $value ) { $this->name = $name; -- 2.20.1