MediaWiki  master
PPDStack_Hash.php
Go to the documentation of this file.
1 <?php
26 // phpcs:ignore Squiz.Classes.ValidClassName.NotCamelCaps
29  public $stack;
31  public $rootAccum;
33  public $accum;
34 
38  public $top;
39  public $out;
40  public $elementClass = PPDStackElement_Hash::class;
41 
42  public static $false = false;
43 
44  public function __construct() {
45  $this->stack = [];
46  $this->top = false;
47  $this->rootAccum = [];
48  $this->accum =& $this->rootAccum;
49  }
50 
54  public function count() {
55  return count( $this->stack );
56  }
57 
58  public function &getAccum() {
59  return $this->accum;
60  }
61 
65  public function getCurrentPart() {
66  if ( $this->top === false ) {
67  return false;
68  } else {
69  return $this->top->getCurrentPart();
70  }
71  }
72 
73  public function push( $data ) {
74  if ( $data instanceof $this->elementClass ) {
75  $this->stack[] = $data;
76  } else {
77  $class = $this->elementClass;
78  $this->stack[] = new $class( $data );
79  }
80  $this->top = $this->stack[count( $this->stack ) - 1];
81  $this->accum =& $this->top->getAccum();
82  }
83 
84  public function pop() {
85  if ( $this->stack === [] ) {
86  throw new MWException( __METHOD__ . ': no elements remaining' );
87  }
88  $temp = array_pop( $this->stack );
89 
90  if ( count( $this->stack ) ) {
91  $this->top = $this->stack[count( $this->stack ) - 1];
92  $this->accum =& $this->top->getAccum();
93  } else {
94  $this->top = self::$false;
95  $this->accum =& $this->rootAccum;
96  }
97  return $temp;
98  }
99 
100  public function addPart( $s = '' ) {
101  $this->top->addPart( $s );
102  $this->accum =& $this->top->getAccum();
103  }
104 
108  public function getFlags() {
109  if ( $this->stack === [] ) {
110  return [
111  'findEquals' => false,
112  'findPipe' => false,
113  'inHeading' => false,
114  ];
115  } else {
116  return $this->top->getFlags();
117  }
118  }
119 }
PPDStack_Hash\getFlags
getFlags()
Definition: PPDStack_Hash.php:108
PPDStack_Hash\getCurrentPart
getCurrentPart()
Definition: PPDStack_Hash.php:65
PPDStack_Hash\push
push( $data)
Definition: PPDStack_Hash.php:73
PPDStack_Hash\$out
$out
Definition: PPDStack_Hash.php:39
MWException
MediaWiki exception.
Definition: MWException.php:29
PPDStack_Hash\addPart
addPart( $s='')
Definition: PPDStack_Hash.php:100
PPDStack_Hash\$stack
PPDStackElement_Hash[] $stack
Definition: PPDStack_Hash.php:29
PPDStackElement_Hash
Definition: PPDStackElement_Hash.php:29
PPDStack_Hash\count
count()
Definition: PPDStack_Hash.php:54
PPDStack_Hash\$elementClass
$elementClass
Definition: PPDStack_Hash.php:40
PPDStack_Hash\$accum
string[] $accum
Definition: PPDStack_Hash.php:33
$s
foreach( $mmfl['setupFiles'] as $fileName) if( $queue) if(empty( $mmfl['quiet'])) $s
Definition: mergeMessageFileList.php:206
PPDStack_Hash\$top
PPDStackElement_Hash false $top
Definition: PPDStack_Hash.php:38
PPDStack_Hash\$false
static $false
Definition: PPDStack_Hash.php:42
PPDStack_Hash
Stack class to help Preprocessor::preprocessToObj()
Definition: PPDStack_Hash.php:27
PPDStack_Hash\pop
pop()
Definition: PPDStack_Hash.php:84
PPDStack_Hash\__construct
__construct()
Definition: PPDStack_Hash.php:44
PPDStack_Hash\$rootAccum
string[] $rootAccum
Definition: PPDStack_Hash.php:31
PPDStack_Hash\getAccum
& getAccum()
Definition: PPDStack_Hash.php:58