MediaWiki REL1_39
PPNode_Hash_Attr.php
Go to the documentation of this file.
1<?php
25// phpcs:ignore Squiz.Classes.ValidClassName.NotCamelCaps
26class PPNode_Hash_Attr implements PPNode {
27
29 public $name;
31 public $value;
33 private $store;
35 private $index;
36
44 public function __construct( array $store, $index ) {
45 $descriptor = $store[$index];
46 if ( $descriptor[PPNode_Hash_Tree::NAME][0] !== '@' ) {
47 throw new MWException( __METHOD__ . ': invalid name in attribute descriptor' );
48 }
49 $this->name = substr( $descriptor[PPNode_Hash_Tree::NAME], 1 );
50 $this->value = $descriptor[PPNode_Hash_Tree::CHILDREN][0];
51 $this->store = $store;
52 $this->index = $index;
53 }
54
55 public function __toString() {
56 return "<@{$this->name}>" . htmlspecialchars( $this->value, ENT_COMPAT ) . "</@{$this->name}>";
57 }
58
59 public function getName() {
60 return $this->name;
61 }
62
63 public function getNextSibling() {
64 return PPNode_Hash_Tree::factory( $this->store, $this->index + 1 );
65 }
66
67 public function getChildren() {
68 return false;
69 }
70
71 public function getFirstChild() {
72 return false;
73 }
74
75 public function getChildrenOfType( $name ) {
76 return false;
77 }
78
79 public function getLength() {
80 return false;
81 }
82
83 public function item( $i ) {
84 return false;
85 }
86
87 public function splitArg() {
88 // @phan-suppress-previous-line PhanPluginNeverReturnMethod
89 throw new MWException( __METHOD__ . ': not supported' );
90 }
91
92 public function splitExt() {
93 // @phan-suppress-previous-line PhanPluginNeverReturnMethod
94 throw new MWException( __METHOD__ . ': not supported' );
95 }
96
97 public function splitHeading() {
98 // @phan-suppress-previous-line PhanPluginNeverReturnMethod
99 throw new MWException( __METHOD__ . ': not supported' );
100 }
101}
MediaWiki exception.
getChildren()
Get an array-type node containing the children of this node.
splitExt()
Split an "<ext>" node into an associative array containing name, attr, inner and close All values in ...
splitArg()
Split a "<part>" node into an associative array containing: name PPNode name index String index value...
__construct(array $store, $index)
Construct an object using the data from $store[$index].
item( $i)
Returns an item of an array-type node.
getChildrenOfType( $name)
Get all children of this tree node which have a given name.
splitHeading()
Split an "<h>" node.
getName()
Get the name of this node.
getLength()
Returns the length of the array, or false if this is not an array-type node.
getFirstChild()
Get the first child of a tree node.
getNextSibling()
Get the next sibling of any node.
static factory(array $store, $index)
Construct an appropriate PPNode_Hash_* object with a class that depends on what is at the relevant st...
const CHILDREN
The offset of the child list within descriptors, used in some places for readability.
const NAME
The offset of the name within descriptors, used in some places for readability.
There are three types of nodes:
Definition PPNode.php:35