public $mOptions;
/**
- * @var Title
+ * Since 1.34, leaving `mTitle` uninitialized or setting `mTitle` to
+ * `null` is deprecated.
+ *
+ * @internal
+ * @var Title|null
*/
public $mTitle; # Title context, used for self-link rendering and similar things
public $mOutputType; # Output type, one of the OT_xxx constants
*/
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 );
}
/**
* Set the context title
*
- * @param Title $t
+ * @param Title|null $t
*/
- public function setTitle( $t ) {
+ public function setTitle( Title $t = null ) {
if ( !$t ) {
$t = Title::makeTitle( NS_SPECIAL, 'Badtitle/Parser' );
}
/**
* Accessor for the Title object
*
+ * Since 1.34, leaving `mTitle` uninitialized as `null` is deprecated.
+ *
* @return Title|null
*/
- public function getTitle() {
+ public function getTitle() : ?Title {
+ if ( $this->mTitle === null ) {
+ wfDeprecated( 'Parser title should never be null', '1.34' );
+ }
return $this->mTitle;
}
* Accessor/mutator for the Title object
*
* @param Title|null $x Title object or null to just get the current one
- * @return Title
+ * @return Title|null
*/
- public function Title( $x = null ) {
+ public function Title( Title $x = null ) : ?Title {
return wfSetVar( $this->mTitle, $x );
}
/**
* Get the language object for language conversion
* @deprecated since 1.32, just use getTargetLanguage()
- * @return Language|null
+ * @return Language
*/
public function getConverterLanguage() {
+ wfDeprecated( __METHOD__, '1.32' );
return $this->getTargetLanguage();
}
*/
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" );
$line = $a->current(); # Workaround for broken ArrayIterator::next() that returns "void"
$s = substr( $s, 1 );
+ if ( is_null( $this->mTitle ) ) {
+ throw new MWException( __METHOD__ . ": \$this->mTitle is null\n" );
+ }
+ $nottalk = !$this->mTitle->isTalkPage();
+
$useLinkPrefixExtension = $this->getTargetLanguage()->linkPrefixExtension();
$e2 = null;
if ( $useLinkPrefixExtension ) {
# e.g. in the case of 'The Arab al[[Razi]]', 'al' will be matched
$charset = $this->contLang->linkPrefixCharset();
$e2 = "/^((?>.*[^$charset]|))(.+)$/sDu";
- }
-
- if ( is_null( $this->mTitle ) ) {
- throw new MWException( __METHOD__ . ": \$this->mTitle is null\n" );
- }
- $nottalk = !$this->mTitle->isTalkPage();
-
- if ( $useLinkPrefixExtension ) {
$m = [];
if ( preg_match( $e2, $s, $m ) ) {
$first_prefix = $m[2];
*/
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" );