MediaWiki master
PPNode_Hash_Text.php
Go to the documentation of this file.
1<?php
22namespace MediaWiki\Parser;
23
24use InvalidArgumentException;
25use LogicException;
26use Stringable;
27
31// phpcs:ignore Squiz.Classes.ValidClassName.NotCamelCaps
32class PPNode_Hash_Text implements Stringable, PPNode {
33
35 public $value;
37 private $store;
39 private $index;
40
48 public function __construct( array $store, $index ) {
49 if ( !is_scalar( $store[$index] ) ) {
50 throw new InvalidArgumentException( __CLASS__ . ' given object instead of string' );
51 }
52 $this->value = $store[$index];
53 $this->store = $store;
54 $this->index = $index;
55 }
56
57 public function __toString() {
58 return htmlspecialchars( $this->value, ENT_COMPAT );
59 }
60
61 public function getNextSibling() {
62 return PPNode_Hash_Tree::factory( $this->store, $this->index + 1 );
63 }
64
65 public function getChildren() {
66 return false;
67 }
68
69 public function getFirstChild() {
70 return false;
71 }
72
73 public function getChildrenOfType( $name ) {
74 return false;
75 }
76
77 public function getLength() {
78 return false;
79 }
80
81 public function item( $i ) {
82 return false;
83 }
84
85 public function getName() {
86 return '#text';
87 }
88
89 public function splitArg() {
90 // @phan-suppress-previous-line PhanPluginNeverReturnMethod
91 throw new LogicException( __METHOD__ . ': not supported' );
92 }
93
94 public function splitExt() {
95 // @phan-suppress-previous-line PhanPluginNeverReturnMethod
96 throw new LogicException( __METHOD__ . ': not supported' );
97 }
98
99 public function splitHeading() {
100 // @phan-suppress-previous-line PhanPluginNeverReturnMethod
101 throw new LogicException( __METHOD__ . ': not supported' );
102 }
103}
104
106class_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.
getChildrenOfType( $name)
Get all children of this tree node which have a given name.
__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 ...
getNextSibling()
Get the next sibling of any node.
getName()
Get the name of this node.
getChildren()
Get an array-type node containing the children of this node.
getFirstChild()
Get the first child of a tree node.
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:37