MediaWiki  1.34.0
PPNode_Hash_Attr.php
Go to the documentation of this file.
1 <?php
25 // phpcs:ignore Squiz.Classes.ValidClassName.NotCamelCaps
26 class 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 }
PPNode_Hash_Attr\$name
$name
Definition: PPNode_Hash_Attr.php:28
PPNode_Hash_Attr\splitExt
splitExt()
Split an "<ext>" node into an associative array containing name, attr, inner and close All values in ...
Definition: PPNode_Hash_Attr.php:85
value
if( $inline) $status value
Definition: SyntaxHighlight.php:346
PPNode_Hash_Attr\$store
$store
Definition: PPNode_Hash_Attr.php:29
PPNode_Hash_Attr\item
item( $i)
Returns an item of an array-type node.
Definition: PPNode_Hash_Attr.php:77
PPNode_Hash_Attr\getFirstChild
getFirstChild()
Get the first child of a tree node.
Definition: PPNode_Hash_Attr.php:65
PPNode_Hash_Attr\splitHeading
splitHeading()
Split an "<h>" node.
Definition: PPNode_Hash_Attr.php:89
PPNode_Hash_Attr\getChildrenOfType
getChildrenOfType( $name)
Get all children of this tree node which have a given name.
Definition: PPNode_Hash_Attr.php:69
MWException
MediaWiki exception.
Definition: MWException.php:26
PPNode_Hash_Tree\CHILDREN
const CHILDREN
The offset of the child list within descriptors, used in some places for readability.
Definition: PPNode_Hash_Tree.php:57
PPNode
There are three types of nodes:
Definition: PPNode.php:35
PPNode_Hash_Attr\$value
$value
Definition: PPNode_Hash_Attr.php:28
PPNode_Hash_Attr\getLength
getLength()
Returns the length of the array, or false if this is not an array-type node.
Definition: PPNode_Hash_Attr.php:73
PPNode_Hash_Attr\$index
$index
Definition: PPNode_Hash_Attr.php:29
PPNode_Hash_Attr\getChildren
getChildren()
Get an array-type node containing the children of this node.
Definition: PPNode_Hash_Attr.php:61
PPNode_Hash_Attr\getNextSibling
getNextSibling()
Get the next sibling of any node.
Definition: PPNode_Hash_Attr.php:57
PPNode_Hash_Attr
Definition: PPNode_Hash_Attr.php:26
PPNode_Hash_Attr\getName
getName()
Get the name of this node.
Definition: PPNode_Hash_Attr.php:53
PPNode_Hash_Attr\splitArg
splitArg()
Split a "<part>" node into an associative array containing: name PPNode name index String index value...
Definition: PPNode_Hash_Attr.php:81
PPNode_Hash_Attr\__construct
__construct(array $store, $index)
Construct an object using the data from $store[$index].
Definition: PPNode_Hash_Attr.php:38
PPNode_Hash_Attr\__toString
__toString()
Definition: PPNode_Hash_Attr.php:49
PPNode_Hash_Tree\factory
static factory(array $store, $index)
Construct an appropriate PPNode_Hash_* object with a class that depends on what is at the relevant st...
Definition: PPNode_Hash_Tree.php:81
PPNode_Hash_Tree\NAME
const NAME
The offset of the name within descriptors, used in some places for readability.
Definition: PPNode_Hash_Tree.php:51