Fix PhanTypeInvalidLeftOperand in Language.php
authorErik Bernhardson <ebernhardson@wikimedia.org>
Tue, 13 Dec 2016 19:51:07 +0000 (11:51 -0800)
committerErik Bernhardson <ebernhardson@wikimedia.org>
Tue, 13 Dec 2016 19:54:15 +0000 (11:54 -0800)
Not entirely sure what's going on here. Best guess is phan isn't able
to figure out that array + mixed will result in an array, and then
adding validNamespaces (another array) is ok. Could make things a little
more explicit with array_merge, but this seems to work to remove the
issue without changing the meaning of the code.

Change-Id: I7031ae4e68878ec3198e47c55ab5de4d52a6d922

languages/Language.php

index 3eb6546..0e91e2e 100644 (file)
@@ -45,7 +45,9 @@ class Language {
        public $dateFormatStrings = [];
        public $mExtendedSpecialPageAliases;
 
-       protected $namespaceNames, $mNamespaceIds, $namespaceAliases;
+       /** @var array|null */
+       protected $namespaceNames;
+       protected $mNamespaceIds, $namespaceAliases;
 
        /**
         * ReplacementArray object caches
@@ -463,11 +465,11 @@ class Language {
                if ( is_null( $this->namespaceNames ) ) {
                        global $wgMetaNamespace, $wgMetaNamespaceTalk, $wgExtraNamespaces;
 
-                       $this->namespaceNames = self::$dataCache->getItem( $this->mCode, 'namespaceNames' );
                        $validNamespaces = MWNamespace::getCanonicalNamespaces();
 
-                       /** @suppress PhanTypeInvalidLeftOperand */
-                       $this->namespaceNames = $wgExtraNamespaces + $this->namespaceNames + $validNamespaces;
+                       $this->namespaceNames = $wgExtraNamespaces +
+                               self::$dataCache->getItem( $this->mCode, 'namespaceNames' );
+                       $this->namespaceNames += $validNamespaces;
 
                        $this->namespaceNames[NS_PROJECT] = $wgMetaNamespace;
                        if ( $wgMetaNamespaceTalk ) {