* @return PPNode_Hash_Array
*/
public function newPartNodeArray( $values ) {
- $list = array();
+ $list = [];
foreach ( $values as $k => $val ) {
$partNode = new PPNode_Hash_Tree( 'part' );
return $node;
}
-
/**
* Preprocess some wikitext and return the document tree.
* This is the ghost of Parser::replace_variables().
$xmlishElements = $this->parser->getStripList();
$enableOnlyinclude = false;
if ( $forInclusion ) {
- $ignoredTags = array( 'includeonly', '/includeonly' );
- $ignoredElements = array( 'noinclude' );
+ $ignoredTags = [ 'includeonly', '/includeonly' ];
+ $ignoredElements = [ 'noinclude' ];
$xmlishElements[] = 'noinclude';
if ( strpos( $text, '<onlyinclude>' ) !== false
&& strpos( $text, '</onlyinclude>' ) !== false
$enableOnlyinclude = true;
}
} else {
- $ignoredTags = array( 'noinclude', '/noinclude', 'onlyinclude', '/onlyinclude' );
- $ignoredElements = array( 'includeonly' );
+ $ignoredTags = [ 'noinclude', '/noinclude', 'onlyinclude', '/onlyinclude' ];
+ $ignoredElements = [ 'includeonly' ];
$xmlishElements[] = 'includeonly';
}
$xmlishRegex = implode( '|', array_merge( $xmlishElements, $ignoredTags ) );
// Keep looking forward as long as we're finding more
// comments.
- $comments = array( array( $wsStart, $wsEnd ) );
+ $comments = [ [ $wsStart, $wsEnd ] ];
while ( substr( $text, $wsEnd + 1, 4 ) == '<!--' ) {
$c = strpos( $text, '-->', $wsEnd + 4 );
if ( $c === false ) {
break;
}
$c = $c + 2 + strspn( $text, " \t", $c + 3 );
- $comments[] = array( $wsEnd + 1, $c );
+ $comments[] = [ $wsEnd + 1, $c ];
$wsEnd = $c;
}
// heading. This is heuristic, but AFAICT the methods for
// completely correct disambiguation are very complex.
} elseif ( $count > 0 ) {
- $piece = array(
+ $piece = [
'open' => "\n",
'close' => "\n",
- 'parts' => array( new PPDPart_Hash( str_repeat( '=', $count ) ) ),
+ 'parts' => [ new PPDPart_Hash( str_repeat( '=', $count ) ) ],
'startPos' => $i,
- 'count' => $count );
+ 'count' => $count ];
$stack->push( $piece );
$accum =& $stack->getAccum();
extract( $stack->getFlags() );
# we need to add to stack only if opening brace count is enough for one of the rules
if ( $count >= $rule['min'] ) {
# Add it to the stack
- $piece = array(
+ $piece = [
'open' => $curChar,
'close' => $rule['end'],
'count' => $count,
'lineStart' => ( $i > 0 && $text[$i - 1] == "\n" ),
- );
+ ];
$stack->push( $piece );
$accum =& $stack->getAccum();
# Re-add the old stack element if it still has unmatched opening characters remaining
if ( $matchingCount < $piece->count ) {
- $piece->parts = array( new PPDPart_Hash );
+ $piece->parts = [ new PPDPart_Hash ];
$piece->count -= $matchingCount;
# do we still qualify for any callback with remaining count?
$min = $this->rules[$piece->open]['min'];
$this->preprocessor = $preprocessor;
$this->parser = $preprocessor->parser;
$this->title = $this->parser->mTitle;
- $this->titleCache = array( $this->title ? $this->title->getPrefixedDBkey() : false );
- $this->loopCheckHash = array();
+ $this->titleCache = [ $this->title ? $this->title->getPrefixedDBkey() : false ];
+ $this->loopCheckHash = [];
$this->depth = 0;
- $this->childExpansionCache = array();
+ $this->childExpansionCache = [];
}
/**
* @return PPTemplateFrame_Hash
*/
public function newChild( $args = false, $title = false, $indexOffset = 0 ) {
- $namedArgs = array();
- $numberedArgs = array();
+ $namedArgs = [];
+ $numberedArgs = [];
if ( $title === false ) {
$title = $this->title;
}
$this->parser->mHighestExpansionDepth = $expansionDepth;
}
- $outStack = array( '', '' );
- $iteratorStack = array( false, $root );
- $indexStack = array( 0, 0 );
+ $outStack = [ '', '' ];
+ $iteratorStack = [ false, $root ];
+ $indexStack = [ 0, 0 ];
while ( count( $iteratorStack ) > 1 ) {
$level = count( $outStack ) - 1;
}
} elseif ( $contextNode->name == 'ext' ) {
# Extension tag
- $bits = $contextNode->splitExt() + array( 'attr' => null, 'inner' => null, 'close' => null );
+ $bits = $contextNode->splitExt() + [ 'attr' => null, 'inner' => null, 'close' => null ];
if ( $flags & PPFrame::NO_TAGS ) {
$s = '<' . $bits['name']->firstChild->value;
if ( $bits['attr'] ) {
$bits = $contextNode->splitHeading();
$titleText = $this->title->getPrefixedDBkey();
- $this->parser->mHeadings[] = array( $titleText, $bits['i'] );
+ $this->parser->mHeadings[] = [ $titleText, $bits['i'] ];
$serial = count( $this->parser->mHeadings ) - 1;
$marker = Parser::MARKER_PREFIX . "-h-$serial-" . Parser::MARKER_SUFFIX;
$s = substr( $s, 0, $bits['level'] ) . $marker . substr( $s, $bits['level'] );
$root = $root->value;
}
if ( !is_array( $root ) ) {
- $root = array( $root );
+ $root = [ $root ];
}
foreach ( $root as $node ) {
if ( $first ) {
$root = $root->value;
}
if ( !is_array( $root ) ) {
- $root = array( $root );
+ $root = [ $root ];
}
foreach ( $root as $node ) {
if ( $first ) {
*/
public function virtualImplode( $sep /*, ... */ ) {
$args = array_slice( func_get_args(), 1 );
- $out = array();
+ $out = [];
$first = true;
foreach ( $args as $root ) {
$root = $root->value;
}
if ( !is_array( $root ) ) {
- $root = array( $root );
+ $root = [ $root ];
}
foreach ( $root as $node ) {
if ( $first ) {
*/
public function virtualBracketedImplode( $start, $sep, $end /*, ... */ ) {
$args = array_slice( func_get_args(), 3 );
- $out = array( $start );
+ $out = [ $start ];
$first = true;
foreach ( $args as $root ) {
$root = $root->value;
}
if ( !is_array( $root ) ) {
- $root = array( $root );
+ $root = [ $root ];
}
foreach ( $root as $node ) {
if ( $first ) {
* @return array
*/
public function getArguments() {
- return array();
+ return [];
}
/**
* @return array
*/
public function getNumberedArguments() {
- return array();
+ return [];
}
/**
* @return array
*/
public function getNamedArguments() {
- return array();
+ return [];
}
/**
* @param array $namedArgs
* @param bool|Title $title
*/
- public function __construct( $preprocessor, $parent = false, $numberedArgs = array(),
- $namedArgs = array(), $title = false
+ public function __construct( $preprocessor, $parent = false, $numberedArgs = [],
+ $namedArgs = [], $title = false
) {
parent::__construct( $preprocessor );
$this->loopCheckHash[$pdbk] = true;
}
$this->depth = $parent->depth + 1;
- $this->numberedExpansionCache = $this->namedExpansionCache = array();
+ $this->numberedExpansionCache = $this->namedExpansionCache = [];
}
public function __toString() {
* @return array
*/
public function getArguments() {
- $arguments = array();
+ $arguments = [];
foreach ( array_merge(
array_keys( $this->numberedArgs ),
array_keys( $this->namedArgs ) ) as $key ) {
* @return array
*/
public function getNumberedArguments() {
- $arguments = array();
+ $arguments = [];
foreach ( array_keys( $this->numberedArgs ) as $key ) {
$arguments[$key] = $this->getArgument( $key );
}
* @return array
*/
public function getNamedArguments() {
- $arguments = array();
+ $arguments = [];
foreach ( array_keys( $this->namedArgs ) as $key ) {
$arguments[$key] = $this->getArgument( $key );
}
* @return PPNode_Hash_Array
*/
public function getChildren() {
- $children = array();
+ $children = [];
for ( $child = $this->firstChild; $child; $child = $child->nextSibling ) {
$children[] = $child;
}
}
public function getChildrenOfType( $name ) {
- $children = array();
+ $children = [];
for ( $child = $this->firstChild; $child; $child = $child->nextSibling ) {
if ( isset( $child->name ) && $child->name === $name ) {
$children[] = $child;
* @return array
*/
public function splitArg() {
- $bits = array();
+ $bits = [];
for ( $child = $this->firstChild; $child; $child = $child->nextSibling ) {
if ( !isset( $child->name ) ) {
continue;
* @return array
*/
public function splitExt() {
- $bits = array();
+ $bits = [];
for ( $child = $this->firstChild; $child; $child = $child->nextSibling ) {
if ( !isset( $child->name ) ) {
continue;
if ( $this->name !== 'h' ) {
throw new MWException( 'Invalid h node passed to ' . __METHOD__ );
}
- $bits = array();
+ $bits = [];
for ( $child = $this->firstChild; $child; $child = $child->nextSibling ) {
if ( !isset( $child->name ) ) {
continue;
* @return array
*/
public function splitTemplate() {
- $parts = array();
- $bits = array( 'lineStart' => '' );
+ $parts = [];
+ $bits = [ 'lineStart' => '' ];
for ( $child = $this->firstChild; $child; $child = $child->nextSibling ) {
if ( !isset( $child->name ) ) {
continue;