Improve type hints in parser related classes
Change-Id: Ia07a2eb32894f96b195fa3189fb5f617e68f2581
This commit is contained in:
parent
a3b4288eac
commit
dd25f3df6b
8 changed files with 29 additions and 21 deletions
|
|
@ -27,7 +27,7 @@ class PPDStack {
|
||||||
public $stack, $rootAccum;
|
public $stack, $rootAccum;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var PPDStack
|
* @var PPDStack|false
|
||||||
*/
|
*/
|
||||||
public $top;
|
public $top;
|
||||||
public $out;
|
public $out;
|
||||||
|
|
|
||||||
|
|
@ -141,7 +141,7 @@ class PPFrame_DOM implements PPFrame {
|
||||||
/**
|
/**
|
||||||
* @throws MWException
|
* @throws MWException
|
||||||
* @param string|int $key
|
* @param string|int $key
|
||||||
* @param string|PPNode_DOM|DOMDocument $root
|
* @param string|PPNode_DOM|DOMNode|DOMNodeList $root
|
||||||
* @param int $flags
|
* @param int $flags
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
|
|
@ -152,7 +152,7 @@ class PPFrame_DOM implements PPFrame {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @throws MWException
|
* @throws MWException
|
||||||
* @param string|PPNode_DOM|DOMDocument $root
|
* @param string|PPNode_DOM|DOMNode $root
|
||||||
* @param int $flags
|
* @param int $flags
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
|
|
@ -396,7 +396,7 @@ class PPFrame_DOM implements PPFrame {
|
||||||
/**
|
/**
|
||||||
* @param string $sep
|
* @param string $sep
|
||||||
* @param int $flags
|
* @param int $flags
|
||||||
* @param string|PPNode_DOM|DOMDocument ...$args
|
* @param string|PPNode_DOM|DOMNode ...$args
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function implodeWithFlags( $sep, $flags, ...$args ) {
|
public function implodeWithFlags( $sep, $flags, ...$args ) {
|
||||||
|
|
@ -426,7 +426,7 @@ class PPFrame_DOM implements PPFrame {
|
||||||
* This previously called implodeWithFlags but has now been inlined to reduce stack depth
|
* This previously called implodeWithFlags but has now been inlined to reduce stack depth
|
||||||
*
|
*
|
||||||
* @param string $sep
|
* @param string $sep
|
||||||
* @param string|PPNode_DOM|DOMDocument ...$args
|
* @param string|PPNode_DOM|DOMNode ...$args
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function implode( $sep, ...$args ) {
|
public function implode( $sep, ...$args ) {
|
||||||
|
|
@ -456,7 +456,7 @@ class PPFrame_DOM implements PPFrame {
|
||||||
* with implode()
|
* with implode()
|
||||||
*
|
*
|
||||||
* @param string $sep
|
* @param string $sep
|
||||||
* @param string|PPNode_DOM|DOMDocument ...$args
|
* @param string|PPNode_DOM|DOMNode ...$args
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
public function virtualImplode( $sep, ...$args ) {
|
public function virtualImplode( $sep, ...$args ) {
|
||||||
|
|
@ -487,7 +487,7 @@ class PPFrame_DOM implements PPFrame {
|
||||||
* @param string $start
|
* @param string $start
|
||||||
* @param string $sep
|
* @param string $sep
|
||||||
* @param string $end
|
* @param string $end
|
||||||
* @param string|PPNode_DOM|DOMDocument ...$args
|
* @param string|PPNode_DOM|DOMNode ...$args
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
public function virtualBracketedImplode( $start, $sep, $end, ...$args ) {
|
public function virtualBracketedImplode( $start, $sep, $end, ...$args ) {
|
||||||
|
|
|
||||||
|
|
@ -36,20 +36,20 @@ interface PPNode {
|
||||||
/**
|
/**
|
||||||
* Get an array-type node containing the children of this node.
|
* Get an array-type node containing the children of this node.
|
||||||
* Returns false if this is not a tree node.
|
* Returns false if this is not a tree node.
|
||||||
* @return PPNode
|
* @return false|PPNode
|
||||||
*/
|
*/
|
||||||
public function getChildren();
|
public function getChildren();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the first child of a tree node. False if there isn't one.
|
* Get the first child of a tree node. False if there isn't one.
|
||||||
*
|
*
|
||||||
* @return PPNode
|
* @return false|PPNode
|
||||||
*/
|
*/
|
||||||
public function getFirstChild();
|
public function getFirstChild();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the next sibling of any node. False if there isn't one
|
* Get the next sibling of any node. False if there isn't one
|
||||||
* @return PPNode
|
* @return false|PPNode
|
||||||
*/
|
*/
|
||||||
public function getNextSibling();
|
public function getNextSibling();
|
||||||
|
|
||||||
|
|
@ -57,7 +57,7 @@ interface PPNode {
|
||||||
* Get all children of this tree node which have a given name.
|
* Get all children of this tree node which have a given name.
|
||||||
* Returns an array-type node, or false if this is not a tree node.
|
* Returns an array-type node, or false if this is not a tree node.
|
||||||
* @param string $type
|
* @param string $type
|
||||||
* @return bool|PPNode
|
* @return false|PPNode
|
||||||
*/
|
*/
|
||||||
public function getChildrenOfType( $type );
|
public function getChildrenOfType( $type );
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,7 @@
|
||||||
class PPNode_DOM implements PPNode {
|
class PPNode_DOM implements PPNode {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var DOMElement
|
* @var DOMElement|DOMNodeList
|
||||||
*/
|
*/
|
||||||
public $node;
|
public $node;
|
||||||
public $xpath;
|
public $xpath;
|
||||||
|
|
@ -59,21 +59,21 @@ class PPNode_DOM implements PPNode {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return bool|PPNode_DOM
|
* @return false|PPNode_DOM
|
||||||
*/
|
*/
|
||||||
public function getChildren() {
|
public function getChildren() {
|
||||||
return $this->node->childNodes ? new self( $this->node->childNodes ) : false;
|
return $this->node->childNodes ? new self( $this->node->childNodes ) : false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return bool|PPNode_DOM
|
* @return false|PPNode_DOM
|
||||||
*/
|
*/
|
||||||
public function getFirstChild() {
|
public function getFirstChild() {
|
||||||
return $this->node->firstChild ? new self( $this->node->firstChild ) : false;
|
return $this->node->firstChild ? new self( $this->node->firstChild ) : false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return bool|PPNode_DOM
|
* @return false|PPNode_DOM
|
||||||
*/
|
*/
|
||||||
public function getNextSibling() {
|
public function getNextSibling() {
|
||||||
return $this->node->nextSibling ? new self( $this->node->nextSibling ) : false;
|
return $this->node->nextSibling ? new self( $this->node->nextSibling ) : false;
|
||||||
|
|
@ -82,7 +82,7 @@ class PPNode_DOM implements PPNode {
|
||||||
/**
|
/**
|
||||||
* @param string $type
|
* @param string $type
|
||||||
*
|
*
|
||||||
* @return bool|PPNode_DOM
|
* @return false|PPNode_DOM
|
||||||
*/
|
*/
|
||||||
public function getChildrenOfType( $type ) {
|
public function getChildrenOfType( $type ) {
|
||||||
return new self( $this->getXPath()->query( $type, $this->node ) );
|
return new self( $this->getXPath()->query( $type, $this->node ) );
|
||||||
|
|
|
||||||
|
|
@ -135,7 +135,7 @@ class PPNode_Hash_Tree implements PPNode {
|
||||||
* return a temporary proxy object: different instances will be returned
|
* return a temporary proxy object: different instances will be returned
|
||||||
* if this is called more than once on the same node.
|
* if this is called more than once on the same node.
|
||||||
*
|
*
|
||||||
* @return PPNode_Hash_Tree|PPNode_Hash_Attr|PPNode_Hash_Text|bool
|
* @return PPNode_Hash_Tree|PPNode_Hash_Attr|PPNode_Hash_Text|false
|
||||||
*/
|
*/
|
||||||
public function getFirstChild() {
|
public function getFirstChild() {
|
||||||
if ( !isset( $this->rawChildren[0] ) ) {
|
if ( !isset( $this->rawChildren[0] ) ) {
|
||||||
|
|
@ -150,7 +150,7 @@ class PPNode_Hash_Tree implements PPNode {
|
||||||
* return a temporary proxy object: different instances will be returned
|
* return a temporary proxy object: different instances will be returned
|
||||||
* if this is called more than once on the same node.
|
* if this is called more than once on the same node.
|
||||||
*
|
*
|
||||||
* @return PPNode_Hash_Tree|PPNode_Hash_Attr|PPNode_Hash_Text|bool
|
* @return PPNode_Hash_Tree|PPNode_Hash_Attr|PPNode_Hash_Text|false
|
||||||
*/
|
*/
|
||||||
public function getNextSibling() {
|
public function getNextSibling() {
|
||||||
return self::factory( $this->store, $this->index + 1 );
|
return self::factory( $this->store, $this->index + 1 );
|
||||||
|
|
|
||||||
|
|
@ -205,9 +205,11 @@ class Parser {
|
||||||
public $mLinkID;
|
public $mLinkID;
|
||||||
public $mIncludeSizes, $mPPNodeCount, $mGeneratedPPNodeCount, $mHighestExpansionDepth;
|
public $mIncludeSizes, $mPPNodeCount, $mGeneratedPPNodeCount, $mHighestExpansionDepth;
|
||||||
public $mDefaultSort;
|
public $mDefaultSort;
|
||||||
public $mTplRedirCache, $mTplDomCache, $mHeadings, $mDoubleUnderscores;
|
public $mTplRedirCache, $mHeadings, $mDoubleUnderscores;
|
||||||
public $mExpensiveFunctionCount; # number of expensive parser function calls
|
public $mExpensiveFunctionCount; # number of expensive parser function calls
|
||||||
public $mShowToc, $mForceTocPosition;
|
public $mShowToc, $mForceTocPosition;
|
||||||
|
/** @var array */
|
||||||
|
public $mTplDomCache;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var User
|
* @var User
|
||||||
|
|
@ -3084,7 +3086,7 @@ class Parser {
|
||||||
* self::OT_HTML: all templates and extension tags
|
* self::OT_HTML: all templates and extension tags
|
||||||
*
|
*
|
||||||
* @param string $text The text to transform
|
* @param string $text The text to transform
|
||||||
* @param bool|PPFrame $frame Object describing the arguments passed to the
|
* @param false|PPFrame|array $frame Object describing the arguments passed to the
|
||||||
* template. Arguments may also be provided as an associative array, as
|
* template. Arguments may also be provided as an associative array, as
|
||||||
* was the usual case before MW1.12. Providing arguments this way may be
|
* was the usual case before MW1.12. Providing arguments this way may be
|
||||||
* useful for extensions wishing to perform variable replacement
|
* useful for extensions wishing to perform variable replacement
|
||||||
|
|
@ -3190,7 +3192,7 @@ class Parser {
|
||||||
* $piece['lineStart']: whether the brace was at the start of a line
|
* $piece['lineStart']: whether the brace was at the start of a line
|
||||||
* @param PPFrame $frame The current frame, contains template arguments
|
* @param PPFrame $frame The current frame, contains template arguments
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
* @return string The text of the template
|
* @return string|array The text of the template
|
||||||
*/
|
*/
|
||||||
public function braceSubstitution( $piece, $frame ) {
|
public function braceSubstitution( $piece, $frame ) {
|
||||||
// Flags
|
// Flags
|
||||||
|
|
|
||||||
|
|
@ -37,6 +37,9 @@ class Preprocessor_DOM extends Preprocessor {
|
||||||
|
|
||||||
const CACHE_PREFIX = 'preprocess-xml';
|
const CACHE_PREFIX = 'preprocess-xml';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param Parser $parser
|
||||||
|
*/
|
||||||
public function __construct( $parser ) {
|
public function __construct( $parser ) {
|
||||||
wfDeprecated( __METHOD__, '1.34' ); // T204945
|
wfDeprecated( __METHOD__, '1.34' ); // T204945
|
||||||
$this->parser = $parser;
|
$this->parser = $parser;
|
||||||
|
|
|
||||||
|
|
@ -50,6 +50,9 @@ class Preprocessor_Hash extends Preprocessor {
|
||||||
const CACHE_PREFIX = 'preprocess-hash';
|
const CACHE_PREFIX = 'preprocess-hash';
|
||||||
const CACHE_VERSION = 2;
|
const CACHE_VERSION = 2;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param Parser $parser
|
||||||
|
*/
|
||||||
public function __construct( $parser ) {
|
public function __construct( $parser ) {
|
||||||
$this->parser = $parser;
|
$this->parser = $parser;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue