Merge "Improve docs from parser objects PPNode/PPFrame"

This commit is contained in:
jenkins-bot 2021-02-05 21:52:37 +00:00 committed by Gerrit Code Review
commit 15ea8da052
9 changed files with 60 additions and 17 deletions

View file

@ -26,8 +26,13 @@
// phpcs:ignore Squiz.Classes.ValidClassName.NotCamelCaps
class PPCustomFrame_Hash extends PPFrame_Hash {
/** @var array */
public $args;
/**
* @param Preprocessor $preprocessor
* @param array $args
*/
public function __construct( $preprocessor, $args ) {
parent::__construct( $preprocessor );
$this->args = $args;
@ -58,7 +63,7 @@ class PPCustomFrame_Hash extends PPFrame_Hash {
/**
* @param int|string $index
* @return string|bool
* @return string|false
*/
public function getArgument( $index ) {
return $this->args[$index] ?? false;

View file

@ -26,6 +26,7 @@
class PPDStack {
/** @var PPDStackElement[] */
public $stack;
/** @var string|array */
public $rootAccum;
/** @var string|array */
public $accum;
@ -58,7 +59,7 @@ class PPDStack {
}
/**
* @return bool|PPDPart
* @return false|PPDPart
*/
public function getCurrentPart() {
if ( $this->top === false ) {

View file

@ -57,8 +57,12 @@ class PPDStackElement {
*/
public $lineStart;
/** @var string */
public $partClass = PPDPart::class;
/**
* @param array $data
*/
public function __construct( $data = [] ) {
$class = $this->partClass;
$this->parts = [ new $class ];

View file

@ -40,21 +40,29 @@ class PPFrame_Hash implements PPFrame {
* @var Title
*/
public $title;
/**
* @var (string|false)[]
*/
public $titleCache;
/**
* Hashtable listing templates which are disallowed for expansion in this frame,
* having been encountered previously in parent frames.
* @var string[]
*/
public $loopCheckHash;
/**
* Recursion depth of this frame, top = 0
* Note that this is NOT the same as expansion depth in expand()
* @var int
*/
public $depth;
/** @var bool */
private $volatile = false;
/** @var int|null */
private $ttl = null;
/**
@ -79,8 +87,8 @@ class PPFrame_Hash implements PPFrame {
* Create a new child frame
* $args is optionally a multi-root PPNode or array containing the template arguments
*
* @param array|bool|PPNode_Hash_Array $args
* @param Title|bool $title
* @param array|false|PPNode_Hash_Array $args
* @param Title|false $title
* @param int $indexOffset
* @throws MWException
* @return PPTemplateFrame_Hash
@ -500,8 +508,8 @@ class PPFrame_Hash implements PPFrame {
}
/**
* @param bool $level
* @return array|bool|string
* @param string|false $level
* @return array|false|string
*/
public function getPDBK( $level = false ) {
if ( $level === false ) {

View file

@ -25,8 +25,12 @@
// phpcs:ignore Squiz.Classes.ValidClassName.NotCamelCaps
class PPNode_Hash_Array implements PPNode {
/** @var array */
public $value;
/**
* @param array $value
*/
public function __construct( $value ) {
$this->value = $value;
}

View file

@ -25,8 +25,14 @@
// phpcs:ignore Squiz.Classes.ValidClassName.NotCamelCaps
class PPNode_Hash_Attr implements PPNode {
public $name, $value;
private $store, $index;
/** @var string */
public $name;
/** @var string */
public $value;
/** @var array */
private $store;
/** @var int */
private $index;
/**
* Construct an object using the data from $store[$index]. The rest of the

View file

@ -25,8 +25,12 @@
// phpcs:ignore Squiz.Classes.ValidClassName.NotCamelCaps
class PPNode_Hash_Text implements PPNode {
/** @var string */
public $value;
private $store, $index;
/** @var array */
private $store;
/** @var int */
private $index;
/**
* Construct an object using the data from $store[$index]. The rest of the

View file

@ -25,22 +25,26 @@
// phpcs:ignore Squiz.Classes.ValidClassName.NotCamelCaps
class PPNode_Hash_Tree implements PPNode {
/** @var string */
public $name;
/**
* The store array for children of this node. It is "raw" in the sense that
* nodes are two-element arrays ("descriptors") rather than PPNode_Hash_*
* objects.
* @var array
*/
private $rawChildren;
/**
* The store array for the siblings of this node, including this node itself.
* @var array
*/
private $store;
/**
* The index into $this->store which contains the descriptor of this node.
* @var int
*/
private $index;

View file

@ -26,15 +26,23 @@
// phpcs:ignore Squiz.Classes.ValidClassName.NotCamelCaps
class PPTemplateFrame_Hash extends PPFrame_Hash {
public $numberedArgs, $namedArgs, $parent;
public $numberedExpansionCache, $namedExpansionCache;
/** @var array */
public $numberedArgs;
/** @var array */
public $namedArgs;
/** @var PPFrame_Hash */
public $parent;
/** @var array */
public $numberedExpansionCache;
/** @var array */
public $namedExpansionCache;
/**
* @param Preprocessor $preprocessor
* @param bool|PPFrame $parent
* @param false|PPFrame $parent
* @param array $numberedArgs
* @param array $namedArgs
* @param bool|Title $title
* @param false|Title $title
*/
public function __construct( $preprocessor, $parent = false, $numberedArgs = [],
$namedArgs = [], $title = false
@ -62,7 +70,6 @@ class PPTemplateFrame_Hash extends PPFrame_Hash {
$s = 'tplframe{';
$first = true;
$args = $this->numberedArgs + $this->namedArgs;
// @phan-suppress-next-line PhanTypeMismatchForeach FIXME args need better documentation
foreach ( $args as $name => $value ) {
if ( $first ) {
$first = false;
@ -140,7 +147,7 @@ class PPTemplateFrame_Hash extends PPFrame_Hash {
/**
* @param int $index
* @return string|bool
* @return string|false
*/
public function getNumberedArgument( $index ) {
if ( !isset( $this->numberedArgs[$index] ) ) {
@ -158,7 +165,7 @@ class PPTemplateFrame_Hash extends PPFrame_Hash {
/**
* @param string $name
* @return string|bool
* @return string|false
*/
public function getNamedArgument( $name ) {
if ( !isset( $this->namedArgs[$name] ) ) {
@ -175,7 +182,7 @@ class PPTemplateFrame_Hash extends PPFrame_Hash {
/**
* @param int|string $name
* @return string|bool
* @return string|false
*/
public function getArgument( $name ) {
$text = $this->getNumberedArgument( $name );