Code Coverage
 
Classes and Traits
Functions and Methods
Lines
Total
0.00% covered (danger)
0.00%
0 / 1
50.34% covered (warning)
50.34%
74 / 147
CRAP
81.62% covered (warning)
81.62%
1940 / 2377
Parser
0.00% covered (danger)
0.00%
0 / 1
50.34% covered (warning)
50.34%
74 / 147
4998.15
81.62% covered (warning)
81.62%
1940 / 2377
 __construct
0.00% covered (danger)
0.00%
0 / 1
9.01
94.87% covered (success)
94.87%
37 / 39
 __destruct
100.00% covered (success)
100.00%
1 / 1
3
100.00% covered (success)
100.00%
5 / 5
 __clone
100.00% covered (success)
100.00%
1 / 1
2
100.00% covered (success)
100.00%
7 / 7
 firstCallInit
100.00% covered (success)
100.00%
1 / 1
2
100.00% covered (success)
100.00%
8 / 8
 clearState
100.00% covered (success)
100.00%
1 / 1
3
100.00% covered (success)
100.00%
32 / 32
 resetOutput
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
3 / 3
 parse
0.00% covered (danger)
0.00%
0 / 1
13.12
91.07% covered (success)
91.07%
51 / 56
 makeLimitReport
0.00% covered (danger)
0.00%
0 / 1
156
0.00% covered (danger)
0.00%
0 / 63
 recursiveTagParse
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
4 / 4
 recursiveTagParseFully
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
3 / 3
 parseExtensionTagAsTopLevelDoc
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 4
 preprocess
0.00% covered (danger)
0.00%
0 / 1
3.01
90.00% covered (success)
90.00%
9 / 10
 recursivePreprocess
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 3
 getPreloadText
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
9 / 9
 setUser
100.00% covered (success)
100.00%
1 / 1
2
100.00% covered (success)
100.00%
2 / 2
 setTitle
0.00% covered (danger)
0.00%
0 / 1
3.33
66.67% covered (warning)
66.67%
4 / 6
 getTitle
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
1 / 1
 Title
0.00% covered (danger)
0.00%
0 / 1
6
0.00% covered (danger)
0.00%
0 / 2
 getOutputType
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 1
 setOutputType
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
4 / 4
 OutputType
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 2
 getOutput
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
1 / 1
 getOptions
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
1 / 1
 setOptions
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
2 / 2
 Options
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 2
 nextLinkID
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
1 / 1
 setLinkID
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 2
 getFunctionLang
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
1 / 1
 getTargetLanguage
0.00% covered (danger)
0.00%
0 / 1
3.04
83.33% covered (warning)
83.33%
5 / 6
 getUser
100.00% covered (success)
100.00%
1 / 1
2
100.00% covered (success)
100.00%
3 / 3
 getPreprocessor
100.00% covered (success)
100.00%
1 / 1
2
100.00% covered (success)
100.00%
3 / 3
 getLinkRenderer
100.00% covered (success)
100.00%
1 / 1
2
100.00% covered (success)
100.00%
5 / 5
 getMagicWordFactory
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
1 / 1
 getContentLanguage
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
1 / 1
 getBadFileLookup
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
1 / 1
 extractTagsAndParams
0.00% covered (danger)
0.00%
0 / 1
56
0.00% covered (danger)
0.00%
0 / 36
 getStripList
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
1 / 1
 getStripState
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 1
 insertStripItem
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
4 / 4
 handleTables
0.00% covered (danger)
0.00%
0 / 1
33
99.14% covered (success)
99.14%
115 / 116
 internalParse
0.00% covered (danger)
0.00%
0 / 1
4.00
93.55% covered (success)
93.55%
29 / 31
 getTargetLanguageConverter
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
2 / 2
 getContentLanguageConverter
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
2 / 2
 getHookContainer
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
1 / 1
 getHookRunner
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 1
 internalParseHalfParsed
100.00% covered (success)
100.00%
1 / 1
6
100.00% covered (success)
100.00%
17 / 17
 handleMagicLinks
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
15 / 15
 magicLinkCallback
0.00% covered (danger)
0.00%
0 / 1
16
95.74% covered (success)
95.74%
45 / 47
 makeFreeExternalLink
100.00% covered (success)
100.00%
1 / 1
9
100.00% covered (success)
100.00%
31 / 31
 handleHeadings
100.00% covered (success)
100.00%
1 / 1
2
100.00% covered (success)
100.00%
4 / 4
 handleAllQuotes
100.00% covered (success)
100.00%
1 / 1
2
100.00% covered (success)
100.00%
6 / 6
 doQuotes
0.00% covered (danger)
0.00%
0 / 1
46
98.28% covered (success)
98.28%
114 / 116
 handleExternalLinks
0.00% covered (danger)
0.00%
0 / 1
7.01
93.75% covered (success)
93.75%
30 / 32
 getExternalLinkRel
100.00% covered (success)
100.00%
1 / 1
5
100.00% covered (success)
100.00%
6 / 6
 getExternalLinkAttribs
100.00% covered (success)
100.00%
1 / 1
4
100.00% covered (success)
100.00%
11 / 11
 normalizeLinkUrl
100.00% covered (success)
100.00%
1 / 1
8
100.00% covered (success)
100.00%
32 / 32
 normalizeUrlComponent
100.00% covered (success)
100.00%
1 / 1
4
100.00% covered (success)
100.00%
7 / 7
 maybeMakeExternalImage
0.00% covered (danger)
0.00%
0 / 1
61.43
46.43% covered (danger)
46.43%
13 / 28
 handleInternalLinks
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
2 / 2
 handleInternalLinks2
0.00% covered (danger)
0.00%
0 / 1
51
96.73% covered (success)
96.73%
148 / 153
 makeKnownLinkHolder
0.00% covered (danger)
0.00%
0 / 1
2.02
83.33% covered (warning)
83.33%
5 / 6
 armorLinks
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
2 / 2
 doBlockLevels
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 2
 expandMagicVariable
0.00% covered (danger)
0.00%
0 / 1
15.85
43.48% covered (danger)
43.48%
10 / 23
 initializeVariables
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
5 / 5
 preprocessToDom
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
2 / 2
 replaceVariables
0.00% covered (danger)
0.00%
0 / 1
7.05
69.23% covered (warning)
69.23%
9 / 13
 limitationWarn
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
5 / 5
 braceSubstitution
0.00% covered (danger)
0.00%
0 / 1
85.22
86.81% covered (warning)
86.81%
158 / 182
 callParserFunction
0.00% covered (danger)
0.00%
0 / 1
17
95.00% covered (success)
95.00%
38 / 40
 getTemplateDom
100.00% covered (success)
100.00%
1 / 1
5
100.00% covered (success)
100.00%
18 / 18
 fetchCurrentRevisionOfTitle
0.00% covered (danger)
0.00%
0 / 1
6
0.00% covered (danger)
0.00%
0 / 5
 fetchCurrentRevisionRecordOfTitle
0.00% covered (danger)
0.00%
0 / 1
4.01
90.91% covered (success)
90.91%
10 / 11
 isCurrentRevisionOfTitleCached
100.00% covered (success)
100.00%
1 / 1
2
100.00% covered (success)
100.00%
2 / 2
 statelessFetchRevision
0.00% covered (danger)
0.00%
0 / 1
6
0.00% covered (danger)
0.00%
0 / 5
 statelessFetchRevisionRecord
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
4 / 4
 fetchTemplateAndTitle
0.00% covered (danger)
0.00%
0 / 1
13.04
57.14% covered (warning)
57.14%
12 / 21
 fetchTemplate
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 2
 statelessFetchTemplate
0.00% covered (danger)
0.00%
0 / 1
27.10
76.00% covered (warning)
76.00%
57 / 75
 fetchFileAndTitle
100.00% covered (success)
100.00%
1 / 1
5
100.00% covered (success)
100.00%
8 / 8
 fetchFileNoRegister
0.00% covered (danger)
0.00%
0 / 1
3.21
71.43% covered (warning)
71.43%
5 / 7
 interwikiTransclude
0.00% covered (danger)
0.00%
0 / 1
110
0.00% covered (danger)
0.00%
0 / 34
 argSubstitution
0.00% covered (danger)
0.00%
0 / 1
12.87
81.82% covered (warning)
81.82%
18 / 22
 extensionSubstitution
0.00% covered (danger)
0.00%
0 / 1
27.87
81.13% covered (warning)
81.13%
43 / 53
 incrementIncludeSize
100.00% covered (success)
100.00%
1 / 1
2
100.00% covered (success)
100.00%
4 / 4
 incrementExpensiveFunctionCount
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
2 / 2
 handleDoubleUnderscore
0.00% covered (danger)
0.00%
0 / 1
14.25
75.00% covered (warning)
75.00%
18 / 24
 addTrackingCategory
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
1 / 1
 finalizeHeadings
0.00% covered (danger)
0.00%
0 / 1
60
96.95% covered (success)
96.95%
191 / 197
 preSaveTransform
100.00% covered (success)
100.00%
1 / 1
3
100.00% covered (success)
100.00%
12 / 12
 pstPass2
100.00% covered (success)
100.00%
1 / 1
5
100.00% covered (success)
100.00%
30 / 30
 getUserSig
0.00% covered (danger)
0.00%
0 / 1
31.32
44.83% covered (danger)
44.83%
13 / 29
 validateSig
0.00% covered (danger)
0.00%
0 / 1
6
0.00% covered (danger)
0.00%
0 / 1
 cleanSig
100.00% covered (success)
100.00%
1 / 1
4
100.00% covered (success)
100.00%
17 / 17
 cleanSigInSig
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
2 / 2
 startExternalParse
0.00% covered (danger)
0.00%
0 / 1
3.14
75.00% covered (warning)
75.00%
3 / 4
 startParse
100.00% covered (success)
100.00%
1 / 1
3
100.00% covered (success)
100.00%
6 / 6
 transformMsg
0.00% covered (danger)
0.00%
0 / 1
3.24
70.00% covered (warning)
70.00%
7 / 10
 setHook
100.00% covered (success)
100.00%
1 / 1
3
100.00% covered (success)
100.00%
8 / 8
 clearTagHooks
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 4
 setFunctionHook
0.00% covered (danger)
0.00%
0 / 1
6.01
93.75% covered (success)
93.75%
15 / 16
 getFunctionHooks
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 2
 setFunctionTagHook
100.00% covered (success)
100.00%
1 / 1
3
100.00% covered (success)
100.00%
9 / 9
 replaceLinkHolders
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 2
 replaceLinkHoldersPrivate
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
2 / 2
 replaceLinkHoldersText
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
1 / 1
 renderImageGallery
0.00% covered (danger)
0.00%
0 / 1
23.28
91.95% covered (success)
91.95%
80 / 87
 getImageParams
0.00% covered (danger)
0.00%
0 / 1
8.86
76.19% covered (warning)
76.19%
16 / 21
 makeImage
100.00% covered (success)
100.00%
1 / 1
37
100.00% covered (success)
100.00%
87 / 87
 parseLinkParameter
100.00% covered (success)
100.00%
1 / 1
5
100.00% covered (success)
100.00%
18 / 18
 stripAltText
100.00% covered (success)
100.00%
1 / 1
2
100.00% covered (success)
100.00%
8 / 8
 attributeStripCallback
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 4
 getTags
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 4
 getFunctionSynonyms
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 2
 getUrlProtocols
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 1
 extractSections
0.00% covered (danger)
0.00%
0 / 1
23.66
84.91% covered (warning)
84.91%
45 / 53
 getSection
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
1 / 1
 replaceSection
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
1 / 1
 getFlatSectionInfo
0.00% covered (danger)
0.00%
0 / 1
12
0.00% covered (danger)
0.00%
0 / 23
 getRevisionId
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
1 / 1
 getRevisionObject
0.00% covered (danger)
0.00%
0 / 1
12
0.00% covered (danger)
0.00%
0 / 8
 getRevisionRecordObject
100.00% covered (success)
100.00%
1 / 1
9
100.00% covered (success)
100.00%
15 / 15
 getRevisionTimestamp
0.00% covered (danger)
0.00%
0 / 1
3.03
85.71% covered (warning)
85.71%
6 / 7
 getRevisionUser
100.00% covered (success)
100.00%
1 / 1
7
100.00% covered (success)
100.00%
7 / 7
 getRevisionSize
0.00% covered (danger)
0.00%
0 / 1
12
0.00% covered (danger)
0.00%
0 / 6
 setDefaultSort
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 3
 getDefaultSort
0.00% covered (danger)
0.00%
0 / 1
2.15
66.67% covered (warning)
66.67%
2 / 3
 getCustomDefaultSort
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 1
 getSectionNameFromStrippedText
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
4 / 4
 makeAnchor
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
1 / 1
 makeLegacyAnchor
0.00% covered (danger)
0.00%
0 / 1
12
0.00% covered (danger)
0.00%
0 / 5
 guessSectionNameFromWikiText
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
3 / 3
 guessLegacySectionNameFromWikiText
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 3
 guessSectionNameFromStrippedText
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
2 / 2
 normalizeSectionName
0.00% covered (danger)
0.00%
0 / 1
2.26
60.00% covered (warning)
60.00%
3 / 5
 stripSectionName
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
6 / 6
 fuzzTestSrvus
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 6
 fuzzTestPst
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 1
 fuzzTestPreprocess
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 1
 markerSkipCallback
0.00% covered (danger)
0.00%
0 / 1
4.03
87.50% covered (warning)
87.50%
14 / 16
 killMarkers
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
1 / 1
 parseWidthParam
0.00% covered (danger)
0.00%
0 / 1
5.01
92.31% covered (success)
92.31%
12 / 13
 lock
100.00% covered (success)
100.00%
1 / 1
2
100.00% covered (success)
100.00%
8 / 8
 stripOuterParagraph
100.00% covered (success)
100.00%
1 / 1
3
100.00% covered (success)
100.00%
4 / 4
 getFreshParser
0.00% covered (danger)
0.00%
0 / 1
6
0.00% covered (danger)
0.00%
0 / 3
 enableOOUI
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 4
 setOutputFlag
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
4 / 4
<?php
/**
 * PHP parser that converts wiki markup to HTML.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License along
 * with this program; if not, write to the Free Software Foundation, Inc.,
 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 * http://www.gnu.org/copyleft/gpl.html
 *
 * @file
 * @ingroup Parser
 */
use MediaWiki\BadFileLookup;
use MediaWiki\Config\ServiceOptions;
use MediaWiki\Debug\DeprecatablePropertyArray;
use MediaWiki\HookContainer\HookContainer;
use MediaWiki\HookContainer\HookRunner;
use MediaWiki\Languages\LanguageConverterFactory;
use MediaWiki\Languages\LanguageNameUtils;
use MediaWiki\Linker\LinkRenderer;
use MediaWiki\Linker\LinkRendererFactory;
use MediaWiki\Linker\LinkTarget;
use MediaWiki\MediaWikiServices;
use MediaWiki\Preferences\SignatureValidator;
use MediaWiki\Revision\RevisionAccessException;
use MediaWiki\Revision\RevisionRecord;
use MediaWiki\Revision\SlotRecord;
use MediaWiki\SpecialPage\SpecialPageFactory;
use Psr\Log\LoggerInterface;
use Psr\Log\NullLogger;
use Wikimedia\IPUtils;
use Wikimedia\ScopedCallback;
/**
 * @defgroup Parser Parser
 */
/**
 * PHP Parser - Processes wiki markup (which uses a more user-friendly
 * syntax, such as "[[link]]" for making links), and provides a one-way
 * transformation of that wiki markup it into (X)HTML output / markup
 * (which in turn the browser understands, and can display).
 *
 * There are seven main entry points into the Parser class:
 *
 * - Parser::parse()
 *     produces HTML output
 * - Parser::preSaveTransform()
 *     produces altered wiki markup
 * - Parser::preprocess()
 *     removes HTML comments and expands templates
 * - Parser::cleanSig() and Parser::cleanSigInSig()
 *     cleans a signature before saving it to preferences
 * - Parser::getSection()
 *     return the content of a section from an article for section editing
 * - Parser::replaceSection()
 *     replaces a section by number inside an article
 * - Parser::getPreloadText()
 *     removes <noinclude> sections and <includeonly> tags
 *
 * @warning $wgUser or $wgTitle or $wgRequest or $wgLang. Keep them away!
 *
 * @par Settings:
 * $wgNamespacesWithSubpages
 *
 * @par Settings only within ParserOptions:
 * $wgAllowExternalImages
 * $wgAllowSpecialInclusion
 * $wgInterwikiMagic
 * $wgMaxArticleSize
 *
 * @ingroup Parser
 */
class Parser {
    /**
     * Update this version number when the ParserOutput format
     * changes in an incompatible way, so the parser cache
     * can automatically discard old data.
     */
    public const VERSION = '1.6.4';
    # Flags for Parser::setFunctionHook
    public const SFH_NO_HASH = 1;
    public const SFH_OBJECT_ARGS = 2;
    # Constants needed for external link processing
    # Everything except bracket, space, or control characters
    # \p{Zs} is unicode 'separator, space' category. It covers the space 0x20
    # as well as U+3000 is IDEOGRAPHIC SPACE for T21052
    # \x{FFFD} is the Unicode replacement character, which the HTML5 spec
    # uses to replace invalid HTML characters.
    public const EXT_LINK_URL_CLASS = '[^][<>"\\x00-\\x20\\x7F\p{Zs}\x{FFFD}]';
    # Simplified expression to match an IPv4 or IPv6 address, or
    # at least one character of a host name (embeds EXT_LINK_URL_CLASS)
    // phpcs:ignore Generic.Files.LineLength
    private const EXT_LINK_ADDR = '(?:[0-9.]+|\\[(?i:[0-9a-f:.]+)\\]|[^][<>"\\x00-\\x20\\x7F\p{Zs}\x{FFFD}])';
    # RegExp to make image URLs (embeds IPv6 part of EXT_LINK_ADDR)
    // phpcs:ignore Generic.Files.LineLength
    private const EXT_IMAGE_REGEX = '/^(http:\/\/|https:\/\/)((?:\\[(?i:[0-9a-f:.]+)\\])?[^][<>"\\x00-\\x20\\x7F\p{Zs}\x{FFFD}]+)
        \\/([A-Za-z0-9_.,~%\\-+&;#*?!=()@\\x80-\\xFF]+)\\.((?i)gif|png|jpg|jpeg)$/Sxu';
    # Regular expression for a non-newline space
    private const SPACE_NOT_NL = '(?:\t|&nbsp;|&\#0*160;|&\#[Xx]0*[Aa]0;|\p{Zs})';
    # Flags for preprocessToDom
    public const PTD_FOR_INCLUSION = 1;
    # Allowed values for $this->mOutputType
    # Parameter to startExternalParse().
    public const OT_HTML = 1; # like parse()
    public const OT_WIKI = 2; # like preSaveTransform()
    public const OT_PREPROCESS = 3; # like preprocess()
    public const OT_MSG = 3;
    # like extractSections() - portions of the original are returned unchanged.
    public const OT_PLAIN = 4;
    /**
     * @var string Prefix and suffix for temporary replacement strings
     * for the multipass parser.
     *
     * \x7f should never appear in input as it's disallowed in XML.
     * Using it at the front also gives us a little extra robustness
     * since it shouldn't match when butted up against identifier-like
     * string constructs.
     *
     * Must not consist of all title characters, or else it will change
     * the behavior of <nowiki> in a link.
     *
     * Must have a character that needs escaping in attributes, otherwise
     * someone could put a strip marker in an attribute, to get around
     * escaping quote marks, and break out of the attribute. Thus we add
     * `'".
     */
    public const MARKER_SUFFIX = "-QINU`\"'\x7f";
    public const MARKER_PREFIX = "\x7f'\"`UNIQ-";
    # Markers used for wrapping the table of contents
    public const TOC_START = '<mw:toc>';
    public const TOC_END = '</mw:toc>';
    # Persistent:
    /** @deprecated since 1.35; use Parser::getTags() */
    public $mTagHooks = [];
    /** @deprecated since 1.35; use Parser::getFunctionHooks() */
    public $mFunctionHooks = [];
    private $mFunctionSynonyms = [ 0 => [], 1 => [] ];
    private $mFunctionTagHooks = [];
    private $mStripList = [];
    private $mVarCache = [];
    private $mImageParams = [];
    private $mImageParamsMagicArray = [];
    /** @deprecated since 1.35 */
    public $mMarkerIndex = 0;
    /**
     * @var bool Whether firstCallInit still needs to be called
     * @deprecated since 1.35
     */
    public $mFirstCall = true;
    # Initialised by initializeVariables()
    /**
     * @var MagicWordArray
     */
    private $mVariables;
    /**
     * @var MagicWordArray
     */
    private $mSubstWords;
    /**
     * @deprecated since 1.34, there should be no need to use this
     * @var array
     */
    private $mConf;
    # Initialised in constructor
    private $mExtLinkBracketedRegex, $mUrlProtocols;
    # Initialized in getPreprocessor()
    /**
     * @var Preprocessor
     * @deprecated since 1.35
     */
    public $mPreprocessor;
    # Cleared with clearState():
    /**
     * @var ParserOutput
     * @deprecated since 1.35; use Parser::getOutput()
     */
    public $mOutput;
    private $mAutonumber;
    /**
     * @var StripState
     * @deprecated since 1.35, use Parser::getStripState()
     */
    public $mStripState;
    /**
     * @var LinkHolderArray
     */
    private $mLinkHolders;
    /**
     * @var int
     * @deprecated since 1.35; use Parser::nextLinkID() / ::setLinkID()
     */
    public $mLinkID;
    /** @deprecated since 1.35 */
    public $mIncludeSizes;
    /** @deprecated since 1.35 */
    public $mPPNodeCount;
    /**
     * @deprecated since 1.35, Preprocessor_DOM was removed and this counter
     *    is no longer incremented by anything.
     */
    public $mGeneratedPPNodeCount;
    /** @deprecated since 1.35 */
    public $mHighestExpansionDepth;
    private $mDefaultSort;
    private $mTplRedirCache;
    /** @internal */
    public $mHeadings;
    /** @deprecated since 1.35 */
    public $mDoubleUnderscores;
    /** @deprecated since 1.35 */
    public $mExpensiveFunctionCount; # number of expensive parser function calls
    /** @deprecated since 1.35 */
    public $mShowToc;
    private $mForceTocPosition;
    /** @var array */
    private $mTplDomCache;
    /**
     * @var User
     * @deprecated since 1.35, use Parser::getUser()
     */
    public $mUser; # User object; only used when doing pre-save transform
    # Temporary
    # These are variables reset at least once per parse regardless of $clearState
    /**
     * @var ParserOptions|null
     * @deprecated since 1.35, use Parser::getOptions()
     */
    public $mOptions;
    /**
     * Since 1.34, leaving `mTitle` uninitialized or setting `mTitle` to
     * `null` is deprecated.
     *
     * @var Title|null
     * @deprecated since 1.35, use Parser::getTitle()
     */
    public $mTitle;        # Title context, used for self-link rendering and similar things
    private $mOutputType;   # Output type, one of the OT_xxx constants
    /** @deprecated since 1.35 */
    public $ot;            # Shortcut alias, see setOutputType()
    /** @deprecated since 1.35, use Parser::getRevisionObject() */
    public $mRevisionObject; # The revision object of the specified revision ID
    /** @deprecated since 1.35, use Parser::getRevisionId() */
    public $mRevisionId;   # ID to display in {{REVISIONID}} tags
    /** @deprecated since 1.35, use Parser::getRevisionTimestamp() */
    public $mRevisionTimestamp; # The timestamp of the specified revision ID
    /** @deprecated since 1.35, use Parser::getRevisionUser() */
    public $mRevisionUser; # User to display in {{REVISIONUSER}} tag
    /** @deprecated since 1.35, use Parser::getRevisionSize() */
    public $mRevisionSize; # Size to display in {{REVISIONSIZE}} variable
    /** @deprecated since 1.35 */
    public $mInputSize = false; # For {{PAGESIZE}} on current page.
    /** @var RevisionRecord|null */
    private $mRevisionRecordObject;
    /**
     * @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.
     */
    private $mLangLinkLanguages;
    /**
     * @var MapCacheLRU|null
     * @since 1.24
     *
     * A cache of the current revisions of titles. Keys are $title->getPrefixedDbKey()
     */
    private $currentRevisionCache;
    /**
     * @var bool|string Recursive call protection.
     * @internal
     * @deprecated since 1.35; this variable should be treated as if it
     *   were private.
     */
    public $mInParse = false;
    /** @var SectionProfiler */
    private $mProfiler;
    /**
     * @var LinkRenderer
     */
    private $mLinkRenderer;
    /** @var MagicWordFactory */
    private $magicWordFactory;
    /** @var Language */
    private $contLang;
    /** @var LanguageConverterFactory */
    private $languageConverterFactory;
    /** @var ParserFactory */
    private $factory;
    /** @var SpecialPageFactory */
    private $specialPageFactory;
    /**
     * This is called $svcOptions instead of $options like elsewhere to avoid confusion with
     * $mOptions, which is public and widely used, and also with the local variable $options used
     * for ParserOptions throughout this file.
     *
     * @var ServiceOptions
     */
    private $svcOptions;
    /** @var LinkRendererFactory */
    private $linkRendererFactory;
    /** @var NamespaceInfo */
    private $nsInfo;
    /** @var LoggerInterface */
    private $logger;
    /** @var BadFileLookup */
    private $badFileLookup;
    /** @var HookContainer */
    private $hookContainer;
    /** @var HookRunner */
    private $hookRunner;
    /**
     * @var array
     * @since 1.35
     */
    public const CONSTRUCTOR_OPTIONS = [
        // Deprecated and unused; from $wgParserConf
        'class',
        // See documentation for the corresponding config options
        'ArticlePath',
        'EnableScaryTranscluding',
        'ExtraInterlanguageLinkPrefixes',
        'FragmentMode',
        'LanguageCode',
        'MaxSigChars',
        'MaxTocLevel',
        'MiserMode',
        'ScriptPath',
        'Server',
        'ServerName',
        'ShowHostnames',
        'SignatureValidation',
        'Sitename',
        'StylePath',
        'TranscludeCacheExpiry',
    ];
    /**
     * Constructing parsers directly is deprecated! Use a ParserFactory.
     * @internal
     *
     * @param ServiceOptions|null $svcOptions
     * @param MagicWordFactory|null $magicWordFactory
     * @param Language|null $contLang Content language
     * @param ParserFactory|null $factory
     * @param string|null $urlProtocols As returned from wfUrlProtocols()
     * @param SpecialPageFactory|null $spFactory
     * @param LinkRendererFactory|null $linkRendererFactory
     * @param NamespaceInfo|null $nsInfo
     * @param LoggerInterface|null $logger
     * @param BadFileLookup|null $badFileLookup
     * @param LanguageConverterFactory|null $languageConverterFactory
     * @param HookContainer|null $hookContainer
     */
    public function __construct(
        $svcOptions = null,
        MagicWordFactory $magicWordFactory = null,
        Language $contLang = null,
        ParserFactory $factory = null,
        $urlProtocols = null,
        SpecialPageFactory $spFactory = null,
        $linkRendererFactory = null,
        $nsInfo = null,
        $logger = null,
        BadFileLookup $badFileLookup = null,
        LanguageConverterFactory $languageConverterFactory = null,
        HookContainer $hookContainer = null
    ) {
        if ( ParserFactory::$inParserFactory === 0 ) {
            // Direct construction of Parser is deprecated; use a ParserFactory
            wfDeprecated( __METHOD__, '1.34' );
        }
        if ( !$svcOptions || is_array( $svcOptions ) ) {
            wfDeprecated( 'old calling convention for ' . __METHOD__, '1.34' );
            // Pre-1.34 calling convention is the first parameter is just ParserConf, the seventh is
            // Config, and the eighth is LinkRendererFactory.
            $this->mConf = (array)$svcOptions;
            if ( empty( $this->mConf['class'] ) ) {
                $this->mConf['class'] = self::class;
            }
            $this->svcOptions = new ServiceOptions( self::CONSTRUCTOR_OPTIONS,
                $this->mConf, func_num_args() > 6
                    ? func_get_arg( 6 ) : MediaWikiServices::getInstance()->getMainConfig()
            );
            $linkRendererFactory = func_num_args() > 7 ? func_get_arg( 7 ) : null;
            $nsInfo = func_num_args() > 8 ? func_get_arg( 8 ) : null;
        } else {
            // New calling convention