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
25 // phpcs:ignore Squiz.Classes.ValidClassName.NotCamelCaps
26 class PPDStackElement_Hash
extends PPDStackElement
{
28 public function __construct( $data = [] ) {
29 $this->partClass
= PPDPart_Hash
::class;
30 parent
::__construct( $data );
34 * Get the accumulator that would result if the close is not found.
36 * @param int|bool $openingCount
39 public function breakSyntax( $openingCount = false ) {
40 if ( $this->open
== "\n" ) {
41 $accum = array_merge( [ $this->savedPrefix
], $this->parts
[0]->out
);
43 if ( $openingCount === false ) {
44 $openingCount = $this->count
;
46 $s = substr( $this->open
, 0, -1 );
48 substr( $this->open
, -1 ),
49 $openingCount - strlen( $s )
51 $accum = [ $this->savedPrefix
. $s ];
54 foreach ( $this->parts
as $part ) {
57 } elseif ( is_string( $accum[$lastIndex] ) ) {
58 $accum[$lastIndex] .= '|';
60 $accum[++
$lastIndex] = '|';
62 foreach ( $part->out
as $node ) {
63 if ( is_string( $node ) && is_string( $accum[$lastIndex] ) ) {
64 $accum[$lastIndex] .= $node;
66 $accum[++
$lastIndex] = $node;