MediaWiki  master
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 }
int $count
Number of opening characters found (number of "=" for heading)
breakSyntax( $openingCount=false)
Get the accumulator that would result if the close is not found.