Merge "Type-hint LinkTarget"
This commit is contained in:
commit
a4b5426e4c
4 changed files with 29 additions and 29 deletions
|
|
@ -955,7 +955,7 @@ class Title implements LinkTarget, PageIdentity, IDBAccessObject {
|
|||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isExternal() {
|
||||
public function isExternal(): bool {
|
||||
return $this->mInterwiki !== '';
|
||||
}
|
||||
|
||||
|
|
@ -966,7 +966,7 @@ class Title implements LinkTarget, PageIdentity, IDBAccessObject {
|
|||
*
|
||||
* @return string Interwiki prefix
|
||||
*/
|
||||
public function getInterwiki() {
|
||||
public function getInterwiki(): string {
|
||||
return $this->mInterwiki;
|
||||
}
|
||||
|
||||
|
|
@ -1038,7 +1038,7 @@ class Title implements LinkTarget, PageIdentity, IDBAccessObject {
|
|||
*
|
||||
* @return string Main part of the title
|
||||
*/
|
||||
public function getText() {
|
||||
public function getText(): string {
|
||||
return $this->mTextform;
|
||||
}
|
||||
|
||||
|
|
@ -1316,7 +1316,7 @@ class Title implements LinkTarget, PageIdentity, IDBAccessObject {
|
|||
* @return bool
|
||||
* @since 1.19
|
||||
*/
|
||||
public function inNamespace( $ns ) {
|
||||
public function inNamespace( int $ns ): bool {
|
||||
return MediaWikiServices::getInstance()->getNamespaceInfo()->
|
||||
equals( $this->mNamespace, $ns );
|
||||
}
|
||||
|
|
@ -1769,7 +1769,7 @@ class Title implements LinkTarget, PageIdentity, IDBAccessObject {
|
|||
*
|
||||
* @return string Title fragment
|
||||
*/
|
||||
public function getFragment() {
|
||||
public function getFragment(): string {
|
||||
return $this->mFragment;
|
||||
}
|
||||
|
||||
|
|
@ -1779,7 +1779,7 @@ class Title implements LinkTarget, PageIdentity, IDBAccessObject {
|
|||
* @return bool
|
||||
* @since 1.23
|
||||
*/
|
||||
public function hasFragment() {
|
||||
public function hasFragment(): bool {
|
||||
return $this->mFragment !== '';
|
||||
}
|
||||
|
||||
|
|
@ -1825,7 +1825,7 @@ class Title implements LinkTarget, PageIdentity, IDBAccessObject {
|
|||
* @param string $fragment
|
||||
* @return Title
|
||||
*/
|
||||
public function createFragmentTarget( $fragment ) {
|
||||
public function createFragmentTarget( string $fragment ): self {
|
||||
return self::makeTitle(
|
||||
$this->mNamespace,
|
||||
$this->getText(),
|
||||
|
|
@ -3476,7 +3476,7 @@ class Title implements LinkTarget, PageIdentity, IDBAccessObject {
|
|||
* @param LinkTarget $other
|
||||
* @return bool
|
||||
*/
|
||||
public function isSameLinkAs( LinkTarget $other ) {
|
||||
public function isSameLinkAs( LinkTarget $other ): bool {
|
||||
// NOTE: keep in sync with TitleValue::isSameLinkAs()!
|
||||
// NOTE: === is needed for number-like titles
|
||||
return ( $other->getInterwiki() === $this->getInterwiki() )
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ interface LinkTarget {
|
|||
*
|
||||
* @return int Namespace index
|
||||
*/
|
||||
public function getNamespace();
|
||||
public function getNamespace(): int;
|
||||
|
||||
/**
|
||||
* Convenience function to test if it is in the namespace
|
||||
|
|
@ -40,7 +40,7 @@ interface LinkTarget {
|
|||
* @param int $ns
|
||||
* @return bool
|
||||
*/
|
||||
public function inNamespace( $ns );
|
||||
public function inNamespace( int $ns ): bool;
|
||||
|
||||
/**
|
||||
* Get the link fragment (i.e. the bit after the #) in text form.
|
||||
|
|
@ -48,7 +48,7 @@ interface LinkTarget {
|
|||
*
|
||||
* @return string link fragment
|
||||
*/
|
||||
public function getFragment();
|
||||
public function getFragment(): string;
|
||||
|
||||
/**
|
||||
* Whether the link target has a fragment
|
||||
|
|
@ -56,7 +56,7 @@ interface LinkTarget {
|
|||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function hasFragment();
|
||||
public function hasFragment(): bool;
|
||||
|
||||
/**
|
||||
* Get the main part with underscores.
|
||||
|
|
@ -64,7 +64,7 @@ interface LinkTarget {
|
|||
*
|
||||
* @return string Main part of the link, with underscores (for use in href attributes)
|
||||
*/
|
||||
public function getDBkey();
|
||||
public function getDBkey(): string;
|
||||
|
||||
/**
|
||||
* Returns the link in text form, without namespace prefix or fragment.
|
||||
|
|
@ -73,7 +73,7 @@ interface LinkTarget {
|
|||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getText();
|
||||
public function getText(): string;
|
||||
|
||||
/**
|
||||
* Creates a new LinkTarget for a different fragment of the same page.
|
||||
|
|
@ -85,7 +85,7 @@ interface LinkTarget {
|
|||
*
|
||||
* @return LinkTarget
|
||||
*/
|
||||
public function createFragmentTarget( $fragment );
|
||||
public function createFragmentTarget( string $fragment );
|
||||
|
||||
/**
|
||||
* Whether this LinkTarget has an interwiki component
|
||||
|
|
@ -93,7 +93,7 @@ interface LinkTarget {
|
|||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isExternal();
|
||||
public function isExternal(): bool;
|
||||
|
||||
/**
|
||||
* The interwiki component of this LinkTarget
|
||||
|
|
@ -101,7 +101,7 @@ interface LinkTarget {
|
|||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getInterwiki();
|
||||
public function getInterwiki(): string;
|
||||
|
||||
/**
|
||||
* Checks whether the given LinkTarget refers to the same target as this LinkTarget.
|
||||
|
|
@ -114,7 +114,7 @@ interface LinkTarget {
|
|||
* @param LinkTarget $other
|
||||
* @return bool
|
||||
*/
|
||||
public function isSameLinkAs( LinkTarget $other );
|
||||
public function isSameLinkAs( LinkTarget $other ): bool;
|
||||
|
||||
/**
|
||||
* Returns an informative human readable representation of the page identity,
|
||||
|
|
|
|||
|
|
@ -215,7 +215,7 @@ class TitleValue implements LinkTarget {
|
|||
* @since 1.23
|
||||
* @return int
|
||||
*/
|
||||
public function getNamespace() {
|
||||
public function getNamespace(): int {
|
||||
return $this->namespace;
|
||||
}
|
||||
|
||||
|
|
@ -224,7 +224,7 @@ class TitleValue implements LinkTarget {
|
|||
* @param int $ns
|
||||
* @return bool
|
||||
*/
|
||||
public function inNamespace( $ns ) {
|
||||
public function inNamespace( int $ns ): bool {
|
||||
return $this->namespace == $ns;
|
||||
}
|
||||
|
||||
|
|
@ -232,7 +232,7 @@ class TitleValue implements LinkTarget {
|
|||
* @since 1.23
|
||||
* @return string
|
||||
*/
|
||||
public function getFragment() {
|
||||
public function getFragment(): string {
|
||||
return $this->fragment;
|
||||
}
|
||||
|
||||
|
|
@ -240,7 +240,7 @@ class TitleValue implements LinkTarget {
|
|||
* @since 1.27
|
||||
* @return bool
|
||||
*/
|
||||
public function hasFragment() {
|
||||
public function hasFragment(): bool {
|
||||
return $this->fragment !== '';
|
||||
}
|
||||
|
||||
|
|
@ -251,7 +251,7 @@ class TitleValue implements LinkTarget {
|
|||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getDBkey() {
|
||||
public function getDBkey(): string {
|
||||
return $this->dbkey;
|
||||
}
|
||||
|
||||
|
|
@ -267,7 +267,7 @@ class TitleValue implements LinkTarget {
|
|||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getText() {
|
||||
public function getText(): string {
|
||||
return str_replace( '_', ' ', $this->dbkey );
|
||||
}
|
||||
|
||||
|
|
@ -279,7 +279,7 @@ class TitleValue implements LinkTarget {
|
|||
*
|
||||
* @return TitleValue
|
||||
*/
|
||||
public function createFragmentTarget( $fragment ) {
|
||||
public function createFragmentTarget( string $fragment ): self {
|
||||
return new TitleValue(
|
||||
$this->namespace,
|
||||
$this->dbkey,
|
||||
|
|
@ -294,7 +294,7 @@ class TitleValue implements LinkTarget {
|
|||
* @since 1.27
|
||||
* @return bool
|
||||
*/
|
||||
public function isExternal() {
|
||||
public function isExternal(): bool {
|
||||
return $this->interwiki !== '';
|
||||
}
|
||||
|
||||
|
|
@ -304,7 +304,7 @@ class TitleValue implements LinkTarget {
|
|||
* @since 1.27
|
||||
* @return string
|
||||
*/
|
||||
public function getInterwiki() {
|
||||
public function getInterwiki(): string {
|
||||
return $this->interwiki;
|
||||
}
|
||||
|
||||
|
|
@ -335,7 +335,7 @@ class TitleValue implements LinkTarget {
|
|||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isSameLinkAs( LinkTarget $other ) {
|
||||
public function isSameLinkAs( LinkTarget $other ): bool {
|
||||
// NOTE: keep in sync with Title::isSameLinkAs()!
|
||||
return ( $other->getInterwiki() === $this->getInterwiki() )
|
||||
&& ( $other->getDBkey() === $this->getDBkey() )
|
||||
|
|
|
|||
|
|
@ -67,7 +67,7 @@ class MWDebugTest extends MediaWikiIntegrationTestCase {
|
|||
|
||||
// create a dummy subclass that overrides a method
|
||||
$subclassInstance = new class ( NS_MAIN, 'Test' ) extends TitleValue {
|
||||
public function getNamespace() {
|
||||
public function getNamespace(): int {
|
||||
// never called
|
||||
return -100;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue