Debian Codegraph @

vendor/wikimedia/parsoid/src/Tokens/CommentTk.php

raw
1 <?php
2 declare( strict_types = 1 );
3
4 namespace Wikimedia\Parsoid\Tokens;
5
6 use Wikimedia\Parsoid\NodeData\DataMw;
7 use Wikimedia\Parsoid\NodeData\DataParsoid;
8
9 /**
10 * Represents a comment
11 */
12 class CommentTk extends Token {
13 /** @var string Comment text */
14 public $value;
15
16 public function __construct(
17 string $value,
18 ?DataParsoid $dataParsoid = null,
19 ?DataMw $dataMw = null
20 ) {
21 // $dataParsoid won't survive in the DOM, but still useful for token serialization
22 // FIXME: verify if this is still required given that html->wt doesn't
23 // use tokens anymore. That was circa 2012 serializer code.
24 parent::__construct( $dataParsoid, $dataMw );
25 $this->value = $value;
26 }
27
28 /**
29 * @inheritDoc
30 */
31 public function jsonSerialize(): array {
32 return [
33 'type' => $this->getType(),
34 'value' => $this->value,
35 'dataParsoid' => $this->dataParsoid,
36 'dataMw' => $this->dataMw,
37 ];
38 }
39 }