MediaWiki  1.34.0
PPDStackElement_Hash.php
Go to the documentation of this file.
1 <?php
26 // phpcs:ignore Squiz.Classes.ValidClassName.NotCamelCaps
28 
29  public function __construct( $data = [] ) {
30  $this->partClass = PPDPart_Hash::class;
31  parent::__construct( $data );
32  }
33 
41  public function breakSyntax( $openingCount = false ) {
42  if ( $this->open == "\n" ) {
43  $accum = array_merge( [ $this->savedPrefix ], $this->parts[0]->out );
44  } else {
45  if ( $openingCount === false ) {
46  $openingCount = $this->count;
47  }
48  $s = substr( $this->open, 0, -1 );
49  $s .= str_repeat(
50  substr( $this->open, -1 ),
51  $openingCount - strlen( $s )
52  );
53  $accum = [ $this->savedPrefix . $s ];
54  $lastIndex = 0;
55  $first = true;
56  foreach ( $this->parts as $part ) {
57  if ( $first ) {
58  $first = false;
59  } elseif ( is_string( $accum[$lastIndex] ) ) {
60  $accum[$lastIndex] .= '|';
61  } else {
62  $accum[++$lastIndex] = '|';
63  }
64 
65  foreach ( $part->out as $node ) {
66  if ( is_string( $node ) && is_string( $accum[$lastIndex] ) ) {
67  $accum[$lastIndex] .= $node;
68  } else {
69  $accum[++$lastIndex] = $node;
70  }
71  }
72  }
73  }
74  return $accum;
75  }
76 }
$s
$s
Definition: mergeMessageFileList.php:185
PPDStackElement
Definition: PPDStackElement.php:27
PPDStackElement\$count
int $count
Number of opening characters found (number of "=" for heading)
Definition: PPDStackElement.php:47
PPDStackElement_Hash
Definition: PPDStackElement_Hash.php:27
PPDStackElement_Hash\__construct
__construct( $data=[])
Definition: PPDStackElement_Hash.php:29
PPDStackElement_Hash\breakSyntax
breakSyntax( $openingCount=false)
Get the accumulator that would result if the close is not found.
Definition: PPDStackElement_Hash.php:41