Merge "Bug 35671 - PHP Notice: Undefined index: gettoken in includes/api/ApiMain...
[lhc/web/wiklou.git] / includes / Namespace.php
index d32a53c..ac788aa 100644 (file)
@@ -33,10 +33,10 @@ class MWNamespace {
         * @param $index
         * @param $method
         *
-        * @return true
+        * @return bool
         */
        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;
@@ -50,7 +50,7 @@ class MWNamespace {
         */
        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 );
        }
 
        /**
@@ -67,8 +67,10 @@ class MWNamespace {
        /**
         * @see self::isSubject
         * @deprecated Please use the more consistently named isSubject (since 1.19)
+        * @return bool
         */
        public static function isMain( $index ) {
+               wfDeprecated( __METHOD__, '1.19' );
                return self::isSubject( $index );
        }
 
@@ -105,7 +107,7 @@ class MWNamespace {
         */
        public static function getSubject( $index ) {
                # Handle special namespaces
-               if( $index < NS_MAIN ) {
+               if ( $index < NS_MAIN ) {
                        return $index;
                }
 
@@ -125,9 +127,9 @@ class MWNamespace {
        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;
@@ -138,7 +140,7 @@ class MWNamespace {
         * Returns whether the specified namespace exists
         *
         * @param $index
-        * 
+        *
         * @return bool
         * @since 1.19
         */
@@ -184,7 +186,7 @@ class MWNamespace {
         * Returns array of all defined namespaces with their canonical
         * (English) names.
         *
-        * @return \array
+        * @return array
         * @since 1.17
         */
        public static function getCanonicalNamespaces() {
@@ -208,7 +210,7 @@ class MWNamespace {
         */
        public static function getCanonicalName( $index ) {
                $nslist = self::getCanonicalNamespaces();
-               if( isset( $nslist[$index] ) ) {
+               if ( isset( $nslist[$index] ) ) {
                        return $nslist[$index];
                } else {
                        return false;
@@ -227,7 +229,7 @@ class MWNamespace {
                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 ) ) {
@@ -305,7 +307,7 @@ class MWNamespace {
         */
        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)