From: Kunal Mehta Date: Fri, 18 May 2018 06:27:42 +0000 (-0700) Subject: Enable "PhanTypeInvalidRightOperand" phan checks X-Git-Tag: 1.34.0-rc.0~5402^2 X-Git-Url: http://git.cyclocoop.org/%22%20.%20generer_url_ecrire%28%22auteur_infos%22%2C%22id_auteur=%24connect_id_auteur%22%29%20.%20%22?a=commitdiff_plain;h=c381dd0a997305105cfb2375f4daf2e4c53fb1f5;p=lhc%2Fweb%2Fwiklou.git 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 --- 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