public $mOptions;
/**
- * @var Title
+ * @var Title|null Beware - this is not always set
*/
public $mTitle; # Title context, used for self-link rendering and similar things
public $mOutputType; # Output type, one of the OT_xxx constants
/**
* 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::newFromText( 'NO TITLE' );
+ $t = Title::makeTitle( NS_SPECIAL, 'Badtitle/Parser' );
}
if ( $t->hasFragment() ) {
*
* @return Title|null
*/
- public function getTitle() {
+ public function getTitle() : ?Title {
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 );
}
$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];
* @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() );