Debian Codegraph @

includes/parser/PPFrame.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 MediaWiki\Title\Title;
25
26 /**
27 * @ingroup Parser
28 *
29 * @property int $depth
30 * @property PPFrame $parent
31 */
32 interface PPFrame {
33 public const NO_ARGS = 1;
34 public const NO_TEMPLATES = 2;
35 public const STRIP_COMMENTS = 4;
36 public const NO_IGNORE = 8;
37 public const RECOVER_COMMENTS = 16;
38 public const NO_TAGS = 32;
39 public const PROCESS_NOWIKI = 64;
40
41 public const RECOVER_ORIG = self::NO_ARGS | self::NO_TEMPLATES | self::NO_IGNORE |
42 self::RECOVER_COMMENTS | self::NO_TAGS;
43
44 /**
45 * Create a child frame
46 *
47 * @param PPNode[]|false $args
48 * @param Title|false $title
49 * @param int $indexOffset A number subtracted from the index attributes of the arguments
50 *
51 * @return PPFrame
52 */
53 public function newChild( $args = false, $title = false, $indexOffset = 0 );
54
55 /**
56 * Expand a document tree node, caching the result on its parent with the given key
57 * @param string|int $key
58 * @param string|PPNode $root
59 * @param int $flags
60 * @return string
61 */
62 public function cachedExpand( $key, $root, $flags = 0 );
63
64 /**
65 * Expand a document tree node
66 * @param string|PPNode $root
67 * @param int $flags
68 * @return string
69 */
70 public function expand( $root, $flags = 0 );
71
72 /**
73 * Implode with flags for expand()
74 * @param string $sep
75 * @param int $flags
76 * @param string|PPNode ...$params
77 * @return string
78 */
79 public function implodeWithFlags( $sep, $flags, ...$params );
80
81 /**
82 * Implode with no flags specified
83 * @param string $sep
84 * @param string|PPNode ...$params
85 * @return string
86 */
87 public function implode( $sep, ...$params );
88
89 /**
90 * Makes an object that, when expand()ed, will be the same as one obtained
91 * with implode()
92 * @param string $sep
93 * @param string|PPNode ...$params
94 * @return PPNode
95 */
96 public function virtualImplode( $sep, ...$params );
97
98 /**
99 * Virtual implode with brackets
100 * @param string $start
101 * @param string $sep
102 * @param string $end
103 * @param string|PPNode ...$params
104 * @return PPNode
105 */
106 public function virtualBracketedImplode( $start, $sep, $end, ...$params );
107
108 /**
109 * Returns true if there are no arguments in this frame
110 *
111 * @return bool
112 */
113 public function isEmpty();
114
115 /**
116 * Returns all arguments of this frame
117 * @return array
118 */
119 public function getArguments();
120
121 /**
122 * Returns all numbered arguments of this frame
123 * @return array
124 */
125 public function getNumberedArguments();
126
127 /**
128 * Returns all named arguments of this frame
129 * @return array
130 */
131 public function getNamedArguments();
132
133 /**
134 * Get an argument to this frame by name
135 * @param int|string $name
136 * @return string|false
137 */
138 public function getArgument( $name );
139
140 /**
141 * Returns true if the infinite loop check is OK, false if a loop is detected
142 *
143 * @param Title $title
144 * @return bool
145 */
146 public function loopCheck( $title );
147
148 /**
149 * Return true if the frame is a template frame
150 * @return bool
151 */
152 public function isTemplate();
153
154 /**
155 * Set the "volatile" flag.
156 *
157 * Note that this is somewhat of a "hack" in order to make extensions
158 * with side effects (such as Cite) work with the PHP parser. New
159 * extensions should be written in a way that they do not need this
160 * function, because other parsers (such as Parsoid) are not guaranteed
161 * to respect it, and it may be removed in the future.
162 *
163 * @param bool $flag
164 */
165 public function setVolatile( $flag = true );
166
167 /**
168 * Get the "volatile" flag.
169 *
170 * Callers should avoid caching the result of an expansion if it has the
171 * volatile flag set.
172 *
173 * @see self::setVolatile()
174 * @return bool
175 */
176 public function isVolatile();
177
178 /**
179 * Get the TTL of the frame's output.
180 *
181 * This is the maximum amount of time, in seconds, that this frame's
182 * output should be cached for. A value of null indicates that no
183 * maximum has been specified.
184 *
185 * Note that this TTL only applies to caching frames as parts of pages.
186 * It is not relevant to caching the entire rendered output of a page.
187 *
188 * @return int|null
189 */
190 public function getTTL();
191
192 /**
193 * Set the TTL of the output of this frame and all of its ancestors.
194 * Has no effect if the new TTL is greater than the one already set.
195 * Note that it is the caller's responsibility to change the cache
196 * expiry of the page as a whole, if such behavior is desired.
197 *
198 * @see self::getTTL()
199 * @param int $ttl
200 */
201 public function setTTL( $ttl );
202
203 /**
204 * Get a title of frame
205 *
206 * @return Title
207 */
208 public function getTitle();
209 }
210
211 /** @deprecated class alias since 1.43 */
212 class_alias( PPFrame::class, 'PPFrame' );