* @return true
*/
private static function isMethodValidFor( $index, $method ) {
- if( $index < NS_MAIN ) {
+ if ( $index < NS_MAIN ) {
throw new MWException( "$method does not make any sense for given namespace $index" );
}
return true;
*/
public static function isMovable( $index ) {
global $wgAllowImageMoving;
- return !( $index < NS_MAIN || ($index == NS_FILE && !$wgAllowImageMoving) || $index == NS_CATEGORY );
+ return !( $index < NS_MAIN || ( $index == NS_FILE && !$wgAllowImageMoving ) || $index == NS_CATEGORY );
}
/**
* @deprecated Please use the more consistently named isSubject (since 1.19)
*/
public static function isMain( $index ) {
+ wfDeprecated( __METHOD__, '1.19' );
return self::isSubject( $index );
}
*/
public static function getSubject( $index ) {
# Handle special namespaces
- if( $index < NS_MAIN ) {
+ if ( $index < NS_MAIN ) {
return $index;
}
public static function getAssociated( $index ) {
self::isMethodValidFor( $index, __METHOD__ );
- if( self::isMain( $index ) ) {
+ if ( self::isSubject( $index ) ) {
return self::getTalk( $index );
- } elseif( self::isTalk( $index ) ) {
+ } elseif ( self::isTalk( $index ) ) {
return self::getSubject( $index );
} else {
return null;
* Returns whether the specified namespace exists
*
* @param $index
- *
+ *
* @return bool
* @since 1.19
*/
* of this function rather than directly doing comparison will make
* sure that code will not potentially break.
*
- * @param $ns1 The first namespace index
- * @param $ns2 The second namespae index
+ * @param $ns1 int The first namespace index
+ * @param $ns2 int The second namespae index
*
* @return bool
* @since 1.19
* eg: NS_USER and NS_USER wil return true, as well
* NS_USER and NS_USER_TALK will return true.
*
- * @param $ns1 The first namespace index
- * @param $ns2 The second namespae index
+ * @param $ns1 int The first namespace index
+ * @param $ns2 int The second namespae index
*
* @return bool
* @since 1.19
*/
public static function getCanonicalName( $index ) {
$nslist = self::getCanonicalNamespaces();
- if( isset( $nslist[$index] ) ) {
+ if ( isset( $nslist[$index] ) ) {
return $nslist[$index];
} else {
return false;
if ( $xNamespaces === false ) {
$xNamespaces = array();
foreach ( self::getCanonicalNamespaces() as $i => $text ) {
- $xNamespaces[strtolower($text)] = $i;
+ $xNamespaces[strtolower( $text )] = $i;
}
}
if ( array_key_exists( $name, $xNamespaces ) ) {
*/
public static function getContentNamespaces() {
global $wgContentNamespaces;
- if( !is_array( $wgContentNamespaces ) || $wgContentNamespaces === array() ) {
+ if ( !is_array( $wgContentNamespaces ) || $wgContentNamespaces === array() ) {
return NS_MAIN;
} elseif ( !in_array( NS_MAIN, $wgContentNamespaces ) ) {
// always force NS_MAIN to be part of array (to match the algorithm used by isContent)