Enable "PhanTypeInvalidRightOperand" phan checks
authorKunal Mehta <legoktm@member.fsf.org>
Fri, 18 May 2018 06:27:42 +0000 (23:27 -0700)
committerKunal Mehta <legoktm@member.fsf.org>
Fri, 18 May 2018 06:27:42 +0000 (23:27 -0700)
HTMLFormField subclasses triggered false positives when phan incorrectly
thought that $this->mOptions was only a boolean.

ReplacementArray $this->data was defined as possibly being boolean, but
in reality that never happened.

Change-Id: I06bae9c9952366ff7927df37373b146d570f4a02

includes/htmlform/HTMLFormField.php
includes/libs/ReplacementArray.php
tests/phan/config.php

index aab8811..5066f28 100644 (file)
@@ -17,6 +17,9 @@ abstract class HTMLFormField {
        protected $mVFormClass = '';
        protected $mHelpClass = false;
        protected $mDefault;
+       /**
+        * @var array|bool|null
+        */
        protected $mOptions = false;
        protected $mOptionsLabelsNotFromMessage = false;
        protected $mHideIf = null;
index 4512a4b..46f9358 100644 (file)
  * Wrapper around strtr() that holds replacements
  */
 class ReplacementArray {
-       private $data = false;
+       private $data = [];
 
        /**
         * Create an object with the specified replacement array
         * The array should have the same form as the replacement array for strtr()
         * @param array $data
         */
-       public function __construct( $data = [] ) {
+       public function __construct( array $data = [] ) {
                $this->data = $data;
        }
 
@@ -44,12 +44,12 @@ class ReplacementArray {
         * Set the whole replacement array at once
         * @param array $data
         */
-       public function setArray( $data ) {
+       public function setArray( array $data ) {
                $this->data = $data;
        }
 
        /**
-        * @return array|bool
+        * @return array
         */
        public function getArray() {
                return $this->data;
index bebdd3d..d9ce429 100644 (file)
@@ -329,8 +329,6 @@ return [
                "PhanTypeComparisonFromArray",
                // approximate error count: 2
                "PhanTypeComparisonToArray",
-               // approximate error count: 3
-               "PhanTypeInvalidRightOperand",
                // approximate error count: 1
                "PhanTypeMagicVoidWithReturn",
                // approximate error count: 218