parser: Declare some dynamic properties
authorDaimona Eaytoy <daimona.wiki@gmail.com>
Sun, 8 Sep 2019 17:18:27 +0000 (19:18 +0200)
committerKrinkle <krinklemail@gmail.com>
Sun, 8 Sep 2019 19:03:03 +0000 (19:03 +0000)
Mostly via the @property annotation. This is to make phan a little
happier.

Change-Id: I3fde33955240dab20870821e9db93caba163845b

includes/parser/PPDPart.php
includes/parser/PPDStack.php
includes/parser/PPDStackElement.php
includes/parser/PPFrame.php
includes/parser/PPFrame_DOM.php
includes/parser/PPTemplateFrame_Hash.php
includes/parser/Preprocessor.php
includes/parser/Preprocessor_Hash.php

index b56527a..6b63a0d 100644 (file)
 
 /**
  * @ingroup Parser
+ *
+ * @property int $eqpos
+ * @property int $commentEnd
+ * @property int $visualEnd
  */
 class PPDPart {
        /**
index 68f1bb2..b9d796d 100644 (file)
@@ -27,6 +27,8 @@ class PPDStack {
        /** @var PPDStackElement[] */
        public $stack;
        public $rootAccum;
+       /** @var string|array */
+       public $accum;
 
        /**
         * @var PPDStackElement|false
index 116244d..fe2b04e 100644 (file)
@@ -21,6 +21,8 @@
 
 /**
  * @ingroup Parser
+ *
+ * @property int $startPos
  */
 class PPDStackElement {
        /**
index 3f147f0..b50fcfc 100644 (file)
@@ -21,6 +21,9 @@
 
 /**
  * @ingroup Parser
+ *
+ * @property int $depth
+ * @property PPFrame $parent
  */
 interface PPFrame {
        const NO_ARGS = 1;
index bb310f2..a0ec326 100644 (file)
@@ -82,7 +82,7 @@ class PPFrame_DOM implements PPFrame {
         * Create a new child frame
         * $args is optionally a multi-root PPNode or array containing the template arguments
         *
-        * @param bool|array $args
+        * @param bool|array|PPNode_DOM $args
         * @param Title|bool $title
         * @param int $indexOffset
         * @return PPTemplateFrame_DOM
@@ -95,11 +95,12 @@ class PPFrame_DOM implements PPFrame {
                }
                if ( $args !== false ) {
                        $xpath = false;
-                       if ( $args instanceof PPNode ) {
+                       if ( $args instanceof PPNode_DOM ) {
                                $args = $args->node;
                        }
+                       // @phan-suppress-next-line PhanTypeSuspiciousNonTraversableForeach
                        foreach ( $args as $arg ) {
-                               if ( $arg instanceof PPNode ) {
+                               if ( $arg instanceof PPNode_DOM ) {
                                        $arg = $arg->node;
                                }
                                if ( !$xpath || $xpath->document !== $arg->ownerDocument ) {
index df740cf..902e4f1 100644 (file)
@@ -40,6 +40,8 @@ class PPTemplateFrame_Hash extends PPFrame_Hash {
                $namedArgs = [], $title = false
        ) {
                parent::__construct( $preprocessor );
+               /** @var PPFrame_Hash parent */
+               '@phan-var PPFrame_Hash $parent';
 
                $this->parent = $parent;
                $this->numberedArgs = $numberedArgs;
index 99ca1be..19dd96e 100644 (file)
@@ -31,6 +31,11 @@ abstract class Preprocessor {
 
        const CACHE_VERSION = 1;
 
+       /**
+        * @var Parser
+        */
+       public $parser;
+
        /**
         * @var array Brace matching rules.
         */
index 9f4b7c7..7c372ee 100644 (file)
  */
 // phpcs:ignore Squiz.Classes.ValidClassName.NotCamelCaps
 class Preprocessor_Hash extends Preprocessor {
-
-       /**
-        * @var Parser
-        */
-       public $parser;
-
        const CACHE_PREFIX = 'preprocess-hash';
        const CACHE_VERSION = 2;