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
Revert "Parser: Add Title type hints"
[lhc/web/wiklou.git]
/
includes
/
parser
/
Parser.php
diff --git
a/includes/parser/Parser.php
b/includes/parser/Parser.php
index
b27338c
..
ae77c4e
100644
(file)
--- a/
includes/parser/Parser.php
+++ b/
includes/parser/Parser.php
@@
-228,7
+228,7
@@
class Parser {
public $mOptions;
/**
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
*/
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
*
/**
* 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() ) {
@@
-926,7
+926,7
@@
class Parser {
*
* @return Title|null
*/
*
* @return Title|null
*/
- public function getTitle() {
+ public function getTitle()
: ?Title
{
return $this->mTitle;
}
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
* 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 );
}
@@
-2312,6
+2312,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
+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";
# 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];