MediaWiki REL1_34
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
28 public $name, $value;
29 private $store, $index;
30
38 public function __construct( array $store, $index ) {
39 $descriptor = $store[$index];
40 if ( $descriptor[PPNode_Hash_Tree::NAME][0] !== '@' ) {
41 throw new MWException( __METHOD__ . ': invalid name in attribute descriptor' );
42 }
43 $this->name = substr( $descriptor[PPNode_Hash_Tree::NAME], 1 );
44 $this->value = $descriptor[PPNode_Hash_Tree::CHILDREN][0];
45 $this->store = $store;
46 $this->index = $index;
47 }
48
49 public function __toString() {
50 return "<@{$this->name}>" . htmlspecialchars( $this->value ) . "</@{$this->name}>";
51 }
52
53 public function getName() {
54 return $this->name;
55 }
56
57 public function getNextSibling() {
58 return PPNode_Hash_Tree::factory( $this->store, $this->index + 1 );
59 }
60
61 public function getChildren() {
62 return false;
63 }
64
65 public function getFirstChild() {
66 return false;
67 }
68
69 public function getChildrenOfType( $name ) {
70 return false;
71 }
72
73 public function getLength() {
74 return false;
75 }
76
77 public function item( $i ) {
78 return false;
79 }
80
81 public function splitArg() {
82 throw new MWException( __METHOD__ . ': not supported' );
83 }
84
85 public function splitExt() {
86 throw new MWException( __METHOD__ . ': not supported' );
87 }
88
89 public function splitHeading() {
90 throw new MWException( __METHOD__ . ': not supported' );
91 }
92}
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