| 1 |
<?php |
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
namespace MediaWiki\Parser; |
| 23 |
|
| 24 |
use InvalidArgumentException; |
| 25 |
use LogicException; |
| 26 |
use Stringable; |
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
class PPNode_Hash_Attr implements Stringable, PPNode { |
| 33 |
|
| 34 |
|
| 35 |
public $name; |
| 36 |
|
| 37 |
public $value; |
| 38 |
|
| 39 |
private $store; |
| 40 |
|
| 41 |
private $index; |
| 42 |
|
| 43 |
|
| 44 |
|
| 45 |
|
| 46 |
|
| 47 |
|
| 48 |
|
| 49 |
|
| 50 |
public function __construct( array $store, $index ) { |
| 51 |
$descriptor = $store[$index]; |
| 52 |
if ( $descriptor[PPNode_Hash_Tree::NAME][0] !== '@' ) { |
| 53 |
throw new InvalidArgumentException( __METHOD__ . ': invalid name in attribute descriptor' ); |
| 54 |
} |
| 55 |
$this->name = substr( $descriptor[PPNode_Hash_Tree::NAME], 1 ); |
| 56 |
$this->value = $descriptor[PPNode_Hash_Tree::CHILDREN][0]; |
| 57 |
$this->store = $store; |
| 58 |
$this->index = $index; |
| 59 |
} |
| 60 |
|
| 61 |
public function __toString() { |
| 62 |
return "<@{$this->name}>" . htmlspecialchars( $this->value, ENT_COMPAT ) . "</@{$this->name}>"; |
| 63 |
} |
| 64 |
|
| 65 |
public function getName() { |
| 66 |
return $this->name; |
| 67 |
} |
| 68 |
|
| 69 |
public function getNextSibling() { |
| 70 |
return PPNode_Hash_Tree::factory( $this->store, $this->index + 1 ); |
| 71 |
} |
| 72 |
|
| 73 |
public function getChildren() { |
| 74 |
return false; |
| 75 |
} |
| 76 |
|
| 77 |
public function getFirstChild() { |
| 78 |
return false; |
| 79 |
} |
| 80 |
|
| 81 |
public function getChildrenOfType( $name ) { |
| 82 |
return false; |
| 83 |
} |
| 84 |
|
| 85 |
public function getLength() { |
| 86 |
return false; |
| 87 |
} |
| 88 |
|
| 89 |
public function item( $i ) { |
| 90 |
return false; |
| 91 |
} |
| 92 |
|
| 93 |
public function splitArg() { |
| 94 |
|
| 95 |
throw new LogicException( __METHOD__ . ': not supported' ); |
| 96 |
} |
| 97 |
|
| 98 |
public function splitExt() { |
| 99 |
|
| 100 |
throw new LogicException( __METHOD__ . ': not supported' ); |
| 101 |
} |
| 102 |
|
| 103 |
public function splitHeading() { |
| 104 |
|
| 105 |
throw new LogicException( __METHOD__ . ': not supported' ); |
| 106 |
} |
| 107 |
} |
| 108 |
|
| 109 |
|
| 110 |
class_alias( PPNode_Hash_Attr::class, 'PPNode_Hash_Attr' ); |