3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation; either version 2 of the License, or
6 * (at your option) any later version.
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License along
14 * with this program; if not, write to the Free Software Foundation, Inc.,
15 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
16 * http://www.gnu.org/copyleft/gpl.html
24 * @property PPDPart_Hash[] $parts
26 // phpcs:ignore Squiz.Classes.ValidClassName.NotCamelCaps
27 class PPDStackElement_Hash
extends PPDStackElement
{
29 public function __construct( $data = [] ) {
30 $this->partClass
= PPDPart_Hash
::class;
31 parent
::__construct( $data );
35 * Get the accumulator that would result if the close is not found.
37 * @param int|bool $openingCount
39 * @suppress PhanParamSignatureMismatch
41 public function breakSyntax( $openingCount = false ) {
42 if ( $this->open
== "\n" ) {
43 $accum = array_merge( [ $this->savedPrefix
], $this->parts
[0]->out
);
45 if ( $openingCount === false ) {
46 $openingCount = $this->count
;
48 $s = substr( $this->open
, 0, -1 );
50 substr( $this->open
, -1 ),
51 $openingCount - strlen( $s )
53 $accum = [ $this->savedPrefix
. $s ];
56 foreach ( $this->parts
as $part ) {
59 } elseif ( is_string( $accum[$lastIndex] ) ) {
60 $accum[$lastIndex] .= '|';
62 $accum[++
$lastIndex] = '|';
65 foreach ( $part->out
as $node ) {
66 if ( is_string( $node ) && is_string( $accum[$lastIndex] ) ) {
67 $accum[$lastIndex] .= $node;
69 $accum[++
$lastIndex] = $node;