* @file
* @ingroup Parser
*/
+use MediaWiki\BadFileLookup;
use MediaWiki\Config\ServiceOptions;
use MediaWiki\Linker\LinkRenderer;
use MediaWiki\Linker\LinkRendererFactory;
/** @var LoggerInterface */
private $logger;
+ /** @var BadFileLookup */
+ private $badFileLookup;
+
/**
* TODO Make this a const when HHVM support is dropped (T192166)
*
* @param LinkRendererFactory|null $linkRendererFactory
* @param NamespaceInfo|null $nsInfo
* @param LoggerInterface|null $logger
+ * @param BadFileLookup|null $badFileLookup
*/
public function __construct(
$svcOptions = null,
SpecialPageFactory $spFactory = null,
$linkRendererFactory = null,
$nsInfo = null,
- $logger = null
+ $logger = null,
+ BadFileLookup $badFileLookup = null
) {
if ( !$svcOptions || is_array( $svcOptions ) ) {
// Pre-1.34 calling convention is the first parameter is just ParserConf, the seventh is
MediaWikiServices::getInstance()->getLinkRendererFactory();
$this->nsInfo = $nsInfo ?? MediaWikiServices::getInstance()->getNamespaceInfo();
$this->logger = $logger ?: new NullLogger();
+ $this->badFileLookup = $badFileLookup ??
+ MediaWikiServices::getInstance()->getBadFileLookup();
}
/**
*/
public function __destruct() {
if ( isset( $this->mLinkHolders ) ) {
+ // @phan-suppress-next-line PhanTypeObjectUnsetDeclaredProperty
unset( $this->mLinkHolders );
}
+ // @phan-suppress-next-line PhanTypeSuspiciousNonTraversableForeach
foreach ( $this as $name => $value ) {
unset( $this->$name );
}
* @param ParserOptions $options
* @param bool $linestart
* @param bool $clearState
- * @param int|null $revid Number to pass in {{REVISIONID}}
+ * @param int|null $revid ID of the revision being rendered. This is used to render
+ * REVISION* magic words. 0 means that any current revision will be used. Null means
+ * that {{REVISIONID}}/{{REVISIONUSER}} will be empty and {{REVISIONTIMESTAMP}} will
+ * use the current timestamp.
* @return ParserOutput A ParserOutput
* @return-taint escaped
*/
*/
public function replaceExternalLinks( $text ) {
$bits = preg_split( $this->mExtLinkBracketedRegex, $text, -1, PREG_SPLIT_DELIM_CAPTURE );
+ // @phan-suppress-next-line PhanTypeComparisonFromArray See phan issue #3161
if ( $bits === false ) {
throw new MWException( "PCRE needs to be compiled with "
. "--enable-unicode-properties in order for MediaWiki to function" );
}
if ( $ns == NS_FILE ) {
- if ( !wfIsBadImage( $nt->getDBkey(), $this->mTitle ) ) {
+ if ( !$this->badFileLookup->isBadFile( $nt->getDBkey(), $this->mTitle ) ) {
if ( $wasblank ) {
# if no parameters were passed, $text
# becomes something like "File:Foo.png",
* @param bool $isMain
* @return mixed|string
* @private
+ * @suppress PhanTypeInvalidDimOffset
*/
public function formatHeadings( $text, $origText, $isMain = true ) {
# Inhibit editsection links if requested in the page
Hooks::run( 'ParserMakeImageParams', [ $title, $file, &$params, $this ] );
# Linker does the rest
+ // @phan-suppress-next-line PhanTypeInvalidDimOffset
$time = $options['time'] ?? false;
$ret = Linker::makeImageLink( $this, $title, $file, $params['frame'], $params['handler'],
$time, $descQuery, $this->mOptions->getThumbSize() );
*/
private static function normalizeSectionName( $text ) {
# T90902: ensure the same normalization is applied for IDs as to links
+ /** @var MediaWikiTitleCodec $titleParser */
$titleParser = MediaWikiServices::getInstance()->getTitleParser();
+ '@phan-var MediaWikiTitleCodec $titleParser';
try {
$parts = $titleParser->splitTitleString( "#$text" );