From c381dd0a997305105cfb2375f4daf2e4c53fb1f5 Mon Sep 17 00:00:00 2001 From: Kunal Mehta Date: Thu, 17 May 2018 23:27:42 -0700 Subject: [PATCH] Enable "PhanTypeInvalidRightOperand" phan checks 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 | 3 +++ includes/libs/ReplacementArray.php | 8 ++++---- tests/phan/config.php | 2 -- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/includes/htmlform/HTMLFormField.php b/includes/htmlform/HTMLFormField.php index aab881129b..5066f28ee4 100644 --- a/includes/htmlform/HTMLFormField.php +++ b/includes/htmlform/HTMLFormField.php @@ -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; diff --git a/includes/libs/ReplacementArray.php b/includes/libs/ReplacementArray.php index 4512a4b13d..46f9358b63 100644 --- a/includes/libs/ReplacementArray.php +++ b/includes/libs/ReplacementArray.php @@ -22,14 +22,14 @@ * 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; diff --git a/tests/phan/config.php b/tests/phan/config.php index bebdd3da5f..d9ce429ba2 100644 --- a/tests/phan/config.php +++ b/tests/phan/config.php @@ -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 -- 2.20.1