From 6b80d71f191ac73b914921846cadd3d5bf0e0206 Mon Sep 17 00:00:00 2001 From: Kunal Mehta Date: Sat, 6 Apr 2019 00:07:54 -0700 Subject: [PATCH] Fix phan errors by improving documentation (#10) PhanTypeExpectedObjectPropAccess was flagged by phan in the DatabaseMysqli and Preprocessor_Hash classes. In Database, the $conn property might be a standard object, such as `\mysqli`, which is not a resource. In Preprocessor, phan was getting confused and thinking PPDStack::getCurrentPart() was returning bool, and not a PPDPart object. Adding explicit documentation about the return value fixed that. Change-Id: I0a3aa219693da5cb46ff9c0936841ed740c6968a --- .phan/config.php | 2 -- includes/libs/rdbms/database/Database.php | 2 +- includes/parser/Preprocessor_DOM.php | 6 ++++++ 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/.phan/config.php b/.phan/config.php index c250bcd7ee..c754480e87 100644 --- a/.phan/config.php +++ b/.phan/config.php @@ -99,8 +99,6 @@ $cfg['suppress_issue_types'] = array_merge( $cfg['suppress_issue_types'], [ "PhanTypeComparisonFromArray", // approximate error count: 2 "PhanTypeComparisonToArray", - // approximate error count: 7 - "PhanTypeExpectedObjectPropAccess", // approximate error count: 63 "PhanTypeInvalidDimOffset", // approximate error count: 6 diff --git a/includes/libs/rdbms/database/Database.php b/includes/libs/rdbms/database/Database.php index a839946285..503ca27e20 100644 --- a/includes/libs/rdbms/database/Database.php +++ b/includes/libs/rdbms/database/Database.php @@ -104,7 +104,7 @@ abstract class Database implements IDatabase, IMaintainableDatabase, LoggerAware /** @var callable Deprecation logging callback */ protected $deprecationLogger; - /** @var resource|null Database connection */ + /** @var object|resource|null Database connection */ protected $conn = null; /** @var bool */ protected $opened = false; diff --git a/includes/parser/Preprocessor_DOM.php b/includes/parser/Preprocessor_DOM.php index 3bcd012f4f..4ed6b791fe 100644 --- a/includes/parser/Preprocessor_DOM.php +++ b/includes/parser/Preprocessor_DOM.php @@ -858,6 +858,9 @@ class PPDStack { return $this->accum; } + /** + * @return bool|PPDPart + */ public function getCurrentPart() { if ( $this->top === false ) { return false; @@ -970,6 +973,9 @@ class PPDStackElement { $this->parts[] = new $class( $s ); } + /** + * @return PPDPart + */ public function getCurrentPart() { return $this->parts[count( $this->parts ) - 1]; } -- 2.20.1