Fix phan errors by improving documentation (#10)
authorKunal Mehta <legoktm@member.fsf.org>
Sat, 6 Apr 2019 07:07:54 +0000 (00:07 -0700)
committerKunal Mehta <legoktm@member.fsf.org>
Sat, 6 Apr 2019 07:07:54 +0000 (00:07 -0700)
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
includes/libs/rdbms/database/Database.php
includes/parser/Preprocessor_DOM.php

index c250bcd..c754480 100644 (file)
@@ -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
index a839946..503ca27 100644 (file)
@@ -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;
index 3bcd012..4ed6b79 100644 (file)
@@ -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];
        }