Merge "Type hint against LinkTarget in WatchedItemStore"
[lhc/web/wiklou.git] / includes / parser / PPCustomFrame_DOM.php
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 /**
23 * Expansion frame with custom arguments
24 * @deprecated since 1.34, use PPCustomFrame_Hash
25 * @ingroup Parser
26 */
27 // phpcs:ignore Squiz.Classes.ValidClassName.NotCamelCaps
28 class PPCustomFrame_DOM extends PPFrame_DOM {
29
30 public $args;
31
32 public function __construct( $preprocessor, $args ) {
33 parent::__construct( $preprocessor );
34 $this->args = $args;
35 }
36
37 public function __toString() {
38 $s = 'cstmframe{';
39 $first = true;
40 foreach ( $this->args as $name => $value ) {
41 if ( $first ) {
42 $first = false;
43 } else {
44 $s .= ', ';
45 }
46 $s .= "\"$name\":\"" .
47 str_replace( '"', '\\"', $value->__toString() ) . '"';
48 }
49 $s .= '}';
50 return $s;
51 }
52
53 /**
54 * @return bool
55 */
56 public function isEmpty() {
57 return !count( $this->args );
58 }
59
60 /**
61 * @param int|string $index
62 * @return string|bool
63 */
64 public function getArgument( $index ) {
65 return $this->args[$index] ?? false;
66 }
67
68 public function getArguments() {
69 return $this->args;
70 }
71 }