dépôts
/
lhc
/
web
/
wiklou.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Parser: Hard deprecate getConverterLanguage
[lhc/web/wiklou.git]
/
includes
/
parser
/
Parser.php
diff --git
a/includes/parser/Parser.php
b/includes/parser/Parser.php
index
267402f
..
d56af1d
100644
(file)
--- a/
includes/parser/Parser.php
+++ b/
includes/parser/Parser.php
@@
-228,7
+228,11
@@
class Parser {
public $mOptions;
/**
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 $mTitle; # Title context, used for self-link rendering and similar things
public $mOutputType; # Output type, one of the OT_xxx constants
@@
-906,11
+910,11
@@
class Parser {
/**
* Set the context title
*
/**
* Set the context title
*
- * @param Title $t
+ * @param Title
|null
$t
*/
*/
- public function setTitle(
$t
) {
+ public function setTitle(
Title $t = null
) {
if ( !$t ) {
if ( !$t ) {
- $t = Title::
newFromText( 'NO TITLE
' );
+ $t = Title::
makeTitle( NS_SPECIAL, 'Badtitle/Parser
' );
}
if ( $t->hasFragment() ) {
}
if ( $t->hasFragment() ) {
@@
-924,9
+928,14
@@
class Parser {
/**
* Accessor for the Title object
*
/**
* Accessor for the Title object
*
+ * Since 1.34, leaving `mTitle` uninitialized as `null` is deprecated.
+ *
* @return Title|null
*/
* @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;
}
return $this->mTitle;
}
@@
-934,9
+943,9
@@
class Parser {
* Accessor/mutator for the Title object
*
* @param Title|null $x Title object or null to just get the current one
* 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 );
}
return wfSetVar( $this->mTitle, $x );
}
@@
-1042,9
+1051,10
@@
class Parser {
/**
* Get the language object for language conversion
* @deprecated since 1.32, just use getTargetLanguage()
/**
* Get the language object for language conversion
* @deprecated since 1.32, just use getTargetLanguage()
- * @return Language
|null
+ * @return Language
*/
public function getConverterLanguage() {
*/
public function getConverterLanguage() {
+ wfDeprecated( __METHOD__, '1.32' );
return $this->getTargetLanguage();
}
return $this->getTargetLanguage();
}
@@
-2312,6
+2322,11
@@
class Parser {
$line = $a->current(); # Workaround for broken ArrayIterator::next() that returns "void"
$s = substr( $s, 1 );
$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 ) {
$useLinkPrefixExtension = $this->getTargetLanguage()->linkPrefixExtension();
$e2 = null;
if ( $useLinkPrefixExtension ) {
@@
-2319,14
+2334,6
@@
class Parser {
# e.g. in the case of 'The Arab al[[Razi]]', 'al' will be matched
$charset = $this->contLang->linkPrefixCharset();
$e2 = "/^((?>.*[^$charset]|))(.+)$/sDu";
# 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];
$m = [];
if ( preg_match( $e2, $s, $m ) ) {
$first_prefix = $m[2];
@@
-6190,7
+6197,9
@@
class Parser {
*/
private static function normalizeSectionName( $text ) {
# T90902: ensure the same normalization is applied for IDs as to links
*/
private static function normalizeSectionName( $text ) {
# T90902: ensure the same normalization is applied for IDs as to links
+ /** @var MediaWikiTitleCodec $titleParser */
$titleParser = MediaWikiServices::getInstance()->getTitleParser();
$titleParser = MediaWikiServices::getInstance()->getTitleParser();
+ '@phan-var MediaWikiTitleCodec $titleParser';
try {
$parts = $titleParser->splitTitleString( "#$text" );
try {
$parts = $titleParser->splitTitleString( "#$text" );