Debian Codegraph @

includes/parser/PPNode_Hash_Attr.php

raw symbols SCIP
1 <?php
2 /**
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation; either version 2 of the License, or
6 * (at your option) any later version.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License along
14 * with this program; if not, write to the Free Software Foundation, Inc.,
15 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
16 * http://www.gnu.org/copyleft/gpl.html
17 *
18 * @file
19 * @ingroup Parser
20 */
21
22 namespace MediaWiki\Parser;
23
24 use InvalidArgumentException;
25 use LogicException;
26 use Stringable;
27
28 /**
29 * @ingroup Parser
30 */
31 // phpcs:ignore Squiz.Classes.ValidClassName.NotCamelCaps
32 class PPNode_Hash_Attr implements Stringable, PPNode {
33
34 /** @var string */
35 public $name;
36 /** @var string */
37 public $value;
38 /** @var array */
39 private $store;
40 /** @var int */
41 private $index;
42
43 /**
44 * Construct an object using the data from $store[$index]. The rest of the
45 * store array can be accessed via getNextSibling().
46 *
47 * @param array $store
48 * @param int $index
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 // @phan-suppress-previous-line PhanPluginNeverReturnMethod
95 throw new LogicException( __METHOD__ . ': not supported' );
96 }
97
98 public function splitExt() {
99 // @phan-suppress-previous-line PhanPluginNeverReturnMethod
100 throw new LogicException( __METHOD__ . ': not supported' );
101 }
102
103 public function splitHeading() {
104 // @phan-suppress-previous-line PhanPluginNeverReturnMethod
105 throw new LogicException( __METHOD__ . ': not supported' );
106 }
107 }
108
109 /** @deprecated class alias since 1.43 */
110 class_alias( PPNode_Hash_Attr::class, 'PPNode_Hash_Attr' );