[JsonCodec] Hide TYPE_ANNOTATION from the unserialization methods
[mediawiki.git] / includes / parser / PPNode_Hash_Text.php
blobb123cc95b5eb7b9fdcd51032bf5e3bf0f481187d
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.
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.
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
18 * @file
19 * @ingroup Parser
22 /**
23 * @ingroup Parser
25 // phpcs:ignore Squiz.Classes.ValidClassName.NotCamelCaps
26 class PPNode_Hash_Text implements PPNode {
28 /** @var string */
29 public $value;
30 /** @var array */
31 private $store;
32 /** @var int */
33 private $index;
35 /**
36 * Construct an object using the data from $store[$index]. The rest of the
37 * store array can be accessed via getNextSibling().
39 * @param array $store
40 * @param int $index
42 public function __construct( array $store, $index ) {
43 if ( !is_scalar( $store[$index] ) ) {
44 throw new InvalidArgumentException( __CLASS__ . ' given object instead of string' );
46 $this->value = $store[$index];
47 $this->store = $store;
48 $this->index = $index;
51 public function __toString() {
52 return htmlspecialchars( $this->value, ENT_COMPAT );
55 public function getNextSibling() {
56 return PPNode_Hash_Tree::factory( $this->store, $this->index + 1 );
59 public function getChildren() {
60 return false;
63 public function getFirstChild() {
64 return false;
67 public function getChildrenOfType( $name ) {
68 return false;
71 public function getLength() {
72 return false;
75 public function item( $i ) {
76 return false;
79 public function getName() {
80 return '#text';
83 public function splitArg() {
84 // @phan-suppress-previous-line PhanPluginNeverReturnMethod
85 throw new LogicException( __METHOD__ . ': not supported' );
88 public function splitExt() {
89 // @phan-suppress-previous-line PhanPluginNeverReturnMethod
90 throw new LogicException( __METHOD__ . ': not supported' );
93 public function splitHeading() {
94 // @phan-suppress-previous-line PhanPluginNeverReturnMethod
95 throw new LogicException( __METHOD__ . ': not supported' );