X-Git-Url: https://git.cyclocoop.org/?a=blobdiff_plain;f=includes%2FMWNamespace.php;h=89cb616a7bfbbded18c616e4c3cd6604e30d9cbc;hb=c47221ab8246b0428628500cfe0fdcd11f96bcf3;hp=0dd709f1e443edc043e215c75b851b52634d08fb;hpb=c8e2b346f717bcd2bbc357a085cf8ad97fb354eb;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/MWNamespace.php b/includes/MWNamespace.php index 0dd709f1e4..89cb616a7b 100644 --- a/includes/MWNamespace.php +++ b/includes/MWNamespace.php @@ -28,7 +28,6 @@ * * These are synonyms for the names given in the language file * Users and translators should not change them - * */ class MWNamespace { @@ -37,7 +36,7 @@ class MWNamespace { * forevermore. Historically, they could've probably been lowercased too, * but some things are just too ingrained now. :) */ - private static $alwaysCapitalizedNamespaces = array( NS_SPECIAL, NS_USER, NS_MEDIAWIKI ); + private static $alwaysCapitalizedNamespaces = [ NS_SPECIAL, NS_USER, NS_MEDIAWIKI ]; /** * Throw an exception when trying to get the subject or talk page @@ -72,7 +71,7 @@ class MWNamespace { /** * @since 1.20 */ - Hooks::run( 'NamespaceIsMovable', array( $index, &$result ) ); + Hooks::run( 'NamespaceIsMovable', [ $index, &$result ] ); return $result; } @@ -209,13 +208,13 @@ class MWNamespace { static $namespaces = null; if ( $namespaces === null || $rebuild ) { global $wgExtraNamespaces, $wgCanonicalNamespaceNames; - $namespaces = array( NS_MAIN => '' ) + $wgCanonicalNamespaceNames; + $namespaces = [ NS_MAIN => '' ] + $wgCanonicalNamespaceNames; // Add extension namespaces $namespaces += ExtensionRegistry::getInstance()->getAttribute( 'ExtensionNamespaces' ); if ( is_array( $wgExtraNamespaces ) ) { $namespaces += $wgExtraNamespaces; } - Hooks::run( 'CanonicalNamespaces', array( &$namespaces ) ); + Hooks::run( 'CanonicalNamespaces', [ &$namespaces ] ); } return $namespaces; } @@ -245,7 +244,7 @@ class MWNamespace { public static function getCanonicalIndex( $name ) { static $xNamespaces = false; if ( $xNamespaces === false ) { - $xNamespaces = array(); + $xNamespaces = []; foreach ( self::getCanonicalNamespaces() as $i => $text ) { $xNamespaces[strtolower( $text )] = $i; } @@ -279,12 +278,26 @@ class MWNamespace { } /** - * Can this namespace ever have a talk namespace? + * Does this namespace ever have a talk namespace? + * + * @deprecated since 1.30, use hasTalkNamespace() instead. * * @param int $index Namespace index - * @return bool + * @return bool True if this namespace either is or has a corresponding talk namespace. */ public static function canTalk( $index ) { + return self::hasTalkNamespace( $index ); + } + + /** + * Does this namespace ever have a talk namespace? + * + * @since 1.30 + * + * @param int $index Namespace ID + * @return bool True if this namespace either is or has a corresponding talk namespace. + */ + public static function hasTalkNamespace( $index ) { return $index >= NS_MAIN; } @@ -339,11 +352,11 @@ class MWNamespace { */ public static function getContentNamespaces() { global $wgContentNamespaces; - if ( !is_array( $wgContentNamespaces ) || $wgContentNamespaces === array() ) { - return array( NS_MAIN ); + if ( !is_array( $wgContentNamespaces ) || $wgContentNamespaces === [] ) { + 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) - return array_merge( array( NS_MAIN ), $wgContentNamespaces ); + return array_merge( [ NS_MAIN ], $wgContentNamespaces ); } else { return $wgContentNamespaces; } @@ -472,7 +485,7 @@ class MWNamespace { } // First, get the list of groups that can edit this namespace. - $namespaceGroups = array(); + $namespaceGroups = []; $combine = 'array_merge'; foreach ( (array)$wgNamespaceProtection[$index] as $right ) { if ( $right == 'sysop' ) { @@ -491,7 +504,7 @@ class MWNamespace { // Now, keep only those restriction levels where there is at least one // group that can edit the namespace but would be blocked by the // restriction. - $usableLevels = array( '' ); + $usableLevels = [ '' ]; foreach ( $wgRestrictionLevels as $level ) { $right = $level; if ( $right == 'sysop' ) {