X-Git-Url: http://git.heureux-cyclage.org/?a=blobdiff_plain;ds=sidebyside;f=includes%2Fparser%2FParser.php;h=ae77c4ef03c7f684e23d939b95abc89ff301b5d7;hb=9ddd146c262806e993ea66994f367a0a795e762d;hp=5c55124492790d29d38295a0a370a44ddbd28352;hpb=cb5acb42ce62b2d600dfb4e11a2982602b670a2f;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/parser/Parser.php b/includes/parser/Parser.php index 5c55124492..ae77c4ef03 100644 --- a/includes/parser/Parser.php +++ b/includes/parser/Parser.php @@ -228,7 +228,7 @@ class Parser { 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 @@ -906,11 +906,11 @@ class Parser { /** * 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() ) { @@ -926,7 +926,7 @@ class Parser { * * @return Title|null */ - public function getTitle() { + public function getTitle() : ?Title { return $this->mTitle; } @@ -934,9 +934,9 @@ class Parser { * 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 ); } @@ -2312,6 +2312,11 @@ class Parser { $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 ) { @@ -2319,14 +2324,6 @@ class Parser { # 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]; @@ -4271,7 +4268,6 @@ class Parser { * @param bool $isMain * @return mixed|string * @private - * @suppress PhanTypeInvalidDimOffset */ public function formatHeadings( $text, $origText, $isMain = true ) { # Inhibit editsection links if requested in the page @@ -5578,7 +5574,6 @@ class Parser { 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() );