* * attribute nodes are children
* * "<h>" nodes that aren't at the top are replaced with <possible-h>
* @ingroup Parser
+ * @codingStandardsIgnoreStart
*/
class Preprocessor_Hash implements Preprocessor {
+ // @codingStandardsIgnoreEnd
+
/**
* @var Parser
*/
- var $parser;
+ public $parser;
const CACHE_VERSION = 1;
- function __construct( $parser ) {
+ public function __construct( $parser ) {
$this->parser = $parser;
}
/**
* @return PPFrame_Hash
*/
- function newFrame() {
+ public function newFrame() {
return new PPFrame_Hash( $this );
}
* @param array $args
* @return PPCustomFrame_Hash
*/
- function newCustomFrame( $args ) {
+ public function newCustomFrame( $args ) {
return new PPCustomFrame_Hash( $this, $args );
}
* @param array $values
* @return PPNode_Hash_Array
*/
- function newPartNodeArray( $values ) {
+ public function newPartNodeArray( $values ) {
$list = array();
foreach ( $values as $k => $val ) {
* @throws MWException
* @return PPNode_Hash_Tree
*/
- function preprocessToObj( $text, $flags = 0 ) {
+ public function preprocessToObj( $text, $flags = 0 ) {
wfProfileIn( __METHOD__ );
// Check cache.
/**
* Stack class to help Preprocessor::preprocessToObj()
* @ingroup Parser
+ * @codingStandardsIgnoreStart
*/
class PPDStack_Hash extends PPDStack {
- function __construct() {
+ // @codingStandardsIgnoreEnd
+
+ public function __construct() {
$this->elementClass = 'PPDStackElement_Hash';
parent::__construct();
$this->rootAccum = new PPDAccum_Hash;
/**
* @ingroup Parser
+ * @codingStandardsIgnoreStart
*/
class PPDStackElement_Hash extends PPDStackElement {
- function __construct( $data = array() ) {
+ // @codingStandardsIgnoreENd
+
+ public function __construct( $data = array() ) {
$this->partClass = 'PPDPart_Hash';
parent::__construct( $data );
}
* @param int|bool $openingCount
* @return PPDAccum_Hash
*/
- function breakSyntax( $openingCount = false ) {
+ public function breakSyntax( $openingCount = false ) {
if ( $this->open == "\n" ) {
$accum = $this->parts[0]->out;
} else {
/**
* @ingroup Parser
+ * @codingStandardsIgnoreStart
*/
class PPDPart_Hash extends PPDPart {
- function __construct( $out = '' ) {
+ // @codingStandardsIgnoreEnd
+
+ public function __construct( $out = '' ) {
$accum = new PPDAccum_Hash;
if ( $out !== '' ) {
$accum->addLiteral( $out );
/**
* @ingroup Parser
+ * @codingStandardsIgnoreStart
*/
class PPDAccum_Hash {
- var $firstNode, $lastNode;
+ // @codingStandardsIgnoreEnd
+
+ public $firstNode, $lastNode;
- function __construct() {
+ public function __construct() {
$this->firstNode = $this->lastNode = false;
}
* Append a string literal
* @param string $s
*/
- function addLiteral( $s ) {
+ public function addLiteral( $s ) {
if ( $this->lastNode === false ) {
$this->firstNode = $this->lastNode = new PPNode_Hash_Text( $s );
} elseif ( $this->lastNode instanceof PPNode_Hash_Text ) {
* Append a PPNode
* @param PPNode $node
*/
- function addNode( PPNode $node ) {
+ public function addNode( PPNode $node ) {
if ( $this->lastNode === false ) {
$this->firstNode = $this->lastNode = $node;
} else {
* @param string $name
* @param string $value
*/
- function addNodeWithText( $name, $value ) {
+ public function addNodeWithText( $name, $value ) {
$node = PPNode_Hash_Tree::newWithText( $name, $value );
$this->addNode( $node );
}
* subsequently be modified, especially nextSibling.
* @param PPDAccum_Hash $accum
*/
- function addAccum( $accum ) {
+ public function addAccum( $accum ) {
if ( $accum->lastNode === false ) {
// nothing to add
} elseif ( $this->lastNode === false ) {
/**
* An expansion frame, used as a context to expand the result of preprocessToObj()
* @ingroup Parser
+ * @codingStandardsIgnoreStart
*/
class PPFrame_Hash implements PPFrame {
+ // @codingStandardsIgnoreEnd
/**
* @var Parser
*/
- var $parser;
+ public $parser;
/**
* @var Preprocessor
*/
- var $preprocessor;
+ public $preprocessor;
/**
* @var Title
*/
- var $title;
- var $titleCache;
+ public $title;
+ public $titleCache;
/**
* Hashtable listing templates which are disallowed for expansion in this frame,
* having been encountered previously in parent frames.
*/
- var $loopCheckHash;
+ public $loopCheckHash;
/**
* Recursion depth of this frame, top = 0
* Note that this is NOT the same as expansion depth in expand()
*/
- var $depth;
+ public $depth;
private $volatile = false;
private $ttl = null;
* Construct a new preprocessor frame.
* @param Preprocessor $preprocessor The parent preprocessor
*/
- function __construct( $preprocessor ) {
+ public function __construct( $preprocessor ) {
$this->preprocessor = $preprocessor;
$this->parser = $preprocessor->parser;
$this->title = $this->parser->mTitle;
* @throws MWException
* @return PPTemplateFrame_Hash
*/
- function newChild( $args = false, $title = false, $indexOffset = 0 ) {
+ public function newChild( $args = false, $title = false, $indexOffset = 0 ) {
$namedArgs = array();
$numberedArgs = array();
if ( $title === false ) {
* @param int $flags
* @return string
*/
- function cachedExpand( $key, $root, $flags = 0 ) {
+ public function cachedExpand( $key, $root, $flags = 0 ) {
// we don't have a parent, so we don't have a cache
return $this->expand( $root, $flags );
}
/**
* @throws MWException
- * @param string|PPNode$root
+ * @param string|PPNode $root
* @param int $flags
* @return string
*/
- function expand( $root, $flags = 0 ) {
+ public function expand( $root, $flags = 0 ) {
static $expansionDepth = 0;
if ( is_string( $root ) ) {
return $root;
} elseif ( $contextNode->name == 'ext' ) {
# Extension tag
$bits = $contextNode->splitExt() + array( 'attr' => null, 'inner' => null, 'close' => null );
- $out .= $this->parser->extensionSubstitution( $bits, $this );
+ if ( $flags & PPFrame::NO_TAGS ) {
+ $s = '<' . $bits['name']->firstChild->value;
+ if ( $bits['attr'] ) {
+ $s .= $bits['attr']->firstChild->value;
+ }
+ if ( $bits['inner'] ) {
+ $s .= '>' . $bits['inner']->firstChild->value;
+ if ( $bits['close'] ) {
+ $s .= $bits['close']->firstChild->value;
+ }
+ } else {
+ $s .= '/>';
+ }
+ $out .= $s;
+ } else {
+ $out .= $this->parser->extensionSubstitution( $bits, $this );
+ }
} elseif ( $contextNode->name == 'h' ) {
# Heading
if ( $this->parser->ot['html'] ) {
* @param int $flags
* @return string
*/
- function implodeWithFlags( $sep, $flags /*, ... */ ) {
+ public function implodeWithFlags( $sep, $flags /*, ... */ ) {
$args = array_slice( func_get_args(), 2 );
$first = true;
* @param string $sep
* @return string
*/
- function implode( $sep /*, ... */ ) {
+ public function implode( $sep /*, ... */ ) {
$args = array_slice( func_get_args(), 1 );
$first = true;
* @param string $sep
* @return PPNode_Hash_Array
*/
- function virtualImplode( $sep /*, ... */ ) {
+ public function virtualImplode( $sep /*, ... */ ) {
$args = array_slice( func_get_args(), 1 );
$out = array();
$first = true;
* @param string $end
* @return PPNode_Hash_Array
*/
- function virtualBracketedImplode( $start, $sep, $end /*, ... */ ) {
+ public function virtualBracketedImplode( $start, $sep, $end /*, ... */ ) {
$args = array_slice( func_get_args(), 3 );
$out = array( $start );
$first = true;
return new PPNode_Hash_Array( $out );
}
- function __toString() {
+ public function __toString() {
return 'frame{}';
}
* @param bool $level
* @return array|bool|string
*/
- function getPDBK( $level = false ) {
+ public function getPDBK( $level = false ) {
if ( $level === false ) {
return $this->title->getPrefixedDBkey();
} else {
/**
* @return array
*/
- function getArguments() {
+ public function getArguments() {
return array();
}
/**
* @return array
*/
- function getNumberedArguments() {
+ public function getNumberedArguments() {
return array();
}
/**
* @return array
*/
- function getNamedArguments() {
+ public function getNamedArguments() {
return array();
}
*
* @return bool
*/
- function isEmpty() {
+ public function isEmpty() {
return true;
}
* @param string $name
* @return bool
*/
- function getArgument( $name ) {
+ public function getArgument( $name ) {
return false;
}
*
* @return bool
*/
- function loopCheck( $title ) {
+ public function loopCheck( $title ) {
return !isset( $this->loopCheckHash[$title->getPrefixedDBkey()] );
}
*
* @return bool
*/
- function isTemplate() {
+ public function isTemplate() {
return false;
}
*
* @return Title
*/
- function getTitle() {
+ public function getTitle() {
return $this->title;
}
*
* @param bool $flag
*/
- function setVolatile( $flag = true ) {
+ public function setVolatile( $flag = true ) {
$this->volatile = $flag;
}
*
* @return bool
*/
- function isVolatile() {
+ public function isVolatile() {
return $this->volatile;
}
*
* @param int $ttl
*/
- function setTTL( $ttl ) {
+ public function setTTL( $ttl ) {
if ( $ttl !== null && ( $this->ttl === null || $ttl < $this->ttl ) ) {
$this->ttl = $ttl;
}
*
* @return int|null
*/
- function getTTL() {
+ public function getTTL() {
return $this->ttl;
}
}
/**
* Expansion frame with template arguments
* @ingroup Parser
+ * @codingStandardsIgnoreStart
*/
class PPTemplateFrame_Hash extends PPFrame_Hash {
- var $numberedArgs, $namedArgs, $parent;
- var $numberedExpansionCache, $namedExpansionCache;
+ // @codingStandardsIgnoreEnd
+
+ public $numberedArgs, $namedArgs, $parent;
+ public $numberedExpansionCache, $namedExpansionCache;
/**
* @param Preprocessor $preprocessor
* @param array $namedArgs
* @param bool|Title $title
*/
- function __construct( $preprocessor, $parent = false, $numberedArgs = array(),
+ public function __construct( $preprocessor, $parent = false, $numberedArgs = array(),
$namedArgs = array(), $title = false
) {
parent::__construct( $preprocessor );
$this->numberedExpansionCache = $this->namedExpansionCache = array();
}
- function __toString() {
+ public function __toString() {
$s = 'tplframe{';
$first = true;
$args = $this->numberedArgs + $this->namedArgs;
* @param int $flags
* @return string
*/
- function cachedExpand( $key, $root, $flags = 0 ) {
+ public function cachedExpand( $key, $root, $flags = 0 ) {
if ( isset( $this->parent->childExpansionCache[$key] ) ) {
return $this->parent->childExpansionCache[$key];
}
*
* @return bool
*/
- function isEmpty() {
+ public function isEmpty() {
return !count( $this->numberedArgs ) && !count( $this->namedArgs );
}
/**
* @return array
*/
- function getArguments() {
+ public function getArguments() {
$arguments = array();
foreach ( array_merge(
array_keys( $this->numberedArgs ),
/**
* @return array
*/
- function getNumberedArguments() {
+ public function getNumberedArguments() {
$arguments = array();
foreach ( array_keys( $this->numberedArgs ) as $key ) {
$arguments[$key] = $this->getArgument( $key );
/**
* @return array
*/
- function getNamedArguments() {
+ public function getNamedArguments() {
$arguments = array();
foreach ( array_keys( $this->namedArgs ) as $key ) {
$arguments[$key] = $this->getArgument( $key );
* @param int $index
* @return array|bool
*/
- function getNumberedArgument( $index ) {
+ public function getNumberedArgument( $index ) {
if ( !isset( $this->numberedArgs[$index] ) ) {
return false;
}
* @param string $name
* @return bool
*/
- function getNamedArgument( $name ) {
+ public function getNamedArgument( $name ) {
if ( !isset( $this->namedArgs[$name] ) ) {
return false;
}
* @param string $name
* @return array|bool
*/
- function getArgument( $name ) {
+ public function getArgument( $name ) {
$text = $this->getNumberedArgument( $name );
if ( $text === false ) {
$text = $this->getNamedArgument( $name );
*
* @return bool
*/
- function isTemplate() {
+ public function isTemplate() {
return true;
}
- function setVolatile( $flag = true ) {
+ public function setVolatile( $flag = true ) {
parent::setVolatile( $flag );
$this->parent->setVolatile( $flag );
}
- function setTTL( $ttl ) {
+ public function setTTL( $ttl ) {
parent::setTTL( $ttl );
$this->parent->setTTL( $ttl );
}
/**
* Expansion frame with custom arguments
* @ingroup Parser
+ * @codingStandardsIgnoreStart
*/
class PPCustomFrame_Hash extends PPFrame_Hash {
- var $args;
+ // @codingStandardsIgnoreEnd
+
+ public $args;
- function __construct( $preprocessor, $args ) {
+ public function __construct( $preprocessor, $args ) {
parent::__construct( $preprocessor );
$this->args = $args;
}
- function __toString() {
+ public function __toString() {
$s = 'cstmframe{';
$first = true;
foreach ( $this->args as $name => $value ) {
/**
* @return bool
*/
- function isEmpty() {
+ public function isEmpty() {
return !count( $this->args );
}
* @param int $index
* @return bool
*/
- function getArgument( $index ) {
+ public function getArgument( $index ) {
if ( !isset( $this->args[$index] ) ) {
return false;
}
return $this->args[$index];
}
- function getArguments() {
+ public function getArguments() {
return $this->args;
}
}
/**
* @ingroup Parser
+ * @codingStandardsIgnoreStart
*/
class PPNode_Hash_Tree implements PPNode {
- var $name, $firstChild, $lastChild, $nextSibling;
+ // @codingStandardsIgnoreEnd
- function __construct( $name ) {
+ public $name, $firstChild, $lastChild, $nextSibling;
+
+ public function __construct( $name ) {
$this->name = $name;
$this->firstChild = $this->lastChild = $this->nextSibling = false;
}
- function __toString() {
+ public function __toString() {
$inner = '';
$attribs = '';
for ( $node = $this->firstChild; $node; $node = $node->nextSibling ) {
* @param string $text
* @return PPNode_Hash_Tree
*/
- static function newWithText( $name, $text ) {
+ public static function newWithText( $name, $text ) {
$obj = new self( $name );
$obj->addChild( new PPNode_Hash_Text( $text ) );
return $obj;
}
- function addChild( $node ) {
+ public function addChild( $node ) {
if ( $this->lastChild === false ) {
$this->firstChild = $this->lastChild = $node;
} else {
/**
* @return PPNode_Hash_Array
*/
- function getChildren() {
+ public function getChildren() {
$children = array();
for ( $child = $this->firstChild; $child; $child = $child->nextSibling ) {
$children[] = $child;
return new PPNode_Hash_Array( $children );
}
- function getFirstChild() {
+ public function getFirstChild() {
return $this->firstChild;
}
- function getNextSibling() {
+ public function getNextSibling() {
return $this->nextSibling;
}
- function getChildrenOfType( $name ) {
+ public function getChildrenOfType( $name ) {
$children = array();
for ( $child = $this->firstChild; $child; $child = $child->nextSibling ) {
if ( isset( $child->name ) && $child->name === $name ) {
/**
* @return bool
*/
- function getLength() {
+ public function getLength() {
return false;
}
* @param int $i
* @return bool
*/
- function item( $i ) {
+ public function item( $i ) {
return false;
}
/**
* @return string
*/
- function getName() {
+ public function getName() {
return $this->name;
}
* @throws MWException
* @return array
*/
- function splitArg() {
+ public function splitArg() {
$bits = array();
for ( $child = $this->firstChild; $child; $child = $child->nextSibling ) {
if ( !isset( $child->name ) ) {
* @throws MWException
* @return array
*/
- function splitExt() {
+ public function splitExt() {
$bits = array();
for ( $child = $this->firstChild; $child; $child = $child->nextSibling ) {
if ( !isset( $child->name ) ) {
* @throws MWException
* @return array
*/
- function splitHeading() {
+ public function splitHeading() {
if ( $this->name !== 'h' ) {
throw new MWException( 'Invalid h node passed to ' . __METHOD__ );
}
* @throws MWException
* @return array
*/
- function splitTemplate() {
+ public function splitTemplate() {
$parts = array();
$bits = array( 'lineStart' => '' );
for ( $child = $this->firstChild; $child; $child = $child->nextSibling ) {
/**
* @ingroup Parser
+ * @codingStandardsIgnoreStart
*/
class PPNode_Hash_Text implements PPNode {
- var $value, $nextSibling;
+ // @codingStandardsIgnoreEnd
+
+ public $value, $nextSibling;
- function __construct( $value ) {
+ public function __construct( $value ) {
if ( is_object( $value ) ) {
throw new MWException( __CLASS__ . ' given object instead of string' );
}
$this->value = $value;
}
- function __toString() {
+ public function __toString() {
return htmlspecialchars( $this->value );
}
- function getNextSibling() {
+ public function getNextSibling() {
return $this->nextSibling;
}
- function getChildren() {
+ public function getChildren() {
return false;
}
- function getFirstChild() {
+ public function getFirstChild() {
return false;
}
- function getChildrenOfType( $name ) {
+ public function getChildrenOfType( $name ) {
return false;
}
- function getLength() {
+ public function getLength() {
return false;
}
- function item( $i ) {
+ public function item( $i ) {
return false;
}
- function getName() {
+ public function getName() {
return '#text';
}
- function splitArg() {
+ public function splitArg() {
throw new MWException( __METHOD__ . ': not supported' );
}
- function splitExt() {
+ public function splitExt() {
throw new MWException( __METHOD__ . ': not supported' );
}
- function splitHeading() {
+ public function splitHeading() {
throw new MWException( __METHOD__ . ': not supported' );
}
}
/**
* @ingroup Parser
+ * @codingStandardsIgnoreStart
*/
class PPNode_Hash_Array implements PPNode {
- var $value, $nextSibling;
+ // @codingStandardsIgnoreEnd
- function __construct( $value ) {
+ public $value, $nextSibling;
+
+ public function __construct( $value ) {
$this->value = $value;
}
- function __toString() {
+ public function __toString() {
return var_export( $this, true );
}
- function getLength() {
+ public function getLength() {
return count( $this->value );
}
- function item( $i ) {
+ public function item( $i ) {
return $this->value[$i];
}
- function getName() {
+ public function getName() {
return '#nodelist';
}
- function getNextSibling() {
+ public function getNextSibling() {
return $this->nextSibling;
}
- function getChildren() {
+ public function getChildren() {
return false;
}
- function getFirstChild() {
+ public function getFirstChild() {
return false;
}
- function getChildrenOfType( $name ) {
+ public function getChildrenOfType( $name ) {
return false;
}
- function splitArg() {
+ public function splitArg() {
throw new MWException( __METHOD__ . ': not supported' );
}
- function splitExt() {
+ public function splitExt() {
throw new MWException( __METHOD__ . ': not supported' );
}
- function splitHeading() {
+ public function splitHeading() {
throw new MWException( __METHOD__ . ': not supported' );
}
}
/**
* @ingroup Parser
+ * @codingStandardsIgnoreStart
*/
class PPNode_Hash_Attr implements PPNode {
- var $name, $value, $nextSibling;
+ // @codingStandardsIgnoreEnd
+
+ public $name, $value, $nextSibling;
- function __construct( $name, $value ) {
+ public function __construct( $name, $value ) {
$this->name = $name;
$this->value = $value;
}
- function __toString() {
+ public function __toString() {
return "<@{$this->name}>" . htmlspecialchars( $this->value ) . "</@{$this->name}>";
}
- function getName() {
+ public function getName() {
return $this->name;
}
- function getNextSibling() {
+ public function getNextSibling() {
return $this->nextSibling;
}
- function getChildren() {
+ public function getChildren() {
return false;
}
- function getFirstChild() {
+ public function getFirstChild() {
return false;
}
- function getChildrenOfType( $name ) {
+ public function getChildrenOfType( $name ) {
return false;
}
- function getLength() {
+ public function getLength() {
return false;
}
- function item( $i ) {
+ public function item( $i ) {
return false;
}
- function splitArg() {
+ public function splitArg() {
throw new MWException( __METHOD__ . ': not supported' );
}
- function splitExt() {
+ public function splitExt() {
throw new MWException( __METHOD__ . ': not supported' );
}
- function splitHeading() {
+ public function splitHeading() {
throw new MWException( __METHOD__ . ': not supported' );
}
}