MediaWiki master
PPNode_Hash_Text.php
Go to the documentation of this file.
1<?php
8namespace MediaWiki\Parser;
9
10use InvalidArgumentException;
11use LogicException;
12use Stringable;
13
17// phpcs:ignore Squiz.Classes.ValidClassName.NotCamelCaps
18class PPNode_Hash_Text implements Stringable, PPNode {
19
21 public $value;
23 private $store;
25 private $index;
26
34 public function __construct( array $store, $index ) {
35 if ( !is_scalar( $store[$index] ) ) {
36 throw new InvalidArgumentException( __CLASS__ . ' given object instead of string' );
37 }
38 $this->value = $store[$index];
39 $this->store = $store;
40 $this->index = $index;
41 }
42
43 public function __toString() {
44 return htmlspecialchars( $this->value, ENT_COMPAT );
45 }
46
48 public function getNextSibling() {
49 return PPNode_Hash_Tree::factory( $this->store, $this->index + 1 );
50 }
51
53 public function getChildren() {
54 return false;
55 }
56
58 public function getFirstChild() {
59 return false;
60 }
61
63 public function getChildrenOfType( $name ) {
64 return false;
65 }
66
68 public function getLength() {
69 return false;
70 }
71
73 public function item( $i ) {
74 return false;
75 }
76
78 public function getName() {
79 return '#text';
80 }
81
83 public function splitArg() {
84 // @phan-suppress-previous-line PhanPluginNeverReturnMethod
85 throw new LogicException( __METHOD__ . ': not supported' );
86 }
87
89 public function splitExt() {
90 // @phan-suppress-previous-line PhanPluginNeverReturnMethod
91 throw new LogicException( __METHOD__ . ': not supported' );
92 }
93
95 public function splitHeading() {
96 // @phan-suppress-previous-line PhanPluginNeverReturnMethod
97 throw new LogicException( __METHOD__ . ': not supported' );
98 }
99}
100
102class_alias( PPNode_Hash_Text::class, 'PPNode_Hash_Text' );
splitArg()
Split a "<part>" node into an associative array containing: name PPNode name index String index value...
item( $i)
Returns an item of an array-type node.PPNode|false
getChildrenOfType( $name)
Get all children of this tree node which have a given name.Returns an array-type node,...
__construct(array $store, $index)
Construct an object using the data from $store[$index].
splitExt()
Split an "<ext>" node into an associative array containing name, attr, inner and close All values in ...
splitHeading()
Split an "<h>" node.array
getNextSibling()
Get the next sibling of any node.False if there isn't one false|PPNode
getName()
Get the name of this node.The following names are defined here:h A heading node. template A double-br...
getChildren()
Get an array-type node containing the children of this node.Returns false if this is not a tree node....
getFirstChild()
Get the first child of a tree node.False if there isn't one.false|PPNode
getLength()
Returns the length of the array, or false if this is not an array-type node.
static factory(array $store, $index)
Construct an appropriate PPNode_Hash_* object with a class that depends on what is at the relevant st...
There are three types of nodes:
Definition PPNode.php:23