| 1 |
<?php |
| 2 |
|
| 3 |
namespace Wikimedia\RemexHtml\Serializer; |
| 4 |
|
| 5 |
use Wikimedia\RemexHtml\PropGuard; |
| 6 |
use Wikimedia\RemexHtml\Tokenizer\Attributes; |
| 7 |
|
| 8 |
class SerializerNode { |
| 9 |
use PropGuard; |
| 10 |
|
| 11 |
/** @var int The integer index into Serializer::$nodes of this node */ |
| 12 |
public $id; |
| 13 |
|
| 14 |
/** @var int The integer index into Serializer::$nodes of the parent node */ |
| 15 |
public $parentId; |
| 16 |
|
| 17 |
/** @var string The element namespace */ |
| 18 |
public $namespace; |
| 19 |
|
| 20 |
/** @var string The element name */ |
| 21 |
public $name; |
| 22 |
|
| 23 |
/** @var Attributes */ |
| 24 |
public $attrs; |
| 25 |
|
| 26 |
/** |
| 27 |
* @var bool The void flag as in TreeHandler::insertElement |
| 28 |
* @see \Wikimedia\RemexHtml\TreeBuilder\TreeHandler::insertElement |
| 29 |
*/ |
| 30 |
public $void; |
| 31 |
|
| 32 |
/** @var (self|string)[] */ |
| 33 |
public $children = []; |
| 34 |
|
| 35 |
/** |
| 36 |
* Arbitrary user data can be placed here. |
| 37 |
* |
| 38 |
* @var mixed |
| 39 |
*/ |
| 40 |
public $snData; |
| 41 |
|
| 42 |
/** |
| 43 |
* @param int $id The integer index into Serializer::$nodes of this node |
| 44 |
* @param int $parentId The integer index into Serializer::$nodes of the parent node |
| 45 |
* @param string $namespace The XML namespace |
| 46 |
* @param string $name The element name |
| 47 |
* @param Attributes $attrs The element attributes |
| 48 |
* @param bool $void The void flag as in TreeHandler::insertElement |
| 49 |
*/ |
| 50 |
public function __construct( $id, $parentId, $namespace, $name, $attrs, $void ) { |
| 51 |
$this->id = $id; |
| 52 |
$this->parentId = $parentId; |
| 53 |
$this->namespace = $namespace; |
| 54 |
$this->name = $name; |
| 55 |
$this->attrs = $attrs; |
| 56 |
$this->void = $void; |
| 57 |
} |
| 58 |
|
| 59 |
/** |
| 60 |
* Get a string identifying the node, for use in debugging. |
| 61 |
* @return string |
| 62 |
*/ |
| 63 |
public function getDebugTag() { |
| 64 |
return $this->name . '#' . $this->id; |
| 65 |
} |
| 66 |
} |